Class: Input

Input

new Input(options, mutablenullable)

Represents a transaction input.

Parameters:
Name Type Attributes Description
options NakedInput
mutable Boolean <nullable>
Properties:
Name Type Attributes Description
prevout Object

Outpoint.

Properties
Name Type Description
hash Hash

Previous transaction hash.

index Number

Previous output index.

script Script

Input script / scriptSig.

sequence Number

nSequence.

witness Witness

Witness (empty if not present).

coin Coin <nullable>

Previous output.

type String

Script type.

address String <nullable>

Input address.

mutable Boolean
Source:

Methods

(static) _fromExtended(data, encnullable) → {NakedInput}

Parse an input in "extended" serialization format.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
  • A "naked" input object.
Type
NakedInput

(static) _fromJSON() → {NakedInput}

Handle a deserialized JSON input object.

Source:
Returns:

A "naked" input (a plain javascript object which is suitable for passing to the Input constructor).

Type
NakedInput

(static) _fromRaw(data, encnullable) → {NakedInput}

Parse a serialized input.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:

A "naked" input object.

Type
NakedInput

(static) fromExtended(data, encnullable) → {TX}

Instantiate an input from a Buffer in "extended" serialization format.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
TX

(static) fromJSON(json) → {Input}

Instantiate an Input from a jsonified input object.

Parameters:
Name Type Description
json Object

The jsonified input object.

Source:
Returns:
Type
Input

(static) fromRaw(data, encnullable) → {Input}

Instantiate an input from a serialized Buffer.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Input

(static) isInput(obj) → {Boolean}

Test an object to see if it is an Input.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

getAddress() → (nullable) {String}

Get the previous output script's address. Will "guess" based on the input script and/or witness if coin is not available.

Source:
Returns:

address

Type
String

getRedeem() → (nullable) {Script}

Get the redeem script. Will attempt to resolve nested redeem scripts if witnesspubkeyhash is behind a scripthash.

Source:
Returns:

Redeem script.

Type
Script

getSubtype() → {String}

Get the redeem script type.

Source:
Returns:

subtype

Type
String

getType() → {String}

Get the previous output script type. Will "guess" based on the input script and/or witness if coin is not available.

Source:
Returns:

type

Type
String

inspect() → {Object}

Convert the input to a more user-friendly object.

Source:
Returns:
Type
Object

isCoinbase() → {Boolean}

Test to see if outpoint hash is null.

Source:
Returns:
Type
Boolean

isFinal() → {Boolean}

Test to see if nSequence is equal to uint32max.

Source:
Returns:
Type
Boolean

test(addressMap) → {Boolean}

Test the input against an address, an array of addresses, or a map of addresses.

Parameters:
Name Type Description
addressMap String | Array.<String> | Object
Source:
Returns:

Whether the input matched.

Type
Boolean

toExtended(encnullable) → {Buffer|String}

Serialize the input to an "extended" format, including both the input and the witness.

Parameters:
Name Type Attributes Description
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Buffer | String

toJSON() → {Object}

Convert the input to an object suitable for JSON serialization. Note that the hashes will be reversed to abide by bitcoind's legacy of little-endian uint256s.

Source:
Returns:
Type
Object

toRaw(encnullable) → {Buffer|String}

Serialize the input.

Parameters:
Name Type Attributes Description
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Buffer | String