ProtectedactionsWhether to automatically unlock the wallet, tokens and history as they load
Protected OptionalautoProtected OptionalbackupReadonlybalance$A map of mint url to balance in sats
Readonlybusy$Whether any async operation is currently running
ReadonlycouchProtectedcouch$ReadonlycouchThe tokens currently held in the couch (refreshed after operations and via refreshCouch)
Protected OptionaldecryptionAn optional persistent cache of decrypted event content, consulted before decrypting and written to after
Protectederror$ReadonlyerrorThe most recent error (cleared at the start of each operation)
ReadonlyeventProtected OptionalfallbackStatic relays passed by the caller, used as a publishing fallback before the wallet loads
Readonlyhistory$The wallet's history events
ReadonlyhistoryThe number of history events
Protectedloaded$Protectedloading$ReadonlyloadingWhether the initial load is in progress
Protected OptionalloadingProtectedlogProtectedmintsA cache of cashu-ts Mint instances keyed by normalized url, reused across mint list changes. A Mint caches the mint's info and owns a single WebSocket connection, so reusing instances avoids re-fetching mint info and keeps one socket per mint.
Readonlymints$The cached cashu-ts Mint instances for the wallet's mints (reused across mint list changes)
ReadonlymintThe mint urls configured on the wallet (undefined until unlocked)
Protectednegentropy$ReadonlynegentropyA map of relay url to whether it supports NIP-77 negentropy sync
Protectedoperations$ReadonlyoperationsA map of operation name to whether it is currently running
ReadonlypoolReadonlypubkeyReadonlyrelays$The relays used for loading and publishing wallet events
ReadonlyrelayPer-relay connection status for the wallet's relays
ReadonlysignerReadonlystaleThe number of token events that are marked deleted but still present
ReadonlystaleToken events marked as deleted by a newer token event but still present (cleanup candidates)
Protectedstarted$Readonlystatus$The high-level lifecycle status of the wallet
Protectedsyncing$ReadonlysyncingWhether a negentropy sync is in progress
ReadonlytokenThe number of token events
ReadonlytokenHow the wallet's token events are spread across its relays
Readonlytokens$The wallet's token events
ReadonlytotalThe total balance across all mints in sats
Readonlyunlocked$Whether the wallet event is currently unlocked
ProtectedunlockingWhether the wallet loads, subscribes to and publishes NIP-09 delete events for its events. When false the wallet completely ignores kind-5 delete events for its wallet, token and history events (see NutWalletOptions.useDeleteEvents). The loading half is fixed when the wallet starts; toggling at runtime with setUseDeleteEvents only affects publishing until the next resync.
ProtecteduserReadonlywallet$The NIP-60 wallet cast (undefined until it loads)
ReadonlywalletThe relays configured on the wallet (undefined until unlocked)
ProtectedwalletsA cache of loaded cashu Wallet instances keyed by normalized mint url (wallets are specific to this wallet)
ProtectedapplyApplies a WalletLoaderStatus update to the lifecycle subjects
ProtectedbackupPublishes loaded wallet events only to configured relays that are missing them
Publishes a single NIP-09 delete event for every token event that a newer token event has marked as deleted but is still present. Cleans up the spent token events left on relays when operations run with setUseDeleteEvents disabled.
Combines all unlocked token events into a single event per mint
Creates a bolt11 mint quote (lightning invoice) to deposit amount sats into a mint.
Pay the returned request invoice, then wait for it with waitForMintQuote and redeem it
with redeemMintQuote (or use mint to do all three in one call).
Optionaldescription: stringCreates and publishes a new NIP-60 wallet event for this pubkey
Deposits funds into a mint using the given payment method, minting the resulting proofs into the wallet. This is the method-agnostic entry point; new payment methods are added as additional DepositOptions variants without changing this signature.
For bolt11 it creates a mint quote, surfaces the invoice via onQuote, waits for it to be paid,
and redeems the proofs.
Alias for stop
ProtecteddisposeDisconnects every cached mint's WebSocket and clears the mint cache
ProtectedgetReturns a cached, loaded cashu CashuWallet for a mint, building it from the cached Mint. Bound to the instance so it can be passed to actions as a wallet provider.
ProtectedgetCollects the wallet, token and history events that can hold encrypted content
ProtectedgetReturns the cached Mint for a url, creating it if it does not exist
ProtectedgetReturns wallet-owned events that should be backed up to every wallet relay
Locks the wallet, token and history events in the event store
ProtectedmintReturns whether the mint at a url supports a given NUT number
Pays a bolt11 lightning invoice from a specific mint's balance (melts ecash to lightning). A thin
alias for withdraw with method: "bolt11".
the cashu melt response, including any change proofs returned by the mint
ProtectedperformShared melt orchestration for every payment method. Creates a method-specific melt quote, selects proofs for the amount + fee reserve (under couch safety), melts them via the method-specific call, and keeps any remainder plus the mint's change. The two callbacks isolate the only payment-method-specific steps so new methods (bolt12, onchain) reuse this body.
ProtectedpersistPersists the decrypted content of unlocked events to the decryptionCache
ProtectedpollPolls a bolt11 mint quote until it is paid (fallback for mints without NIP-17 support)
Optionaloptions: { interval?: number; signal?: AbortSignal; timeoutMs?: number }ProtectedpublishPublishes a single event to the resolved relay set
Optionalrelays: string[]Receives one or more NIP-61 nutzap events into the wallet
Receives a Cashu token (encoded string or decoded Token) into the wallet
Recovers any unspent tokens left in the couch back into the wallet
Reloads the list of tokens currently held in the couch
ProtectedresolveResolves the relays an event should be published to: the relays passed by the action, plus the wallet's own relays and the user's outbox relays. Read synchronously so publishing is never blocked on loading.
Optionalextra: string[]ProtectedrestoreRestores decrypted content from the decryptionCache onto locked events. Setting the content cache lets the unlock helpers short-circuit before performing the expensive NIP-44 decryption.
Re-runs the initial load and negentropy sync against the current relay set
Rolls every unlocked token over to a fresh cashu token. For each mint the proofs are swapped at the mint
(rotating the secrets) and a single new token event is created whose del field references the
rolled-over token events. Unlike consolidateTokens, this swaps the proofs at the mint even when a
mint only has a single token event, so it is a good way to exercise the del reconciliation flow end to
end. Every new token event is published together with a single batched delete event covering all mints,
keeping signer operations to a minimum.
Creates a Cashu token to send and returns the encoded token string.
the amount to send in sats
Optionaloptions: { mint?: string }Optionalmint?: stringrestrict the send to a specific mint (otherwise any mint with enough balance is used)
Enables or disables automatic unlocking
Sets the mints configured on the wallet
ProtectedsetSets the running state of a named operation
Sets the relays configured on the wallet
Enables or disables publishing NIP-09 delete events for old token events during spend, rollover and consolidate operations. When disabled, spent token events are left on relays until cleanupDeletedTokens removes them in a single batched delete. This only affects publishing; to also change whether the wallet loads and subscribes to delete events, call resync afterwards.
Begins loading wallet events and watching for auto-unlock
Stops all loading and auto-unlocking
ProtectedsubscribeWatches for locked wallet, token and history events and unlocks them when auto-unlock is enabled
ProtectedsubscribeSubscribes to the loading stream and maps its status to the lifecycle subjects
ProtectedsyncReconciles the mint cache to a set of urls and returns the matching Mint instances. Mints that are no longer in the list have their WebSocket disconnected and are dropped.
Re-publishes all token events to the wallet's relays
ProtectedtrackRuns an async operation while tracking its busy state and surfacing any error
Unlocks the wallet event and all of its token and history events
Waits for a bolt11 mint quote to be paid. Uses a NIP-17 WebSocket subscription when the mint supports it and falls back to polling the quote otherwise.
Optionaloptions: { interval?: number; signal?: AbortSignal; timeoutMs?: number }Optionalinterval?: numberpolling interval in ms when the mint does not support NIP-17 (default 3000)
Optionalsignal?: AbortSignalaborts the wait
OptionaltimeoutMs?: numberrejects after this many milliseconds
Withdraws funds from a mint's balance using the given payment method (melts ecash). This is the method-agnostic entry point; payInvoice is the bolt11 alias. New payment methods are added as additional WithdrawOptions variants without changing this signature.
the cashu melt response, including any change proofs returned by the mint
StaticcreateCreates a new NIP-60 wallet and returns a started NutWallet
A reusable NIP-60 / Cashu wallet.
Wraps a signer, relay pool, event store and couch, exposes RxJS observable fields for wallet state and status, and async methods for the common wallet operations. Robustly loads wallet events using an initial request, negentropy sync where available, and a live subscription (see loadWalletEvents).
Example