Cashu-TS - v4.0.0-rc3
    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

    • Checks an existing melt quote for any payment method.

      Type Parameters

      Parameters

      • method: string

        The payment method (e.g., 'bolt11', 'bolt12', or custom method name).

      • quote: string

        Quote ID.

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<TRes>

      The melt quote response.

      Uses /v1/melt/quote/{method}/{quote} and validates method format. Normalization follows the same stacking pattern as Mint.createMeltQuote.

    • 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<MeltQuoteBolt11Response>

      Updated quote with current payment state and preimage if available.

      Thin wrapper around checkMeltQuote('bolt12', ...).

    • Checks an existing mint quote for any payment method.

      Type Parameters

      Parameters

      • method: string

        The payment method (e.g., 'bolt11', 'bolt12', or custom method name).

      • quote: string

        Quote ID.

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<TRes>

      The mint quote response.

      Uses /v1/mint/quote/{method}/{quote} and validates method format. Normalization follows the same stacking pattern as Mint.createMintQuote.

    • Gets an existing mint quote from the mint.

      Parameters

      • quote: string

        Quote ID.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintQuoteBolt11Response>

      The status of the mint quote, including payment details and state.

      Thin wrapper around checkMintQuote('bolt11', ...).

    • Gets an existing BOLT12 mint quote from the mint.

      Parameters

      • quote: string

        Quote ID to check.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintQuoteBolt12Response>

      Updated quote with current payment and issuance amounts.

      Thin wrapper around checkMintQuote('bolt12', ...).

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

      Returns Promise<void>

    • Creates a melt quote for any payment method.

      Type Parameters

      Parameters

      • method: string

        The payment method (e.g., 'bolt11', 'bolt12', or custom method name).

      • payload: Record<string, unknown>

        The request body to POST (method-specific fields).

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<TRes>

      The melt quote response.

      Uses /v1/melt/quote/{method} and validates method format. Base normalization (amount, expiry, change) is always applied. For first-class methods (bolt11/bolt12), bolt-specific normalization (fee_reserve, request) is stacked on top. Custom methods can supply an optional normalize callback for their own fields.

    • 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: MeltQuoteBolt12Request

        Payload containing the BOLT12 offer to pay and unit.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MeltQuoteBolt11Response>

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

      Thin wrapper around createMeltQuote('bolt12', ...).

    • Creates a mint quote for any payment method.

      Type Parameters

      Parameters

      • method: string

        The payment method (e.g., 'bolt11', 'bolt12', or custom method name).

      • payload: Record<string, unknown>

        The request body to POST (method-specific fields).

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<TRes>

      The mint quote response.

      Uses /v1/mint/quote/{method} and validates method format. Base normalization is applied automatically. For first-class methods (bolt11/bolt12), method-specific normalization is stacked on top. Custom methods can supply an optional normalize callback for their own fields.

    • 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<GetKeysResponse>

      The mint's public keys.

    • Generic method to melt tokens using any payment method endpoint.

      Type Parameters

      • TRes extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • method: string

        The payment method (e.g., 'bolt11', 'bolt12', or custom method name).

      • meltPayload: MeltRequest

        The melt payload containing inputs and optional outputs.

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => MeltQuoteBaseResponse & TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => MeltQuoteBaseResponse & TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<MeltQuoteBaseResponse & TRes>

      A response object with at least the required melt quote fields.

      This method enables support for custom payment methods without modifying the Mint class. It constructs the endpoint as /v1/melt/{method} and POSTs the payload. The response must contain the common fields: quote, amount, state, expiry. Method-specific fields (e.g. fee_reserve for bolt11/bolt12) are normalized when present. Custom methods can supply an optional normalize callback for their own fields.

      const response = await mint.melt('bolt11', { quote: 'q1', inputs: [...], outputs: [...] });
      const response = await mint.melt('custom-payment', { quote: 'c1', inputs: [...], outputs: [...] });
    • 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: MeltRequest

        The melt payload containing inputs and optional outputs.

      • Optionaloptions: { customRequest?: RequestFn }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

      Returns Promise<MeltQuoteBolt11Response>

      The melt response.

      Thin wrapper around melt('bolt11', ...).

    • 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: MeltRequest

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

      • Optionaloptions: { customRequest?: RequestFn }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

      Returns Promise<MeltQuoteBolt11Response>

      Payment result with state and optional change signatures.

      Thin wrapper around melt('bolt12', ...).

    • Mints new tokens for a given payment method.

      Type Parameters

      • TRes extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • method: string

        The minting method (e.g., 'bolt11', 'bolt12', or custom method name).

      • mintPayload: MintRequest

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

      • Optionaloptions: {
            customRequest?: RequestFn;
            normalize?: (raw: Record<string, unknown>) => MintResponse & TRes;
        }
        • OptionalcustomRequest?: RequestFn

          Optional override for the request function.

        • Optionalnormalize?: (raw: Record<string, unknown>) => MintResponse & TRes

          Optional callback to normalize method-specific response fields.

      Returns Promise<MintResponse & TRes>

      Serialized blinded signatures for the requested outputs.

      Uses /v1/mint/{method} and validates method format. Signature amounts are always normalized. Custom methods can supply an optional normalize callback for any additional response fields.

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

      Parameters

      • mintPayload: MintRequest

        Payload containing the outputs to get blind signatures on.

      • OptionalcustomRequest: RequestFn

        Optional override for the request function.

      Returns Promise<MintResponse>

      Serialized blinded signatures.

      Thin wrapper around mint('bolt11', ...).

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

      Parameters

      • mintPayload: MintRequest

        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.

      Thin wrapper around mint('bolt12', ...).

    • 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