Cashu-TS - v4.0.0-rc3
    Preparing search index...

    Class KeyChain

    Manages all keysets for a Mint. Queries filter by the wallet's unit.

    Stores keysets for every unit the mint exposes. Methods like getKeysets() and getCheapestKeyset() filter by this.unit; getKeyset(id) is a direct lookup and is intentionally cross-unit.

    Index

    Constructors

    Accessors

    Methods

    • Ensure we have usable keys for a specific keyset id.

      Parameters

      • id: string

        Keyset ID.

      Returns Promise<Keyset>

      Keyset with keys.

      If keyset keys not found or verification fails.

    • Returns all the keyset IDs in this KeyChain across all units.

      Returns string[]

      Array of keyset IDs.

      If uninitialized.

    • Get the cheapest active keyset.

      Returns Keyset

      Active Keyset.

      Selects active keyset with lowest fee and hex ID.

      If none found or uninitialized.

    • Get a keyset by ID or the cheapest keyset if no ID is provided.

      Parameters

      • Optionalid: string

        Optional keyset ID.

      Returns Keyset

      Keyset with keys.

      If keyset not found or uninitialized.

    • Get list of all keysets for the wallet's unit.

      Returns Keyset[]

      Array of Keysets for this.unit.

      If uninitialized or no keysets exist for the unit.

    • Asynchronously load keysets and keys from the mint.

      Parameters

      • OptionalforceRefresh: boolean

        If true, re-fetches data even if already loaded.

      Returns Promise<void>

      Intended for callers that want the freshest data from the mint and can use an asynchronous path.

    • Synchronously load keysets and keys from cached data.

      Parameters

      Returns void

      Does not hit the network. Intended for callers that already have a KeyChainCache and want a synchronous path. Loads all keysets from the cache regardless of unit; query methods filter by this.unit.

    • Construct a KeyChain from previously cached data.

      Parameters

      • mint: string | Mint

        Mint URL or Mint instance.

      • unit: string

        The unit this KeyChain should filter queries by (e.g. 'sat').

      • cache: KeyChainCache

        Cache produced by keyChain.cache or KeyChain.mintToCacheDTO.

      Returns KeyChain

      Does not hit the network. The cache should have been produced by keyChain.cache.

    • Convert Mint API DTOs into a consolidated KeyChainCache.

      Parameters

      • mintUrl: string

        Mint URL.

      • allKeysets: MintKeyset[]

        All keysets from mint.getKeySets() — any unit.

      • allKeys: MintKeys[]

        All keys from mint.getKeys() — any unit.

      Returns KeyChainCache

      This is symmetrical to KeyChain.cacheToMintDTO. It is used by the cache getter and any code that wants to move from raw Mint DTOs to the new cache shape.