Unbonding via CLI

How to Unbond BTC with Babylon via b14g

b14g Babylon BTC Staking Tool

A CLI tool that lets you stake BTC natively on the Bitcoin network and earn co-staking rewards from the Babylon Genesis network via b14g.

Unbonding Workflow

The unbonding process lets you initiate unbonding, which is the first step needed before you can withdraw your staked BTC back to your wallet.

1. Fetch Delegation Data

  • Connects to Babylon staking API using the staking transaction hash

  • Retrieves delegation information including:

    • stakerBtcPkHex: Your Bitcoin public key

    • stakingAmount: Amount of BTC staked (in satoshis)

    • stakingTimelock: Original staking period

    • stakingTxHex: Original staking transaction

    • finalityProviderBtcPksHex: Finality provider public keys

    • covenantUnbondingSignatures: Pre-signed signatures from covenant committee

    • unbondingTxHex: Pre-created unbonding transaction

    • paramsVersion: Version of staking parameters used

2. Create Signed Unbonding Transaction

  • Uses createSignedBtcUnbondingTransaction() from @babylonlabs-io/btc-staking-ts with:

    • Staker information (address and public key)

    • Staking input parameters (finality providers, amount, timelock)

    • Parameters version

    • Original staking transaction

    • Pre-created unbonding transaction (unsigned)

    • Covenant committee signatures

  • This function:

    • Combines covenant signatures with your signature

    • Creates a valid multi-signature transaction

    • Signs with your BTC private key

    • Produces a fully signed unbonding transaction

3. Broadcast to Bitcoin Network

  • Broadcasts the signed unbonding transaction to Bitcoin network

  • Transaction is confirmed on Bitcoin blockchain

  • Starts the unbonding timelock period

  • After unbonding timelock expires, funds become available for withdrawal

Withdrawal Workflow

The withdrawal process lets you retrieve your BTC once the unbonding period has fully completed.

1. Fetch Delegation Data

  • Connects to Babylon staking API using the staking transaction hash

  • Retrieves delegation information including:

    • stakerBtcPkHex: Your Bitcoin public key

    • stakingAmount: Amount of BTC staked (in satoshis)

    • stakingTimelock: Original staking period

    • finalityProviderBtcPksHex: Finality provider public keys

    • unbondingTxHex: The unbonding transaction (must be already broadcast)

    • paramsVersion: Version of staking parameters used

2. Create Signed Withdrawal Transaction

  • Uses createSignedBtcWithdrawEarlyUnbondedTransaction() from @babylonlabs-io/btc-staking-ts with:

    • Staker information (address and public key)

    • Staking input parameters (finality provider public keys, amount, timelock)

    • Parameters version

    • Unbonding transaction

    • Fee rate for the withdrawal transaction

  • This function:

    • Creates a new transaction that spends the unbonding output

    • Calculates the output amount (unbonding amount minus fees)

    • Signs the transaction with your BTC private key

    • Sends funds back to your Bitcoin address

    • Produces a fully signed withdrawal transaction

3. Broadcast to Bitcoin Network

  • Broadcasts the signed withdrawal transaction to Bitcoin network

Last updated