RegisterMetadata
Everything a staker can derive for a paired-BTC register-for-bond before the funding Bitcoin transaction exists. Returned by buildRegisterMetadata.
Usage
import { buildRegisterMetadata, fetchBond, fetchPoxInfo } from '@stacks/bitcoin-staking';
const bondIndex = 2;
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const bond = await fetchBond({ bondIndex, network: 'mainnet' });
if (!bond) throw new Error(`bond ${bondIndex} is not set up`);
const meta = buildRegisterMetadata({
bondIndex,
poxInfo,
bitcoinPublicKey: '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc',
stxAddress: 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7',
earlyUnlockBytes: bond.earlyUnlockBytes,
network: 'mainnet',
});
meta.lockAddress; // fund this address with the sats to lock
meta.unlockHeight; // 994700 for mainnet bond 2
// After the funding transaction confirms:
// buildLockProof({ ...proofInputs, lockScript: meta.lockScript, unlockHeight: meta.unlockHeight })Definition
Properties
Property
Type
Description
lockAddress
string
P2WSH Bitcoin address to fund with the sats to lock
lockScript
Uint8Array
Witness script the address commits to. Pass as lockScript to buildLockProof or buildLockProofFromBlock, and to buildReclaim to spend the lockup
outputScript
Uint8Array
34-byte P2WSH scriptPubKey the funding output must carry, the P2WSH form of lockScript
unlockBytes
Uint8Array
Staker subscript, <pubkey> OP_CHECKSIG. Pass as lockup.unlockBytes to buildRegisterForBond
unlockHeight
number
Bitcoin block height of the OP_CHECKLOCKTIMEVERIFY branch, from computeBondUnlockHeight
Was this helpful?