Class Transaction

Represents a Bitcoin transaction.

Constructors

Properties

ins: TxInput[] = []
locktime: number = 0
outs: TxOutput[] = []
version: number = 1
ADVANCED_TRANSACTION_FLAG: 1 = 0x01
ADVANCED_TRANSACTION_MARKER: 0 = 0x00
DEFAULT_SEQUENCE: 4294967295 = 0xffffffff
SIGHASH_ALL: 1 = 0x01
SIGHASH_ANYONECANPAY: 128 = 0x80
SIGHASH_DEFAULT: 0 = 0x00
SIGHASH_INPUT_MASK: 128 = 0x80
SIGHASH_NONE: 2 = 0x02
SIGHASH_OUTPUT_MASK: 3 = 0x03
SIGHASH_SINGLE: 3 = 0x03

Methods

  • Parameters

    • hash: Uint8Array
    • index: number
    • Optionalsequence: number
    • OptionalscriptSig: Uint8Array

    Returns number

  • Parameters

    • scriptPubKey: Uint8Array
    • value: bigint

    Returns number

  • Parameters

    • _ALLOW_WITNESS: boolean = true

    Returns number

  • Parameters

    • OptionalforWitness: boolean

    Returns Uint8Array

  • Hash transaction for signing a specific input.

    Bitcoin uses a different hash for each signed transaction input. This method copies the transaction, makes the necessary changes based on the hashType, and then hashes the result. This hash can then be used to sign the provided transaction input.

    Parameters

    • inIndex: number
    • prevOutScript: Uint8Array
    • hashType: number

    Returns Uint8Array

  • Parameters

    • inIndex: number
    • prevOutScript: Uint8Array
    • value: bigint
    • hashType: number

    Returns Uint8Array

  • Parameters

    • inIndex: number
    • prevOutScripts: Uint8Array[]
    • values: bigint[]
    • hashType: number
    • OptionalleafHash: Uint8Array
    • Optionalannex: Uint8Array

    Returns Uint8Array

  • Parameters

    • index: number
    • scriptSig: Uint8Array

    Returns void

  • Parameters

    • index: number
    • witness: Uint8Array[]

    Returns void

  • Parameters

    • Optionalbuffer: Uint8Array
    • OptionalinitialOffset: number

    Returns Uint8Array

  • Parameters

    • buffer: Uint8Array

    Returns boolean