Creates a new input template for use in a Bitcoin transaction.
The parameters for creating the input template
OptionalamountSats?: stringThe amount in satoshis. Optional since it may come from UTXO data.
The transaction ID of the UTXO being spent (in reversed byte order)
The output index within the transaction being spent
Get the amount in BTC
The amount in BTC (as a string)
Get the amount in satoshis
The amount in satoshis (as a string)
Set amount in satoshis
Gets the BIP32 derivation information for all public keys in this input. This information is crucial for hardware wallets and multisig coordinators to identify which keys they control and how to derive them.
Sets the BIP32 derivation information for all public keys in this input. Each derivation entry maps a public key to its derivation path and master fingerprint.
Array of BIP32 derivation information
Gets the non-witness UTXO.
Sets the non-witness UTXO. Required for non-segwit inputs in PSBTs.
The full transaction containing the UTXO being spent
Gets the redeem script for P2SH inputs. The redeem script contains the actual spending conditions for P2SH outputs. For multisig P2SH, this is the multisig script with the signature requirements.
Sets the redeem script for P2SH inputs. Required for spending P2SH outputs in PSBTs.
The redeem script buffer
Get the sequence number
Sets the sequence number for the input. Optional, but useful for RBF signaling.
The sequence number
The transaction ID of the UTXO (reversed, big-endian). Required for all PSBT inputs.
The output index in the transaction. Required for all PSBT inputs.
Gets the witness script for segwit inputs (P2WSH, P2SH-P2WSH). The witness script contains the actual spending conditions for segwit script outputs. For multisig segwit, this is the multisig script with the signature requirements.
Sets the witness script for segwit inputs. Required for spending P2WSH and P2SH-P2WSH outputs in PSBTs.
The witness script buffer
Gets the witness UTXO.
Sets the witness UTXO. Required for segwit inputs in PSBTs.
The witness UTXO
The scriptPubKey of the output
The value of the output in satoshis
Disables Replace-By-Fee (RBF) signaling for this input. Sets the sequence number to 0xffffffff.
Enables Replace-By-Fee (RBF) signaling for this input. Sets the sequence number to 0xfffffffd .
Checks if the input has the required fields for PSBT creation.
Checks if RBF is enabled for this input.
True if RBF is enabled, false otherwise.
Check if the input is valid
True if the amount is positive and exists, and txid and vout are valid
Converts the input template to a UTXO object.
StaticfromCreates a BtcTxInputTemplate from a user-provided UTXO object.
This function prepares the UTXO for internal PSBT construction by:
txid stored in its original big-endian (human-readable) form internally.txid to little-endian at the time of serialization during PSBT construction (inside toPSBT() method of BtcTransactionTemplate), as required by Bitcoin’s internal protocol format.The UTXO provided by the user, where txid is expected to be in big-endian format
(as commonly seen in block explorers and UIs).
A BtcTxInputTemplate instance representing the PSBT input.
Bitcoin internally uses little-endian format for transaction IDs during transaction serialization and signing.
However, for clarity and consistency with human-readable sources (like block explorers),
we retain the txid in big-endian form throughout our internal structures.
The conversion to little-endian is deferred until the final serialization step (toPSBT()).
For more information on byte order in Bitcoin, see:
Represents a Bitcoin transaction input template for PSBT creation. This class contains the minimal required fields and optional fields necessary for creating a valid PSBT input.
See
https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki