Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Input<Bytecode, HashRepresentation>

Data type representing a Transaction Input.

Type parameters

  • Bytecode

  • HashRepresentation

Hierarchy

  • Input

Index

Properties

outpointIndex

outpointIndex: number

The index of the output in the transaction from which this input is spent.

remarks

An "outpoint" is a reference (A.K.A. "pointer") to a specific output in a previous transaction.

outpointTransactionHash

outpointTransactionHash: HashRepresentation

The hash of the raw transaction from which this input is spent in big-endian byte order. This is the byte order typically seen in block explorers and user interfaces (as opposed to little-endian byte order, which is used in standard P2P network messages).

A.K.A. Transaction ID

remarks

An "outpoint" is a reference (A.K.A. "pointer") to a specific output in a previous transaction.

Encoded raw bitcoin transactions serialize this value in little-endian byte order. However, it is more common to use big-endian byte order when displaying transaction hashes. (In part because the SHA-256 specification defines its output as big-endian, so this byte order is output by most cryptographic libraries.)

sequenceNumber

sequenceNumber: number

The positive, 32-bit unsigned integer used as the "sequence number" for this input.

A sequence number is a complex bitfield which can encode several properties about an input:

  • sequence age support – whether or not the input can use OP_CHECKSEQUENCEVERIFY, and the minimum number of blocks or length of time which has passed since this input's source transaction was mined (up to approximately 1 year).
  • locktime support – whether or not the input can use OP_CHECKLOCKTIMEVERIFY

Sequence Age Support

Sequence number age is enforced by mining consensus – a transaction is invalid until it has "aged" such that all outputs referenced by its age-enabled inputs are at least as old as claimed by their respective sequence numbers.

This allows sequence numbers to function as a "relative locktime" for each input: a lockingBytecode can use the OP_CHECKSEQUENCEVERIFY operation to verify that the funds being spent have been "locked" for a minimum required amount of time (or block count). This can be used in protocols which require a reliable "proof-of-publication", like escrow, time-delayed withdrawals, and various payment channel protocols.

Sequence age support is enabled unless the "disable bit" – the most significant bit – is set (i.e. the sequence number is less than (1 << 31) >>> 0/0b10000000000000000000000000000000/2147483648).

If sequence age is enabled, the "type bit" – the most significant bit in the second-most significant byte (1 << 22/0b1000000000000000000000/2097152) – indicates the unit type of the specified age:

  • if set, the age is in units of 512 seconds (using Median Time-Past)
  • if not set, the age is a number of blocks

The least significant 16 bits specify the age (i.e. age = sequenceNumber & 0x0000ffff). This makes the maximum age either 65535 blocks (about 1.25 years) or 33553920 seconds (about 1.06 years).

Locktime Support

Locktime support is disabled for an input if the sequence number is exactly 0xffffffff (4294967295). Because this value requires the "disable bit" to be set, disabling locktime support also disables sequence age support.

With locktime support disabled, if either OP_CHECKLOCKTIMEVERIFY or OP_CHECKSEQUENCEVERIFY are encountered during the validation of unlockingBytecode, an error is produced, and the transaction is invalid.

remarks

The term "sequence number" was the name given to this field in the Satoshi implementation of the bitcoin transaction format. The field was originally intended for use in a multi-party signing protocol where parties updated the "sequence number" to indicate to miners that this input should replace a previously-signed input in an existing, not-yet-mined transaction. The original use-case was not completed and relied on behavior which can not be enforced by mining consensus, so the field was mostly-unused until it was repurposed by BIP68 in block 419328. See BIP68, BIP112, and BIP113 for details.

unlockingBytecode

unlockingBytecode: Bytecode

The bytecode used to unlock a transaction output. To spend an output, unlocking bytecode must be included in a transaction input which – when evaluated in the authentication virtual machine with the locking bytecode – completes in valid state.

A.K.A. scriptSig or "unlocking script"

Generated using TypeDoc