Class CsvMaturity
Evaluates BIP-68 relative timelocks (the CSV delay on an Arkade contract's unilateral-exit path) against live chain state.
An NBitcoin.Sequence is not a block count. NBitcoin encodes a
time-based relative lock by setting SEQUENCE_LOCKTIME_TYPE_FLAG
(bit 22) and storing the delay in 512-second units, so
NBitcoin.Sequence.Value for a 24-hour delay is 4,194,472 — adding that
raw number to a block height pushes maturity roughly 80 years out. Always
branch on NBitcoin.Sequence.LockType, which this helper does:
- NBitcoin.SequenceLockType.Height — compare the tip height against the input's confirmation height plus NBitcoin.Sequence.LockHeight blocks.
- NBitcoin.SequenceLockType.Time — compare the tip's median time past (BIP 113) against the MTP of the block that confirmed the input plus NBitcoin.Sequence.LockPeriod. Heights don't enter into it.
public static class CsvMaturity
- Inheritance
-
CsvMaturity
- Inherited Members
Methods
EvaluateAsync(Sequence, uint, IBitcoinBlockchain, CancellationToken)
Checks whether the relative timelock exitDelay on an
input confirmed at confirmHeight has matured.
public static Task<CsvMaturityResult> EvaluateAsync(Sequence exitDelay, uint confirmHeight, IBitcoinBlockchain blockchain, CancellationToken cancellationToken = default)
Parameters
exitDelaySequenceThe contract's relative-locktime sequence (typically
ArkServerInfo.UnilateralExit).confirmHeightuintHeight of the block that confirmed the input the claim transaction spends — where the countdown starts.
blockchainIBitcoinBlockchainBackend used to read the tip and, for time-based locks, the confirmation block's median time past.
cancellationTokenCancellationTokenCancellation token.
Returns
Exceptions
- InvalidOperationException
exitDelayis not a relative lock at all, or the backend could not resolve the confirmation block's median time past for a time-based lock (without it the timelock cannot be evaluated, and silently reporting "not matured" would strand the exit forever).- NotSupportedException
The lock is time-based and
blockchaindoes not implement GetMedianTimePastAsync(uint, CancellationToken).