Class: BIP322
Defined in: BIP322.ts:8
Class that handles BIP-322 related operations. Reference: https://github.com/LegReq/bip0322-signatures/blob/master/BIP0322_signing.ipynb
Constructors
Constructor
new BIP322():
BIP322
Returns
BIP322
Properties
Property | Modifier | Type | Defined in |
---|---|---|---|
TAG | static | Buffer | BIP322.ts:10 |
Methods
buildToSignTx()
static
buildToSignTx(toSpendTxId
,witnessScript
,isRedeemScript
,tapInternalKey?
):Psbt
Defined in: BIP322.ts:69
Build a to_sign transaction using simple signature in accordance to the BIP-322.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
toSpendTxId | string | undefined | Transaction ID of the to_spend transaction as constructed by buildToSpendTx |
witnessScript | Buffer | undefined | The script public key for the signing wallet, or the redeemScript for P2SH-P2WPKH address |
isRedeemScript | boolean | false | Set to true if the provided witnessScript is a redeemScript for P2SH-P2WPKH address, default to false |
tapInternalKey? | Buffer | undefined | Used to set the taproot internal public key of a taproot signing address when provided, default to undefined |
Returns
Psbt
Ready-to-be-signed bitcoinjs.Psbt transaction
buildToSpendTx()
static
buildToSpendTx(message
,scriptPublicKey
):Transaction
Defined in: BIP322.ts:31
Build a to_spend transaction using simple signature in accordance to the BIP-322.
Parameters
Parameter | Type | Description |
---|---|---|
message | string | Message to be signed using BIP-322 |
scriptPublicKey | Buffer | The script public key for the signing wallet |
Returns
Transaction
Bitcoin transaction that correspond to the to_spend transaction
encodeWitness()
static
encodeWitness(signedPsbt
):string
Defined in: BIP322.ts:117
Encode witness stack in a signed BIP-322 PSBT into its base-64 encoded format.
Parameters
Parameter | Type | Description |
---|---|---|
signedPsbt | Psbt | Signed PSBT |
Returns
string
Base-64 encoded witness data
hashMessage()
static
hashMessage(message
):any
Defined in: BIP322.ts:19
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
Parameter | Type | Description |
---|---|---|
message | string | Message to be hashed |
Returns
any
Hashed message