For the complete documentation index, see llms.txt. This page is also available as Markdown.

Verifying and Reclaiming Your Locked Bitcoin

How to check a bond's Bitcoin lock address before you fund it, what you need to spend it later, and how to reclaim your BTC once the timelock passes.

On a native BTC bond your Bitcoin stays in an output you control, guarded by a timelock. This page covers checking the lock address before you send anything to it, and spending the output back to yourself once the timelock passes. For leaving before the timelock, see Ending or Changing a Bond Position.

Before you fund: check the lock address

The lock address is deterministic. It is built from:

  • your Stacks address,

  • the output's unlock height, at or above the bond's minimum,

  • your staker-unlock-bytes, by default <your Bitcoin public key> OP_CHECKSIG,

  • the bond's early-unlock-bytes, published on-chain when the bond is set up.

Check the address against the contract before funding. The contract's construct-lockup-output-script builds the same output from the same inputs. If it disagrees with the address your wallet or tool shows, do not fund. The code is under Cross-check the script before funding.

What you need to spend it later

Spending the output needs the lock script, the output itself, and your Bitcoin key. Save the lock script when you register, and keep the lock transaction ID: it identifies the output to spend. If you lose the lock script, you can rebuild it from the same inputs:

Input
Where to find it again

Stacks address

Your Stacks wallet

Unlock height

The arguments of your register-for-bond transaction

staker-unlock-bytes

The same transaction. With the default unlock bytes, rebuild them from the public key of the Bitcoin key you registered with

early-unlock-bytes

The bond's on-chain record

The contract keeps none of these in its own state, which is why the registration transaction matters.

Reclaim after the timelock

Once Bitcoin passes the output's unlock height, you spend it through the timelock branch with a Bitcoin transaction signed by your key alone. The output stays spendable by you from then on.

Your STX leg unlocks separately, at the end of the bond term on Stacks. See the bond timeline.

Building a reclaim

For wallet, custodian, and app developers. The examples use @stacks/bitcoin-staking 7.6.0.

Cross-check the script before funding

Rebuild the lock script if you did not keep it

Build, sign and finalize the spend

buildReclaim sets the transaction's nLockTime to the unlock height decoded from the lock script, so the spend can be mined from the block after that height. The signature commits to the outputs and fee, so set them before signing.

Relock straight into the next bond

To renew without other BTC, set output.address to the next bond's lock address instead of your own. The same spend moves your BTC from the old lock into the new one. Once it confirms, register for the next bond with a proof of the new output. See Renewing a native BTC bond.

Was this helpful?