Class CashuWallet

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

Hierarchy

  • CashuWallet

Constructors

  • Parameters

    • mint: CashuMint

      Cashu mint instance is used to make api calls

    • Optional keys: MintKeys

      public keys from the mint

    • Optional mnemonicOrSeed: string | Uint8Array

      mnemonic phrase or Seed to initial derivation key for this wallets deterministic secrets. When the mnemonic is provided, the seed will be derived from it. This can lead to poor performance, in which case the seed should be directly provided

    Returns CashuWallet

Properties

_keys: MintKeys
_keysetId: string = ''
_seed: undefined | Uint8Array
mint: CashuMint

Accessors

Methods

  • returns proofs that are already spent (use for keeping wallet state clean)

    Type Parameters

    • T extends {
          secret: string;
      }

    Parameters

    • proofs: T[]

      (only the 'secret' field is required)

    Returns Promise<T[]>

  • Creates blinded messages for a according to

    Parameters

    • amounts: number[]
    • Optional counter: number
    • Optional keysetId: string

    Returns BlindedMessageData & {
        amounts: number[];
    }

    blinded messages, secrets, rs, and amounts

  • Creates blinded messages for a given amount

    Parameters

    • amount: number

      amount to create blinded messages for

    • Optional amountPreference: AmountPreference[]

      optional preference for splitting proofs into specific amounts. overrides amount param

    • Optional counter: number

    Returns BlindedMessageData & {
        amounts: number[];
    }

    blinded messages, secrets, rs, and amounts

  • Estimate fees for a given LN invoice

    Parameters

    • invoice: string

      LN invoice that needs to get a fee estimate

    Returns Promise<number>

    estimated Fee

  • Initialize the wallet with the mints public keys

    Returns Promise<void>

  • Executes a payment of an invoice on the Lightning network. The combined amount of Proofs has to match the payment amount including fees.

    Parameters

    • invoice: string
    • proofsToSend: Proof[]

      the exact amount to send including fees

    • Optional feeReserve: number
    • Optional counter: number

    Returns Promise<PayLnInvoiceResponse>

  • Receive an encoded or raw Cashu token

    Parameters

    • token: string | Token

      Cashu token

    • Optional preference: AmountPreference[]

      optional preference for splitting proofs into specific amounts

    • Optional counter: number

    Returns Promise<ReceiveResponse>

    New token with newly created proofs, token entries that had errors, and newKeys if they have changed

  • Receive a single cashu token entry

    Parameters

    • tokenEntry: TokenEntry

      a single entry of a cashu token

    • Optional preference: AmountPreference[]

      optional preference for splitting proofs into specific amounts.

    • Optional counter: number

    Returns Promise<ReceiveTokenEntryResponse>

    New token entry with newly created proofs, proofs that had errors, and newKeys if they have changed

  • Starts a minting process by requesting an invoice from the mint

    Parameters

    • amount: number

      Amount requesting for mint.

    Returns Promise<RequestMintResponse>

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

  • Request tokens from the mint

    Parameters

    • amount: number

      amount to request

    • id: string

      id to identify the mint request*

    • Optional AmountPreference: AmountPreference[]
    • Optional counter: number

    Returns Promise<{
        newKeys?: MintKeys;
        proofs: Proof[];
    }>

    proofs and newKeys if they have changed

  • 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

    • Optional keysetId: string

    Returns Promise<{
        newKeys?: MintKeys;
        proofs: Proof[];
    }>

    proofs (and newKeys, if they have changed)

  • 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

      amount to send while performing the optimal split (least proofs possible). can be set to undefined if preference is set

    • proofs: Proof[]

      proofs matching that amount

    • Optional preference: AmountPreference[]

      optional preference for splitting proofs into specific amounts. overrides amount param

    • Optional counter: number

    Returns Promise<SendResponse>

    promise of the change- and send-proofs

  • Parameters

    • amount: number
    • amountAvailable: number

    Returns {
        amountKeep: number;
        amountSend: number;
    }

    • amountKeep: number
    • amountSend: number

Generated using TypeDoc