rewardCycleToBurnHeight
Returns the first Bitcoin block height of a reward cycle. Pure computation that mirrors the pox-5 read-only reward-cycle-to-burn-height.
Usage
import { fetchPoxInfo, rewardCycleToBurnHeight } from '@stacks/bitcoin-staking';
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const nextCycleStart = rewardCycleToBurnHeight({ rewardCycle: poxInfo.rewardCycleId + 1, poxInfo });
const preparePhaseStart = nextCycleStart - poxInfo.prepareCycleLength;Notes
Computes
firstBurnchainBlockHeight + rewardCycle * rewardCycleLength. The input is not validated.The prepare phase of a cycle starts
prepareCycleLengthblocks before the next cycle's first block. See isInPreparePhase.
Signature
function rewardCycleToBurnHeight(opts: { rewardCycle: number; poxInfo: PoxInfo }): number;Returns
number
The Bitcoin block height at which the cycle starts.
Parameters
opts.rewardCycle (required)
Type:
number
The reward cycle ID.
opts.poxInfo (required)
Type:
PoxInfo
A PoxInfo, usually from fetchPoxInfo.
Was this helpful?