def init_with_stream(stream)
      if stream.eof?
        raise ArgumentError, "Can't parse transaction input from stream because it is already closed."
      end

      if !(@previous_hash = stream.read(32)) || @previous_hash.bytesize != 32
        raise ArgumentError, "Failed to read 32-byte previous_hash from stream."
      end

      if !(@previous_index = BTC::WireFormat.read_uint32le(stream: stream).first)
        raise ArgumentError, "Failed to read previous_index from stream."
      end

      is_coinbase = (@previous_hash == ZERO_HASH256 && @previous_index == INVALID_INDEX)

      if !(scriptdata = BTC::WireFormat.read_string(stream: stream).first)
        raise ArgumentError, "Failed to read signature_script data from stream."
      end

      @coinbase_data = nil
      @signature_script = nil

      if is_coinbase
        @coinbase_data = scriptdata
      else
        @signature_script = BTC::Script.new(data: scriptdata)
      end

      if !(@sequence = BTC::WireFormat.read_uint32le(stream: stream).first)
        raise ArgumentError, "Failed to read sequence from stream."
      end
    end
def init_with_stream(stream)
      if stream.eof?
        raise ArgumentError, "Can't parse transaction input from stream because it is already closed."
      end

      if !(@previous_hash = stream.read(32)) || @previous_hash.bytesize != 32
        raise ArgumentError, "Failed to read 32-byte previous_hash from stream."
      end

      if !(@previous_index = BTC::WireFormat.read_uint32le(stream: stream).first)
        raise ArgumentError, "Failed to read previous_index from stream."
      end

      is_coinbase = (@previous_hash == ZERO_HASH256 && @previous_index == INVALID_INDEX)

      if !(scriptdata = BTC::WireFormat.read_string(stream: stream).first)
        raise ArgumentError, "Failed to read signature_script data from stream."
      end

      @coinbase_data = nil
      @signature_script = nil

      if is_coinbase
        @coinbase_data = scriptdata
      else
        @signature_script = BTC::Script.new(data: scriptdata)
      end

      if !(@sequence = BTC::WireFormat.read_uint32le(stream: stream).first)
        raise ArgumentError, "Failed to read sequence from stream."
      end
    end
Initializes transaction input with its attributes. Every attribute has a valid default value.