Cashu-TS - v4.13.0
    Preparing search index...

    Interface CounterSource

    interface CounterSource {
        advanceToAtLeast(keysetId: string, minNext: number): Promise<void>;
        reserve(keysetId: string, n: number): Promise<CounterRange>;
        reserveAt?(
            keysetId: string,
            start: number,
            count: number,
        ): Promise<CounterRange>;
        setNext?(keysetId: string, next: number): Promise<void>;
        snapshot?(): Promise<Record<string, number>>;
    }
    Index

    Methods

    • Monotonic bump, ensure the next counter is at least minNext.

      Parameters

      • keysetId: string
      • minNext: number

      Returns Promise<void>

    • Reserve n counters for a keyset.

      N may be 0. In that case the call MUST NOT mutate state and MUST return { start: currentNext, count: 0 }, effectively a read only peek of the cursor.

      Parameters

      • keysetId: string
      • n: number

      Returns Promise<CounterRange>

    • Reserve a caller-chosen range [start, start+count) for a keyset.

      Optional in v4, will be required in v5.

      Parameters

      • keysetId: string
      • start: number
      • count: number

      Returns Promise<CounterRange>

      Used for manual deterministic counters when present; without it the wallet falls back to advanceToAtLeast. MUST be atomic with reserve() and throw if start is below the cursor (range already issued). Counters below start are burned, matching advanceToAtLeast.

    • Optional hard set, useful for tests or migrations.

      Parameters

      • keysetId: string
      • next: number

      Returns Promise<void>