### Install btc-staking-ts npm Package Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md This command installs the btc-staking-ts library using npm, the Node Package Manager. Ensure you have Node.js and npm installed on your system. ```bash npm i btc-staking-ts ``` -------------------------------- ### Build Staking Scripts (TypeScript) Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Constructs all necessary Bitcoin scripts for the staking contract, including timelock, unbonding, slashing, and data embed scripts. It requires Babylon system parameters like covenant public keys and thresholds, along with user-selected parameters such as the staker's public key, finality providers, and staking durations. The output includes various script types needed for the staking protocol. ```typescript import { StakingScriptData, networks } from "btc-staking-ts"; // Babylon system parameters (retrieve from Babylon governance) const covenantPks = [ Buffer.from("f1ab4e...", "hex"), Buffer.from("a3bc5d...", "hex"), Buffer.from("7e9f82...", "hex") ]; const covenantThreshold = 2; const minUnbondingTime = 101; const magicBytes = Buffer.from("62627434", "hex"); // "bbt4" tag // User-selected parameters const stakerPk = Buffer.from("d4e7f1...", "hex"); // 32-byte public key without coordinate const finalityProviders = [Buffer.from("c8a2b5...", "hex")]; // Single finality provider const stakingDuration = 144; // blocks const unbondingTime = 101; // must be >= minUnbondingTime // Create staking script data and build all scripts const stakingScriptData = new StakingScriptData( stakerPk, finalityProviders, covenantPks, covenantThreshold, stakingDuration, unbondingTime, magicBytes ); const { timelockScript, unbondingScript, slashingScript, dataEmbedScript, unbondingTimelockScript } = stakingScriptData.buildScripts(); ``` -------------------------------- ### Initialize Elliptic Curve Library Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Initializes the secp256k1 elliptic curve library, which is a prerequisite for all cryptographic operations within the Bitcoin Staking SDK. This function must be called once before utilizing any other SDK functionalities. ```typescript import { initBTCCurve } from "btc-staking-ts"; // Must be called once before using any SDK functions initBTCCurve(); ``` -------------------------------- ### Create Bitcoin Staking Scripts using StakingScriptData Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Initializes StakingScriptData to build various Bitcoin scripts required for staking, including timelock, unbonding, slashing, and data embed scripts. Dependencies include the 'btc-staking-ts' library. Inputs are staker public key, finality providers, covenant public keys and threshold, staking duration, min unbonding time, and magic bytes. Outputs are the constructed script objects. ```typescript import { StakingScriptData } from "btc-staking-ts"; const stakingScriptData = new StakingScriptData( stakerPk, finalityProviders, covenantPks, covenantThreshold, stakingDuration, minUnbondingTime, magicBytes, ); const { timelockScript, unbondingScript, slashingScript, dataEmbedScript, unbondingTimelockScript, } = stakingScriptData.buildScripts(); ``` -------------------------------- ### Create Unbonding Transaction with btc-staking-ts Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Constructs an unsigned unbonding transaction allowing early withdrawal before a staking timelock expires. Requires the original staking transaction, unbonding scripts, fee, and network configuration. Outputs an unsigned PSBT for further signing. ```typescript import { unbondingTransaction, networks } from "btc-staking-ts"; import { Transaction, Psbt } from "bitcoinjs-lib"; // Assuming you have the signed staking transaction const stakingTx = Transaction.fromHex("0200000..."); const unbondingFee = 500; // satoshis const network = networks.testnet; // Build unsigned unbonding transaction const { psbt: unbondingPsbt } = unbondingTransaction( { unbondingScript, unbondingTimelockScript, timelockScript, slashingScript }, stakingTx, unbondingFee, network, 0 // output index (staking output is always at index 0) ); // Sign with wallet const signedUnbondingPsbtHex = await wallet.signPsbt(unbondingPsbt.toHex()); const unbondingTx = Psbt.fromHex(signedUnbondingPsbtHex).extractTransaction(); // Note: This transaction requires additional covenant signatures before broadcast // Send to Babylon backend to collect covenant committee signatures ``` -------------------------------- ### Generate Canary Version with npm Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md This command is used to generate a canary (pre-release) version of the package. It assumes all changes have been committed. This is typically used during development or for testing new features before a stable release. ```bash npm run version:canary ``` -------------------------------- ### Create Staking Transaction (TypeScript) Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Generates an unsigned Bitcoin staking transaction, locking funds into a taproot output governed by the staking scripts. This function requires input UTXOs, the desired staking amount, a change address, network configuration, fee rate, and optionally a public key and lock height. The output is a PSBT that can be signed by a wallet, along with the calculated transaction fee. ```typescript import { stakingTransaction, networks } from "btc-staking-ts"; import { Psbt } from "bitcoinjs-lib"; // Input UTXOs to fund the staking transaction const inputUTXOs = [ { txid: "e472d65b0c9c1bac9ffe53708007e57ab830f1bf09af4bfbd17e780b641258fc", vout: 2, value: 9265692, scriptPubKey: "0014505049839bc32f869590adc5650c584e17c917fc" } ]; const stakingAmount = 1000000; // satoshis const feeRate = 18; // sat/vB const changeAddress = "tb1q2p5y..."; // Taproot or Native Segwit address const network = networks.testnet; // Optional: public key for taproot wallets const publicKeyNoCoord = Buffer.from("d4e7f1...", "hex"); // Optional: lockHeight for transaction activation const lockHeight = 850000; // Build unsigned staking transaction const { psbt, fee } = stakingTransaction( { timelockScript, unbondingScript, slashingScript, dataEmbedScript }, stakingAmount, changeAddress, inputUTXOs, network, feeRate, publicKeyNoCoord, lockHeight ); // Sign with wallet (implementation depends on wallet) const signedPsbtHex = await wallet.signPsbt(psbt.toHex()); const stakingTx = Psbt.fromHex(signedPsbtHex).extractTransaction(); const stakingTxId = stakingTx.getId(); ``` -------------------------------- ### Define Bitcoin Staking Parameters in TypeScript Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md This snippet demonstrates how to collect Babylon system parameters, define user-selected staking contract parameters, and specify parameters for the staking transaction. It includes dependencies like `bitcoinjs-lib` and assumes the availability of `covenant_pks`, `finalityProvider`, and `btcWallet` objects. ```typescript import { networks } from "bitcoinjs-lib"; // 1. Collect the Babylon system parameters. // These are parameters that are shared between for all Bitcoin staking // transactions, and are maintained by Babylon governance. // They involve: // - `covenantPks: Buffer[]`: A list of the public keys // without the coordinate bytes correspondongin to the // covenant emulators. // - `covenantThreshold: number`: The amount of covenant // emulator signatures required for the staking to be activated. // - `minimumUnbondingTime: number`: The minimum unbonding period // allowed by the Babylon system . // - `magicBytes: Buffer`: The magic bytes that are appended to the data // embed script that is used to identify the staking transaction on BTC. // - `lockHeight: number`: Indicates the BTC height before which // the transaction is considered invalid. This value can be derived from // the `activationHeight` of the Babylon versioned global parameters // where the current BTC height is. Note that if the // `current BTC height + 1 + confirmationDepth` is going to be >= // the next versioned `activationHeight`, then you should use the // `activationHeight` from the next version of the global parameters. // Below, these values are hardcoded, but they should be retrieved from the // Babylon system. const covenantPks: Buffer[] = covenant_pks.map((pk) => Buffer.from(pk, "hex")); const covenantThreshold: number = 3; const minUnbondingTime: number = 101; const magicBytes: Buffer = Buffer.from("62627434", "hex"); // "bbt4" tag // Optional field. Value coming from current global param activationHeight const lockHeight: number = 0; // 2. Define the user selected parameters of the staking contract: // - `stakerPk: Buffer`: The public key without the coordinate of the // staker. // - `finalityProviders: Buffer[]`: A list of public keys without the // coordinate corresponding to the finality providers. Currently, // a delegation to only a single finality provider is allowed, // so the list should contain only a single item. // - `stakingDuration: number`: The staking period in BTC blocks. // - `stakingAmount: number`: The amount to be staked in satoshis. // - `unbondingTime: number`: The unbonding time. Should be `>=` the // `minUnbondingTime`. const stakerPk: Buffer = btcWallet.publicKeyNoCoord(); const finalityProviders: Buffer[] = [ Buffer.from(finalityProvider.btc_pk_hex, "hex"), ]; const stakingDuration: number = 144; const stakingAmount: number = 1000; const unbondingTime: number = minUnbondingTime; // 3. Define the parameters for the staking transaction that will contain the // staking contract: // - `inputUTXOs: UTXO[]`: The list of UTXOs that will be used as an input // to fund the staking transaction. // - `feeRate: number`: The fee per tx byte in satoshis. // - `changeAddress: string`: BTC wallet change address, Taproot or Native // Segwit. // - `network: network to work with, either networks.testnet // for BTC Testnet and BTC Signet, or networks.bitcoin for BTC Mainnet. // Each object in the inputUTXOs array represents a single UTXO with the following properties: // - txid: transaction ID, string // - vout: output index, number // - value: value of the UTXO, in satoshis, number // - scriptPubKey: script which provides the conditions that must be fulfilled for this UTXO to be spent, string const inputUTXOs = [ { txid: "e472d65b0c9c1bac9ffe53708007e57ab830f1bf09af4bfbd17e780b641258fc", vout: 2, value: 9265692, scriptPubKey: "0014505049839bc32f869590adc5650c584e17c917fc", }, ]; const feeRate: number = 18; const changeAddress: string = btcWallet.address; const network = networks.testnet; ``` -------------------------------- ### Declare Withdrawal Transaction Parameters Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Defines key parameters for constructing a withdrawal transaction, such as the output index, fee, and destination address. These parameters are essential for initiating the withdrawal process. ```typescript const stakingOutputIndex: number = 0; const withdrawalFee: number = 500; const withdrawalAddress: string = btcWallet.address; ``` -------------------------------- ### Withdraw Early Unbonded Transaction with btc-staking-ts Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Generates a withdrawal transaction to claim funds after an early unbonding period has concluded. It takes the completed unbonding transaction, withdrawal address, network, and fee rate as input. The function returns an unsigned PSBT and the estimated withdrawal fee, ready for signing and broadcast. ```typescript import { withdrawEarlyUnbondedTransaction, networks } from "btc-staking-ts"; import { Transaction, Psbt } from "bitcoinjs-lib"; // Unbonding transaction that has completed its unbonding period const unbondingTx = Transaction.fromHex("0200000..."); const withdrawalAddress = "tb1q2p5y..."; const feeRate = 15; // sat/vB const network = networks.testnet; // Build withdrawal transaction from unbonding output const { psbt: withdrawalPsbt, fee: withdrawalFee } = withdrawEarlyUnbondedTransaction( { unbondingTimelockScript, slashingScript }, unbondingTx, withdrawalAddress, network, feeRate ); // Sign and broadcast const signedWithdrawalPsbtHex = await wallet.signPsbt(withdrawalPsbt.toHex()); const withdrawalTx = Psbt.fromHex(signedWithdrawalPsbtHex).extractTransaction(); ``` -------------------------------- ### Create Bitcoin Staking Transaction using stakingTransaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Constructs an unsigned Bitcoin staking transaction using the previously built staking scripts. It requires script objects, staking amount, change address, input UTXOs, network configuration, fee rate, optional Taproot public key, and lock height. Outputs a PSBT object and the estimated fee. The transaction can then be signed using a wallet. ```typescript import { stakingTransaction } from "btc-staking-ts"; import { Psbt, Transaction } from "bitcoinjs-lib"; // stakingTransaction constructs an unsigned BTC Staking transaction const unsignedStakingPsbt: {psbt: Psbt, fee: number} = stakingTransaction( scripts: { timelockScript, unbondingScript, slashingScript, dataEmbedScript }, stakingAmount, changeAddress, inputUTXOs, network(), feeRate, btcWallet.isTaproot ? btcWallet.publicKeyNoCoord() : undefined, lockHeight, ); const signedStakingPsbt = await btcWallet.signPsbt(unsignedStakingPsbt.psbt.toHex()); const stakingTx = Psbt.fromHex(signedStakingPsbt).extractTransaction(); ``` -------------------------------- ### Collect Slashing Transaction Parameters Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Gathers essential parameters for creating a slashing transaction, including the destination address for slashed funds, the slashing rate (as a decimal between 0 and 1), and the minimum required fee in satoshis. These values are typically obtained from the Babylon system. ```typescript const slashingAddress: string = ""; const slashingRate: number = 0; const minimumSlashingFee: number = 500; ``` -------------------------------- ### Create Bitcoin Unbonding Transaction using unbondingTransaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Generates an unsigned Bitcoin unbonding transaction, allowing for on-demand stake withdrawal before the timelock expires, subject to an unbonding period. It requires specific scripts (unbonding, unbonding timelock, timelock, slashing), the original staking transaction, an unbonding fee, and network configuration. Outputs a partially signed PSBT object. This PSBT then needs further signatures from the covenant committee. ```typescript import { unbondingTransaction } from "btc-staking-ts"; import { Psbt, Transaction } from "bitcoinjs-lib"; // Unbonding fee in satoshis. number const unbondingFee: number = 500; const unsignedUnbondingPsbt: {psbt: Psbt} = unbondingTransaction( scripts: { unbondingScript, unbondingTimelockScript, timelockScript, slashingScript, }, stakingTx, unbondingFee, network, ); const signedUnbondingPsbt = await signPsbt(unsignedUnbondingPsbt.psbt.toHex()); const unbondingTx = Psbt.fromHex(signedUnbondingPsbt).extractTransaction(); ``` -------------------------------- ### Withdraw Early Unbonded Transaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Constructs an unsigned withdrawal PSBT for funds from an early unbonding transaction after the unbonding period has passed. Requires unbonding transaction details, scripts, recipient address, network configuration, and fee rate. The resulting PSBT can then be signed and extracted into a transaction. ```typescript import { Psbt, Transaction } from "bitcoinjs-lib"; import { withdrawEarlyUnbondedTransaction } from "btc-staking-ts"; const unsignedWithdrawalPsbt: { psbt: Psbt, fee: number } = withdrawEarlyUnbondedTransaction( scripts: { unbondingTimelockScript, slashingScript, }, unbondingTx, withdrawalAddress, network, feeRate, ); const signedWithdrawalPsbt = await signPsbt(unsignedWithdrawalPsbt.psbt.toHex()); const withdrawalTransaction = Psbt.fromHex(signedWithdrawalPsbt).extractTransaction(); ``` -------------------------------- ### Withdraw Timelock Unbonded Transaction with btc-staking-ts Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Creates a withdrawal transaction to claim funds after a staking timelock has naturally expired. It requires the original staking transaction, the withdrawal address, network parameters, and a fee rate. Outputs an unsigned PSBT and the calculated withdrawal fee. ```typescript import { withdrawTimelockUnbondedTransaction, networks } from "btc-staking-ts"; import { Transaction, Psbt } from "bitcoinjs-lib"; // Staking transaction with expired timelock const stakingTx = Transaction.fromHex("0200000..."); const withdrawalAddress = "tb1q2p5y..."; // Address to receive withdrawn funds const feeRate = 15; // sat/vB const network = networks.testnet; const stakingOutputIndex = 0; // Staking output position // Build withdrawal transaction const { psbt: withdrawalPsbt, fee: withdrawalFee } = withdrawTimelockUnbondedTransaction( { timelockScript, slashingScript, unbondingScript }, stakingTx, withdrawalAddress, network, feeRate, stakingOutputIndex ); // Sign and extract transaction const signedWithdrawalPsbtHex = await wallet.signPsbt(withdrawalPsbt.toHex()); const withdrawalTx = Psbt.fromHex(signedWithdrawalPsbtHex).extractTransaction(); console.log(`Withdrawal fee: ${withdrawalFee} satoshis`); console.log(`Transaction: ${withdrawalTx.toHex()}`); ``` -------------------------------- ### Construct Slashing Transaction for Unbonding Output (TypeScript) Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Constructs a slashing transaction for an unbonding output if the finality provider commits an offense during the unbonding period. This is used to slash funds that are already in the unbonding phase. It requires the unbonding transaction details and slashing parameters. ```typescript import { slashEarlyUnbondedTransaction, networks } from "btc-staking-ts"; import { Transaction, Psbt } from "bitcoinjs-lib"; // Unbonding transaction to be slashed const unbondingTx = Transaction.fromHex("0200000..."); const slashingAddress = "tb1qslash..."; const slashingRate = 0.15; // 15% slashing rate const minimumSlashingFee = 500; const network = networks.testnet; // Build unbonding slashing transaction const { psbt: unbondingSlashingPsbt } = slashEarlyUnbondedTransaction( { slashingScript, unbondingTimelockScript }, unbondingTx, slashingAddress, slashingRate, minimumSlashingFee, network ); // Sign and extract (only during slashing event) const signedUnbondingSlashingPsbtHex = await wallet.signPsbt(unbondingSlashingPsbt.toHex()); const unbondingSlashingTx = Psbt.fromHex(signedUnbondingSlashingPsbtHex).extractTransaction(); ``` -------------------------------- ### Slash Early Unbonded Transaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Generates an unsigned slashing PSBT for an unbonding transaction that was initiated for early unbonding. This function requires the relevant scripts, the unbonding transaction, the slashing address, slashing rate, minimum fee, and network configuration. The PSBT can then be signed and extracted. ```typescript import { Psbt, Transaction } from "bitcoinjs-lib"; import { slashEarlyUnbondedTransaction } from "btc-staking-ts"; const unsignedUnbondingSlashingPsbt: {psbt: Psbt} = slashEarlyUnbondedTransaction( scripts: { slashingScript, unbondingTimelockScript, }, unbondingTx, slashingAddress, slashingRate, minimumSlashingFee, network, ); const signedUnbondingSlashingPsbt = await signPsbt(unsignedUnbondingSlashingPsbt.psbt.toHex()); const unbondingSlashingTx = Psbt.fromHex(signedUnbondingSlashingPsbt).extractTransaction(); ``` -------------------------------- ### Withdraw Timelock Unbonded Transaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Constructs an unsigned withdrawal PSBT for funds from a staking transaction where the timelock has naturally expired. Requires staking transaction details, scripts, recipient address, network configuration, fee rate, and output index. ```typescript import { Psbt, Transaction } from "bitcoinjs-lib"; import { withdrawTimelockUnbondedTransaction } from "btc-staking-ts"; const stakingTx: Transaction = undefined; const unsignedWithdrawalPsbt: {psbt: Psbt, fee: number} = withdrawTimelockUnbondedTransaction( scripts: { timelockScript, slashingScript, unbondingScript, }, stakingTx, btcWallet.address, network, feeRate, stakingOutputIndex, ); ``` -------------------------------- ### Construct Slashing Transaction for Staking Output (TypeScript) Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Builds a slashing transaction to penalize stakers if their finality provider commits an offense. This function is used for slashing outputs from the initial staking transaction. It requires the original staking transaction details, slashing parameters, and network configuration. ```typescript import { slashTimelockUnbondedTransaction, networks } from "btc-staking-ts"; import { Transaction, Psbt } from "bitcoinjs-lib"; // System parameters (from Babylon) const slashingAddress = "tb1qslash..."; // Address to receive slashed funds const slashingRate = 0.1; // 10% slashing rate (0 < rate < 1) const minimumSlashingFee = 500; // satoshis const network = networks.testnet; // Staking transaction to be slashed const stakingTx = Transaction.fromHex("0200000..."); const outputIndex = 0; // Build slashing transaction const { psbt: slashingPsbt } = slashTimelockUnbondedTransaction( { slashingScript, timelockScript, unbondingScript, unbondingTimelockScript }, stakingTx, slashingAddress, slashingRate, minimumSlashingFee, network, outputIndex ); // Sign with staker key (only sign during actual slashing event) const signedSlashingPsbtHex = await wallet.signPsbt(slashingPsbt.toHex()); const slashingTx = Psbt.fromHex(signedSlashingPsbtHex).extractTransaction(); // Output 0: slashed amount to slashing address // Output 1: remaining funds minus fee back to user with unbonding timelock ``` -------------------------------- ### Slash Timelock Unbonded Transaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Creates an unsigned slashing PSBT for a staking transaction where no unbonding has occurred. This function requires detailed script information, the staking transaction itself, the slashing address, slashing rate, minimum fee, network configuration, and the specific output index to be slashed. ```typescript import { slashTimelockUnbondedTransaction } from "btc-staking-ts"; import { Psbt, Transaction } from "bitcoinjs-lib"; const outputIndex: number = 0; const unsignedSlashingPsbt: {psbt: Psbt} = slashTimelockUnbondedTransaction( scripts: { slashingScript, unbondingScript, timelockScript, unbondingTimelockScript, }, stakingTx, slashingAddress, slashingRate, minimumSlashingFee, network, outputIndex, ); const signedSlashingPsbt = await signPsbt(unsignedSlashingPsbt.psbt.toHex()); const slashingTx = Psbt.fromHex(signedSlashingPsbt).extractTransaction(); ``` -------------------------------- ### Add Covenant Signatures to Unbonding Transaction with btc-staking-ts Source: https://context7.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/llms.txt Combines a staker's signature with covenant committee signatures to finalize an unbonding transaction witness. This function takes the original witness, covenant public keys, and retrieved covenant signatures to create a complete witness. The updated transaction is then ready for broadcast. ```typescript import { createWitness } from "btc-staking-ts"; import { Transaction } from "bitcoinjs-lib"; // Partially signed unbonding transaction const unbondingTx = Transaction.fromHex("0200000..."); // Original witness from staker's signature const originalWitness = unbondingTx.ins[0].witness; // Covenant public keys (from system parameters) const covenantPks = [ Buffer.from("f1ab4e...", "hex"), Buffer.from("a3bc5d...", "hex"), Buffer.from("7e9f82...", "hex") ]; // Covenant signatures (retrieved from Babylon backend) const covenantUnbondingSignatures = [ { btc_pk_hex: "f1ab4e...", sig_hex: "30440220..." }, { btc_pk_hex: "a3bc5d...", sig_hex: "30450221..." } ]; // Create complete witness with covenant signatures const completeWitness = createWitness( originalWitness, covenantPks, covenantUnbondingSignatures ); // Update transaction with complete witness unbondingTx.setWitness(0, completeWitness); // Now ready to broadcast const completeTxHex = unbondingTx.toHex(); ``` -------------------------------- ### Construct Witness for Unbonding Transaction Source: https://github.com/stakingrewards/staking-sdk-babylon-btc-staking-ts/blob/dev/README.md Assembles the complete witness for an unbonding transaction by combining the original witness with signatures from the covenant committee. This function is used when the application has direct access to the covenant signatures, typically for testing purposes. It takes the original transaction witness, covenant public keys, and the corresponding unbonding signatures as input, producing the final witness array. ```typescript // Create the full witness const witness = createWitness( unbondingTx.ins[0].witness: Buffer[], // original witness covenantPks: Buffer[], covenantUnbondingSignatures: { btc_pk_hex: string; sig_hex: string; }[], ); // Put the witness inside the unbonding transaction. unbondingTx.setWitness(0, witness); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.