btcutil-js - v0.2.0
    Preparing search index...

    Variable bip322Const

    bip322: {
        buildToSignPacketFull(
            message: string,
            pkScript: Bytes,
            txVersion: number,
            lockTime: number,
            sequence: number,
        ): Promise<string>;
        buildToSignPacketSimple(message: string, pkScript: Bytes): Promise<string>;
        parseTxWitness(rawWitness: Bytes): Promise<Uint8Array<ArrayBufferLike>[]>;
        serializeTxWitness(witness: Bytes[]): Promise<Uint8Array<ArrayBufferLike>>;
        verifyMessage(
            message: string,
            address: string,
            signature: string,
            network?: Network,
        ): Promise<VerifyResult>;
    } = ...

    BIP-322 generic signed message verification and signing helpers.

    Type Declaration

    • buildToSignPacketFull: function
      • Build the BIP-322 "to_sign" PSBT for the full format. Calls Go: bip322.BuildToSignPacketFull() from btcutil/bip322.

        Parameters

        • message: string

          The message to sign.

        • pkScript: Bytes

          The pkScript of the signing address.

        • txVersion: number

          Transaction version (typically 2).

        • lockTime: number

          Lock time (typically 0).

        • sequence: number

          Input sequence (typically 0).

        Returns Promise<string>

        Base64-encoded PSBT ready for signing.

    • buildToSignPacketSimple: function
      • Build the BIP-322 "to_sign" PSBT for the simple format. Calls Go: bip322.BuildToSignPacketSimple() from btcutil/bip322.

        Parameters

        • message: string

          The message to sign.

        • pkScript: Bytes

          The pkScript of the signing address.

        Returns Promise<string>

        Base64-encoded PSBT ready for signing.

    • parseTxWitness: function
      • Parse serialized witness bytes back into a witness stack. Calls Go: bip322.ParseTxWitness() from btcutil/bip322.

        Parameters

        • rawWitness: Bytes

          Serialized witness data (hex string or Uint8Array).

        Returns Promise<Uint8Array<ArrayBufferLike>[]>

        Array of witness stack items (Uint8Array[]).

    • serializeTxWitness: function
      • Serialize a witness stack into the BIP-322 wire format. Calls Go: bip322.SerializeTxWitness() from btcutil/bip322.

        Parameters

        • witness: Bytes[]

          Array of witness items (hex strings or Uint8Arrays).

        Returns Promise<Uint8Array<ArrayBufferLike>>

        Serialized witness bytes (Uint8Array).

    • verifyMessage: function
      • Verify a BIP-322 signed message. Calls Go: bip322.VerifyMessage() from btcutil/bip322 (after btcutil.DecodeAddress() to parse the address).

        Parameters

        • message: string

          The message that was signed.

        • address: string

          The Bitcoin address to verify against.

        • signature: string

          The base64-encoded BIP-322 signature.

        • network: Network = 'mainnet'

          Bitcoin network (default: "mainnet").

        Returns Promise<VerifyResult>

        An object with valid (boolean) and optionally error (string).