Table of Contents

Class CsvMaturity

Namespace
NArk.Core.Exit
Assembly
NArk.Core.dll

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

exitDelay Sequence

The contract's relative-locktime sequence (typically ArkServerInfo.UnilateralExit).

confirmHeight uint

Height of the block that confirmed the input the claim transaction spends — where the countdown starts.

blockchain IBitcoinBlockchain

Backend used to read the tip and, for time-based locks, the confirmation block's median time past.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<CsvMaturityResult>

Exceptions

InvalidOperationException

exitDelay is 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 blockchain does not implement GetMedianTimePastAsync(uint, CancellationToken).