Skip to main content

Module nonce

Module nonce 

Source
Expand description

Process-wide (wallet, subaccount) nonce manager for Derive self-custodial requests.

Derive’s venue schema defines a unique nonce as UTC milliseconds followed by a suffix of up to three digits and illustrates the suffix as 001. The reference SDK accepts caller-selected suffixes in 0..=999. The allocator uses a fixed three-digit suffix field: utc_ms * 1000 + suffix.

Manager guarantees:

  1. Unique and monotonically increasing per (wallet, subaccount) across every manager in the process, including during clock rollback.
  2. Suffixes stay within the venue’s documented 0..=999 range.
  3. Atomic allocation per key under contention. A process-wide DashMap shards the state and a compare_exchange loop serialises allocators.

Structs§

NonceManager
Thread-safe process-wide nonce allocator keyed by (wallet, subaccount_id).

Enums§

NonceError
Errors raised by NonceManager.