Client-side Bitcoin JavaScript library for node.js and browsers with comprehensive Bitcoin protocol support
Overall
score
99%
Build a utility that computes tagged hash commitments for Taproot script trees used in Bitcoin Taproot transactions.
Your task is to create functions that compute the cryptographic hash commitments used in Taproot script paths. These tagged hashes are a core part of how Bitcoin's Taproot upgrade works, allowing multiple spending conditions to be committed to in a Merkle tree structure.
Create a function that:
The leaf version should default to 0xc0 (standard Tapscript leaf version).
Create a function that:
Create a function that:
For an odd number of leaves, the unpaired leaf should be promoted to the next level.
@generates
/**
* Computes the TapLeaf tagged hash for a script
*
* @param script - The script Buffer to hash
* @param leafVersion - The leaf version byte (defaults to 0xc0)
* @returns The TapLeaf hash as a 32-byte Buffer
*/
export function computeLeafHash(script: Buffer, leafVersion?: number): Buffer;
/**
* Computes the TapBranch tagged hash for two child hashes
*
* @param hash1 - First child hash
* @param hash2 - Second child hash
* @returns The TapBranch hash as a 32-byte Buffer
*/
export function computeBranchHash(hash1: Buffer, hash2: Buffer): Buffer;
/**
* Computes the Merkle root for an array of scripts
*
* @param scripts - Array of script Buffers
* @param leafVersion - The leaf version byte (defaults to 0xc0)
* @returns The Merkle root hash as a 32-byte Buffer
*/
export function computeMerkleRoot(scripts: Buffer[], leafVersion?: number): Buffer;Provides Bitcoin transaction primitives and Taproot tagged hashing functions.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-bitcoinjs-libdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10