Caravan Documentation
    Preparing search index...

    Interface UTXO

    Represents an Unspent Transaction Output (UTXO) with essential information for PSBT creation.

    TXID Format Convention for @caravan/transactions Package:

    Throughout this entire package, all input TXIDs are expected to be in big-endian format (human-readable format). This includes:

    • UTXO.txid fields
    • originalTx parameters in RBF/CPFP functions
    • Any transaction references in analysis

    This maintains consistency with external expectations (block explorers, wallets, APIs) while the package internally handles the conversion to Bitcoin's native little-endian format when constructing raw transactions and PSBTs.

    Output Format: When this package returns fee-bumped PSBTs, the internal TXID references within those PSBTs will be in little-endian format to ensure compatibility with Bitcoin's internal data structures and protocol requirements.

    interface UTXO {
        bip32Derivations?: InputDerivation[];
        nonWitnessUtxo?: Buffer;
        prevTxHex?: string;
        redeemScript?: Buffer;
        sequence?: number;
        txid: string;
        value: string;
        vout: number;
        witnessScript?: Buffer;
        witnessUtxo?: { script: Buffer; value: number };
    }
    Index

    Properties

    bip32Derivations?: InputDerivation[]

    BIP32 derivation information for all public keys involved in this UTXO. This array contains derivation paths for each cosigner's public key in a multisig setup.

    Critical for:

    • Hardware wallets to derive the correct signing key
    • Coordinators to validate signatures from other cosigners
    • PSBT signers to identify which keys they control

    Each entry maps a public key to its derivation path and master fingerprint.

    nonWitnessUtxo?: Buffer

    The non-witness UTXO information for non-segwit transactions. (The buffer of the full previous transaction) Required for non-segwit inputs in PSBTs.

    prevTxHex?: string

    The full previous transaction in hexadecimal format. Required for non-segwit inputs in PSBTs to prevent fee attacks. For P2SH and some hardware wallets, this is mandatory.

    redeemScript?: Buffer

    The redeem script for P2SH outputs. For multisig P2SH addresses, this contains the actual multisig script that defines the m-of-n signature requirements. Required for spending P2SH outputs.

    Example: For a 2-of-3 P2SH multisig, this would be the script: OP_2 OP_3 OP_CHECKMULTISIG

    sequence?: number

    The sequence number of the input. This is used for relative time locks and signaling RBF.

    txid: string

    The transaction ID of the UTXO in reversed hex format (big-endian).

    Package-wide TXID Convention: All TXIDs provided to this package should be in big-endian format (human-readable format), which is the standard format used by:

    • Block explorers (e.g., blockstream.info, blockchain.info)
    • Wallet APIs and RPC interfaces
    • Bitcoin Core's getrawmempool, getrawtransaction outputs
    • User-facing interfaces

    The package will internally convert these to little-endian format when needed for Bitcoin protocol operations and PSBT construction.

    Big-endian (user-facing): `6fe28c0ab6f1b372...`
    Little-endian (internal use): `...72b3f1b60a8ce26f`
    value: string

    The value of the UTXO in satoshis.

    vout: number

    The output index of the UTXO in its parent transaction.

    witnessScript?: Buffer

    The witness script for P2WSH and P2SH-P2WSH outputs. For segwit multisig addresses, this contains the multisig script that gets committed to in the witness program. Required for spending segwit script outputs.

    Note: For P2SH-P2WSH, both redeemScript and witnessScript are needed:

    • redeemScript: Contains the witness program (version + witness script hash)
    • witnessScript: Contains the actual multisig script
    witnessUtxo?: { script: Buffer; value: number }

    The witness UTXO information for segwit transactions. Required for segwit inputs in PSBTs.