@cashu/cashu-ts
    Preparing search index...

    Class Mint

    Class represents Cashu Mint API.

    This class contains lower-level functions that are implemented by Wallet.

    Index

    Constructors

    Accessors

    Methods

    • Gets an existing BOLT12 melt quote from the mint. Returns current payment state (UNPAID, PENDING, or PAID) and payment preimage if paid.

      Parameters

      • quote: string

        Quote ID to check.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MeltQuoteResponse>

      Updated quote with current payment state and preimage if available.

    • Tries to establish a websocket connection with the websocket mint url according to NUT-17.

      Returns Promise<void>

    • Requests a new BOLT12 melt quote from the mint for paying a Lightning Network offer. For amount-less offers, specify the amount in options.amountless.amount_msat.

      Parameters

      • meltQuotePayload: MeltQuotePayload

        Payload containing the BOLT12 offer to pay and unit.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MeltQuoteResponse>

      Melt quote with amount, fee reserve, and payment state.

    • Closes a websocket connection.

      Returns void

    • Get the mint's public keys.

      Parameters

      • OptionalkeysetId: string

        Optional param to get the keys for a specific keyset. If not specified, the keys from all active keysets are fetched.

      • OptionalmintUrl: string

        Optional alternative mint URL to use for this request.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintActiveKeys>

      The mint's public keys.

    • Lazily fetches and caches the mint's info if not already loaded.

      Returns Promise<MintInfo>

      The parsed MintInfo object.

    • Requests the mint to pay for a Bolt11 payment request by providing ecash as inputs to be spent. The inputs contain the amount and the fee_reserves for a Lightning payment. The payload can also contain blank outputs in order to receive back overpaid Lightning fees.

      Parameters

      • meltPayload: MeltPayload

        The melt payload containing inputs and optional outputs.

      • Optionaloptions: { customRequest?: RequestFn; preferAsync?: boolean }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • OptionalpreferAsync?: boolean

          Optional override to set 'respond-async' header.

      Returns Promise<PartialMeltQuoteResponse>

      The melt response.

    • Requests the mint to pay a BOLT12 offer by providing ecash inputs to be spent. The inputs must cover the amount plus fee reserves. Optional outputs can be included to receive change for overpaid Lightning fees.

      Parameters

      • meltPayload: MeltPayload

        Payload containing quote ID, inputs, and optional outputs for change.

      • Optionaloptions: { customRequest?: RequestFn; preferAsync?: boolean }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • OptionalpreferAsync?: boolean

          Optional override to set 'respond-async' header.

      Returns Promise<MeltQuoteResponse>

      Payment result with state and optional change signatures.

    • Mints new tokens by requesting blind signatures on the provided outputs.

      Parameters

      • mintPayload: MintPayload

        Payload containing the outputs to get blind signatures on.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintResponse>

      Serialized blinded signatures.

    • Mints new tokens using a BOLT12 quote by requesting blind signatures on the provided outputs.

      Parameters

      • mintPayload: MintPayload

        Payload containing the quote ID and outputs to get blind signatures on.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintResponse>

      Serialized blinded signatures for the requested outputs.

    • Create an OIDC client using this mint’s NUT-21 metadata.

      Parameters

      Returns Promise<OIDCAuth>

      const oidc = await mint.oidcAuth({ onTokens: (t) => authMgr.setCAT(t.access_token!) });
      const start = await oidc.deviceStart();
      // show start.user_code / start.verification_uri to the user
      const token = await oidc.devicePoll(start.device_code, start.interval ?? 5);
      // token.access_token is your CAT