enforceUpdateGuards
@totemsdk/omnia / enforceUpdateGuards
Function: enforceUpdateGuards()
enforceUpdateGuards(
channelId,newSequence,payloadHash,pendingProposal?):"CAPACITY_NEAR_EXHAUSTION"|null
Enforce all per-update invariants that must hold for every state transition
regardless of whether the caller is updateState, addHTLC, fulfillHTLC,
or timeoutHTLC.
Specifically:
- WOTS capacity check: throws
ChannelCapacityErrorat 100%, returns'CAPACITY_NEAR_EXHAUSTION'at 95% (caller must NOT advance watermark). - Stale-sequence guard (SequenceError): rejects any attempt to sign a sequence that is behind the module-level watermark.
- Double-sign guard (DoubleSignError): rejects a different payload at a sequence already committed by this process.
- Watermark advance: after all guards pass, records
(newSequence, payloadHash)synchronously — before any async work — so no concurrent call can slip in between the guard and the WOTS reservation.
Parameters
channelId
string
Channel identifier for the watermark map key.
newSequence
number
Proposed next sequence number.
payloadHash
string
Hex-encoded SHA3-256 of the full off-chain state commitment (sequence + balances + pending HTLCs).
pendingProposal?
payloadHash
string
sequence
number
Returns
"CAPACITY_NEAR_EXHAUSTION" | null
'CAPACITY_NEAR_EXHAUSTION' when signing is blocked at the 95%
threshold; null when signing may proceed.