Class that represents a Cashu wallet. This class should act as the entry point for this library

Constructors

  • Parameters

    • mint: CashuMint

      Cashu mint instance is used to make api calls

    • Optionaloptions: {
          bip39seed?: Uint8Array<ArrayBufferLike>;
          denominationTarget?: number;
          keepFactory?: OutputDataFactory;
          keys?: MintKeys | MintKeys[];
          keysets?: MintKeyset[];
          mintInfo?: GetInfoResponse;
          unit?: string;
      }
      • Optionalbip39seed?: Uint8Array<ArrayBufferLike>

        BIP39 seed for deterministic secrets.

      • OptionaldenominationTarget?: number

        target number proofs per denomination (default: see

      • OptionalkeepFactory?: OutputDataFactory

        A function that will be used by all parts of the library that produce proofs to be kept (change, etc.). This can lead to poor performance, in which case the seed should be directly provided

      • Optionalkeys?: MintKeys | MintKeys[]

        public keys from the mint (will be fetched from mint if not provided)

      • Optionalkeysets?: MintKeyset[]

        keysets from the mint (will be fetched from mint if not provided)

      • OptionalmintInfo?: GetInfoResponse

        mint info from the mint (will be fetched from mint if not provided)

      • Optionalunit?: string

        optionally set unit (default is 'sat')

    Returns CashuWallet

    DEFAULT_DENOMINATION_TARGET)

Properties

mint: CashuMint

Accessors

Methods

  • Gets an existing mint quote from the mint.

    Parameters

    • quote: string

      Quote ID

    Returns Promise<MintQuoteResponse>

    the mint will create and return a Lightning invoice for the specified amount

  • Get an array of the states of proofs from the mint (as an array of CheckStateEnum's)

    Parameters

    • proofs: Proof[]

      (only the secret field is required)

    Returns Promise<ProofState[]>

  • Requests a melt quote from the mint. Response returns amount and fees for a given unit in order to pay a Lightning invoice.

    Parameters

    • invoice: string

      LN invoice that needs to get a fee estimate

    Returns Promise<MeltQuoteResponse>

    the mint will create and return a melt quote for the invoice with an amount and fee reserve

  • Requests a mint quote form the mint. Response returns a Lightning payment request for the requested given amount and unit.

    Parameters

    • amount: number

      Amount requesting for mint.

    • Optionaldescription: string

      optional description for the mint quote

    Returns Promise<MintQuoteResponse>

    the mint will return a mint quote with a Lightning invoice for minting tokens of the specified amount and unit

  • Get all active keys from the mint and set the keyset with the lowest fees as the active wallet keyset.

    Returns Promise<MintKeys[]>

    keyset

  • calculates the fees based on inputs for a given keyset

    Parameters

    • nInputs: number

      number of inputs

    • keysetId: string

      keysetId used to lookup input_fee_ppk

    Returns number

    fee amount

  • calculates the fees based on inputs (proofs)

    Parameters

    • proofs: Proof[]

      input proofs to calculate fees for

    Returns number

    fee amount

  • Get public keys from the mint. If keys were already fetched, it will return those.

    If keysetId is set, it will fetch and return that specific keyset. Otherwise, we select an active keyset with the unit of the wallet.

    Parameters

    • OptionalkeysetId: string

      optional keysetId to get keys for

    • OptionalforceRefresh: boolean

    Returns Promise<MintKeys>

    keyset

  • Get information about the mint

    Returns Promise<MintInfo>

    mint info

  • Load mint information, keysets and keys. This function can be called if no keysets are passed in the constructor

    Returns Promise<void>

  • Mint proofs for a given mint quote

    Parameters

    • amount: number

      amount to request

    • quote: string

      ID of mint quote

    • Optionaloptions: MintProofOptions

      Optional parameters for configuring the Mint Proof operation

    Returns Promise<Proof[]>

    proofs

  • Register a callback to be called whenever a melt quote's state changes

    Parameters

    • quoteId: string
    • callback: (payload: MeltQuoteResponse) => void

      Callback function that will be called whenever a melt quote state changes

    • errorCallback: (e: Error) => void

    Returns Promise<SubscriptionCanceller>

  • Register a callback to be called when a single melt quote gets paid

    Parameters

    • quoteIds: string[]
    • callback: (payload: MeltQuoteResponse) => void

      Callback function that will be called when this melt quote gets paid

    • errorCallback: (e: Error) => void

    Returns Promise<SubscriptionCanceller>

  • Register a callback to be called when a single mint quote gets paid

    Parameters

    • quoteId: string

      Mint quote id that should be subscribed to

    • callback: (payload: MintQuoteResponse) => void

      Callback function that will be called when this mint quote gets paid

    • errorCallback: (e: Error) => void

    Returns Promise<SubscriptionCanceller>

  • Register a callback to be called whenever a mint quote's state changes

    Parameters

    • quoteIds: string[]

      List of mint quote IDs that should be subscribed to

    • callback: (payload: MintQuoteResponse) => void

      Callback function that will be called whenever a mint quote state changes

    • errorCallback: (e: Error) => void

    Returns Promise<SubscriptionCanceller>

  • Register a callback to be called whenever a subscribed proof state changes

    Parameters

    • proofs: Proof[]

      List of proofs that should be subscribed to

    • callback: (payload: ProofState & { proof: Proof }) => void

      Callback function that will be called whenever a proof's state changes

    • errorCallback: (e: Error) => void

    Returns Promise<SubscriptionCanceller>

  • Receive an encoded or raw Cashu token (only supports single tokens. It will only process the first token in the token array)

    Parameters

    • token: string | Token

      Cashu token, either as string or decoded

    • Optionaloptions: ReceiveOptions

      Optional configuration for token processing

    Returns Promise<Proof[]>

    New token with newly created proofs, token entries that had errors

  • Regenerates

    Parameters

    • start: number

      set starting point for count (first cycle for each keyset should usually be 0)

    • count: number

      set number of blinded messages that should be generated

    • Optionaloptions: RestoreOptions
      • OptionalkeysetId?: string

    Returns Promise<{ proofs: Proof[] }>

  • Send proofs of a given amount, by providing at least the required amount of proofs

    Parameters

    • amount: number

      amount to send

    • proofs: Proof[]

      array of proofs (accumulated amount of proofs must be >= than amount)

    • Optionaloptions: SendOptions

      Optional parameters for configuring the send operation

    Returns Promise<SendResponse>

  • Splits and creates sendable tokens if no amount is specified, the amount is implied by the cumulative amount of all proofs if both amount and preference are set, but the preference cannot fulfill the amount, then we use the default split

    Parameters

    • amount: number
    • proofs: Proof[]
    • Optionaloptions: SwapOptions

      Optional parameters for configuring the swap operation

    Returns Promise<SendResponse>

    promise of the change- and send-proofs