bondPeriodToBurnHeight
Returns a bond's start height: the first Bitcoin block of its first reward cycle. Pure computation that mirrors the pox-5 read-only bond-period-to-burn-height.
Usage
import { bondPeriodToBurnHeight, fetchPoxInfo } from '@stacks/bitcoin-staking';
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const startHeight = bondPeriodToBurnHeight({ bondIndex: 3, poxInfo });
const blocksUntilStart = startHeight - poxInfo.currentBurnchainBlockHeight;Notes
Computes
rewardCycleToBurnHeightofbondPeriodToRewardCycle, both frompoxInfo.register-for-bondfails withERR_BOND_ALREADY_STARTED (u43)from this height on, andsetup-bondwithERR_CANNOT_SETUP_BOND_TOO_LATE (u3).The bond is active above this height and up to
bondPeriodToBurnHeightofbondIndex + 6inclusive. See isBondActiveAtHeight.Throws an
Errorwhose message starts withpox-5 not activated yetifpoxInfo.contractVersionshas no pox-5 entry.
Signature
Returns
number
The Bitcoin block height at which the bond starts.
Parameters
opts.bondIndex (required)
Type:
number
The bond index.
opts.poxInfo (required)
Type:
PoxInfo
A PoxInfo, usually from fetchPoxInfo.
Was this helpful?