Function encodeSigningSerializationBCH

  • Encode the signature-protected properties of a transaction following the algorithm required by the signingSerializationType of a signature.

    Note: When validating transactions with multiple signatures, performance-critical applications should use a memoized sha256 implementation to avoid re-computing hashes.


    • __namedParameters: {
          correspondingOutput: undefined | Uint8Array;
          coveredBytecode: Uint8Array;
          forkId?: Uint8Array;
          locktime: number;
          outpointIndex: number;
          outpointTransactionHash: Uint8Array;
          outputTokenPrefix: Uint8Array;
          outputValue: Uint8Array;
          sequenceNumber: number;
          signingSerializationType: Uint8Array;
          transactionOutpoints: Uint8Array;
          transactionOutputs: Uint8Array;
          transactionSequenceNumbers: Uint8Array;
          transactionUtxos: Uint8Array;
          version: number;
      • correspondingOutput: undefined | Uint8Array

        The serialization of the output at the same index as this input (A.K.A. hashOutputs with SIGHASH_SINGLE) – only used if SINGLE is set.

      • coveredBytecode: Uint8Array

        The encoded script currently being executed, beginning at the lastCodeSeparator.

      • Optional forkId?: Uint8Array

        While a bitcoin-encoded signature only includes a single byte to encode the signing serialization type, a 3-byte forkId can be appended to provide replay-protection between different forks. (See Bitcoin Cash's Replay Protected Sighash spec for details.)

      • locktime: number

        The locktime of the transaction.

      • outpointIndex: number

        The index of the outpoint being spent in outpointTransactionHash.

      • outpointTransactionHash: Uint8Array

        The big-endian (standard) transaction hash of the outpoint being spent.

      • outputTokenPrefix: Uint8Array

        The encoded token prefix of the output being spent (see encodeTokenPrefix).

        If the output includes no tokens, a zero-length Uint8Array.

      • outputValue: Uint8Array

        The 8-byte Uint64LE-encoded value of the outpoint in satoshis (see bigIntToBinUint64LE).

      • sequenceNumber: number

        The sequence number of the input (A.K.A. nSequence).

      • signingSerializationType: Uint8Array

        The signing serialization type of the signature (A.K.A. sighash type).

      • transactionOutpoints: Uint8Array

        The serialization of all input outpoints (A.K.A. hashPrevouts) – used if ANYONECANPAY is not set.

      • transactionOutputs: Uint8Array

        The serialization of output amounts and locking bytecode values (A.K.A. hashOutputs with SIGHASH_ALL) – only used if ALL is set.

      • transactionSequenceNumbers: Uint8Array

        The serialization of all input sequence numbers. (A.K.A. hashSequence) – used if none of ANYONECANPAY, SINGLE, or NONE are set.

      • transactionUtxos: Uint8Array

        The signing serialization of all UTXOs spent by the transaction's inputs (concatenated in input order).

      • version: number

        The version number of the transaction.

    • sha256: {
          hash: ((input: Uint8Array) => Uint8Array);
      } = internalSha256
      • hash: ((input: Uint8Array) => Uint8Array)
          • (input: Uint8Array): Uint8Array
          • Returns the sha256 hash of the provided input.

            To incrementally construct a sha256 hash (e.g. for streaming), use init, update, and final.


            • input: Uint8Array

              a Uint8Array to be hashed using sha256

            Returns Uint8Array

    Returns Uint8Array

Generated using TypeDoc