BIP322
class
BIP322
Class that handles BIP-322 related operations.
Reference: https://github.com/LegReq/bip0322-signatures/blob/master/BIP0322_signing.ipynb
Properties
TAG
Buffer
Methods
buildToSignTx
buildToSignTx(toSpendTxId: string, witnessScript: Buffer, isRedeemScript: boolean, tapInternalKey?: Buffer): Psbt
Build a to_sign transaction using simple signature in accordance to the BIP-322.
Parameters:
toSpendTxId: string
Transaction ID of the to_spend transaction as constructed by buildToSpendTx
witnessScript: Buffer
The script public key for the signing wallet, or the redeemScript for P2SH-P2WPKH address
isRedeemScript: boolean
Set to true if the provided witnessScript is a redeemScript for P2SH-P2WPKH address, default to false
tapInternalKey (optional): Buffer
Used to set the taproot internal public key of a taproot signing address when provided, default to undefined
Returns:
PsbtReady-to-be-signed bitcoinjs.Psbt transaction
buildToSpendTx
buildToSpendTx(message: string, scriptPublicKey: Buffer): Transaction
Build a to_spend transaction using simple signature in accordance to the BIP-322.
Parameters:
message: string
Message to be signed using BIP-322
scriptPublicKey: Buffer
The script public key for the signing wallet
Returns:
TransactionBitcoin transaction that correspond to the to_spend transaction
encodeWitness
encodeWitness(signedPsbt: Psbt): string
Encode witness stack in a signed BIP-322 PSBT into its base-64 encoded format.
Parameters:
signedPsbt: Psbt
Signed PSBT
Returns:
stringBase-64 encoded witness data
hashMessage
hashMessage(message: string): any
Compute the message hash as specified in the BIP-322.
The standard is specified in BIP-340 as:
The function hashtag(x) where tag is a UTF-8 encoded tag name and x is a byte array returns the 32-byte hash SHA256(SHA256(tag) || SHA256(tag) || x).
Parameters:
message: string
Message to be hashed
Returns:
anyHashed message
