Skip to main content

Wallet

Struct Wallet 

Source
pub struct Wallet {
    pub mint_url: MintUrl,
    pub unit: CurrencyUnit,
    pub localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>,
    pub metadata_cache: Arc<MintMetadataCache>,
    pub target_proof_count: usize,
    /* private fields */
}
Expand description

CDK Wallet

The CDK Wallet is a high level cashu wallet.

A Wallet is for a single mint and single unit.

§Initialization

After creating a wallet, call Wallet::recover_incomplete_sagas to recover from interrupted operations (swap, send, receive, melt). This is required to prevent proofs from being stuck in reserved states after a crash.

For pending mint quotes, call Wallet::mint_unissued_quotes which checks quote states with the mint and mints available tokens. This makes network calls.

Fields§

§mint_url: MintUrl

Mint Url

§unit: CurrencyUnit

Unit

§localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>

Storage backend

§metadata_cache: Arc<MintMetadataCache>

Mint metadata cache for this mint (lock-free cached access to keys, keysets, and mint info)

§target_proof_count: usize

The targeted amount of proofs to have at each size

Implementations§

Source§

impl Wallet

Source

pub async fn mint_blind_auth(&self, amount: Amount) -> Result<Proofs, Error>

Mint blind auth tokens

Source

pub async fn get_unspent_auth_proofs(&self) -> Result<Vec<AuthProof>, Error>

Get unspent auth proofs

Source

pub async fn set_cat(&self, cat: String) -> Result<(), Error>

Set Clear Auth Token (CAT) for authentication

Source

pub async fn set_refresh_token( &self, refresh_token: String, ) -> Result<(), Error>

Set refresh for authentication

Source

pub async fn refresh_access_token(&self) -> Result<(), Error>

Refresh CAT token

Source

pub async fn set_auth_client(&self, auth_wallet: Option<AuthWallet>)

Set the auth client (AuthWallet) for this wallet

This allows updating the auth wallet without recreating the wallet. Also updates the client’s auth wallet to keep them in sync.

Source§

impl Wallet

Source

pub async fn total_balance(&self) -> Result<Amount, Error>

Total unspent balance of wallet

Source

pub async fn total_pending_balance(&self) -> Result<Amount, Error>

Total pending balance

Source

pub async fn total_reserved_balance(&self) -> Result<Amount, Error>

Total reserved balance

Source§

impl Wallet

Source

pub async fn mint_quote( &self, method: PaymentMethod, amount: Option<Amount>, description: Option<String>, extra: Option<String>, ) -> Result<MintQuote, Error>

Create a mint quote for the given payment method and amount

Source

pub async fn check_mint_quote_status( &self, quote_id: &str, ) -> Result<MintQuote, Error>

Check the status of a single mint quote from the mint.

Calls GET /v1/mint/quote/{method}/{quote_id} per NUT-04. Updates local store with current state from mint. Returns the persisted quote, including its database version and ownership. Rejects a mismatched response quote ID before changing local state. If there was a crashed mid-mint (pending saga), attempts to complete it. Does NOT mint tokens directly - use mint() for that.

Note: The mint quote must be known to the wallet (stored locally) for this function to work. If the quote is not stored locally, use fetch_mint_quote instead.

Source

pub async fn check_mint_quote(&self, quote_id: &str) -> Result<MintQuote, Error>

Check a mint quote status (alias for check_mint_quote_status)

Source

pub async fn check_all_mint_quotes(&self) -> Result<Vec<MintQuote>, Error>

Check all unissued mint quote states from the mint.

Calls GET /v1/mint/quote/{method}/{quote_id} per NUT-04 for each quote. Updates local store with current state from mint for each quote. If there was a crashed mid-mint (pending saga), attempts to complete it. Does NOT mint tokens directly - use mint() or mint_unissued_quotes() for that.

Source

pub async fn mint_unissued_quotes(&self) -> Result<Amount, Error>

Refresh states and mint all unissued quotes that have mintable amounts. Uses NUT-29 batch quote checks and batch minting automatically when the mint advertises support for the quotes’ payment method. Returns the total amount minted across all quotes.

§Privacy

This method retrieves all unissued mint quotes from the local store and checks their state with the mint. This has a negative privacy effect of linking all these quotes to a single wallet session.

Source

pub async fn get_active_mint_quotes(&self) -> Result<Vec<MintQuote>, Error>

Get active mint quotes Returns mint quotes that are not expired and not yet issued.

Source

pub async fn get_unissued_mint_quotes(&self) -> Result<Vec<MintQuote>, Error>

Get unissued mint quotes Returns bolt11 quotes where nothing has been issued yet (amount_issued = 0) and all bolt12 quotes. Includes unpaid bolt11 quotes to allow checking with the mint if they’ve been paid (wallet state may be outdated). Filters out quotes from other mints and units. Does not filter by expiry time to allow checking with the mint if expired quotes can still be minted.

Source

pub async fn mint( &self, quote_id: &str, amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> Result<Proofs, Error>

Mint

Source

pub async fn mint_unified( &self, quote_id: &str, amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> Result<Proofs, Error>

Mint tokens for a quote (alias for mint)

Source

pub async fn fetch_mint_quote( &self, quote_id: &str, payment_method: Option<PaymentMethod>, ) -> Result<MintQuote, Error>

Fetch a mint quote from the mint and store it locally

This method contacts the mint to get the current state of a quote, creates or updates the quote in local storage, and returns the stored quote.

Works with all payment methods (Bolt11, Bolt12, and custom payment methods).

A quote not created by this wallet instance, such as one fetched after restoring from seed, is stored without its NUT-20 signing key. Use Self::fetch_mint_quote_with_key_search to recover that key.

§Arguments
  • quote_id - The ID of the quote to fetch
  • payment_method - The payment method for the quote. Required if the quote is not already stored locally. If the quote exists locally, the stored payment method will be used and this parameter is ignored.
§Errors

Returns Error::PaymentMethodRequired if the quote is not found locally and no payment method is provided. Returns Error::InvalidMintResponse if the response quote ID does not match.

Fetch a mint quote and try to recover its NUT-20 signing key from the seed.

Use this after restoring a wallet from seed to claim a quote whose ID is known but whose signing key was lost with the old database. Plain Self::fetch_mint_quote never searches.

The mint reports the public key the quote is locked to. This method derives the wallet’s NUT-20 keys at counters 0..key_search_limit (capped at the BIP32 non-hardened index boundary) and stores the first one that matches. On a match, the wallet’s NUT-20 counter is advanced past that index so new quotes never reuse it.

Returns Ok even if no key matched. Check quote.secret_key.is_some() on the result: if set, call Self::mint; if not, retry with a larger limit. The quote stays stored either way.

The search is skipped when the quote already has a key, is not locked, is an NpubCash quote (its key comes from the NpubCash identity), or key_search_limit is zero. Keys that were generated randomly rather than derived from the seed cannot be recovered.

See crates/cdk/examples/restore-mint-quote.rs for a complete example.

§Arguments
  • quote_id - The ID of the quote to recover
  • payment_method - As for Self::fetch_mint_quote
  • key_search_limit - Exclusive upper bound on counters to try. It must exceed the index the original wallet used for this quote, which is below the number of locked quotes it created. Each key costs a BIP32 derivation.
§Errors

Same as Self::fetch_mint_quote, plus key derivation or database errors.

Source

pub async fn batch_check_mint_quote_status( &self, quote_ids: &[&str], ) -> Result<Vec<MintQuote>, Error>

Batch check status of multiple mint quotes from the mint.

Calls POST /v1/mint/quote/{method}/check per NUT-29. All quotes must share the same payment method. Updates local store with current state from mint for each quote. Rejects mismatched response counts or quote IDs before updating any quote.

Source

pub async fn batch_mint( &self, quote_ids: &[&str], amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, external_keys: Option<HashMap<String, SecretKey>>, ) -> Result<Proofs, Error>

Mint tokens for multiple quotes in a single batch operation.

Calls POST /v1/mint/{method}/batch per NUT-29. All quotes must share the same payment method and unit. Uses the saga pattern for crash recovery.

§Arguments
  • quote_ids - Array of unique quote IDs to mint
  • amount_split_target - How to split the minted amount into proofs
  • spending_conditions - Optional conditions to attach to the proofs
  • external_keys - Optional signing keys for quotes not in local store
Source§

impl Wallet

Source

pub async fn keysets( &self, policy: KeysetLoadPolicy, ) -> Result<Vec<KeySet>, Error>

Get all keysets for this wallet’s unit.

Tries a fresh fetch from the mint. On failure, falls back to any cached/persisted data. Only hard-fails when the cache is empty (first-ever fetch).

Source

pub async fn active_keyset(&self) -> Result<KeySet, Error>

Get the active keyset with the lowest fees.

Filters the output of keysets() for active keysets and returns the one with the minimum input_fee_ppk.

Source

pub async fn active_keyset_with_policy( &self, policy: KeysetLoadPolicy, ) -> Result<KeySet, Error>

Get the active keyset using a specific KeysetLoadPolicy.

Same as active_keyset() but lets callers control whether the network may be contacted.

Source

pub async fn keyset(&self, keyset_id: Id) -> Result<KeySet, Error>

Get a single keyset by ID.

Source

pub async fn keyset_with_policy( &self, keyset_id: Id, policy: KeysetLoadPolicy, ) -> Result<KeySet, Error>

Get a single keyset by ID using a specific KeysetLoadPolicy.

Source

pub async fn get_keyset_fees_and_amounts( &self, ) -> Result<KeysetFeeAndAmounts, Error>

Get keyset fees and amounts for all keysets

Source

pub async fn get_keyset_fees_and_amounts_with_policy( &self, policy: KeysetLoadPolicy, ) -> Result<KeysetFeeAndAmounts, Error>

Same as get_keyset_fees_and_amounts() but lets callers control the KeysetLoadPolicy.

Source

pub async fn get_keyset_fees_by_id(&self, keyset_id: Id) -> Result<u64, Error>

Get the input fee rate for a specific keyset ID

Source

pub async fn get_keyset_fees_and_amounts_by_id( &self, keyset_id: Id, ) -> Result<FeeAndAmounts, Error>

Get keyset fees and amounts for a specific keyset ID

Source

pub async fn get_keyset_fees_and_amounts_by_id_with_policy( &self, keyset_id: Id, policy: KeysetLoadPolicy, ) -> Result<FeeAndAmounts, Error>

Get keyset fees and amounts for a specific keyset ID using a specific KeysetLoadPolicy.

Source§

impl Wallet

Source

pub async fn melt_bip353_quote( &self, bip353_address: &str, amount_msat: impl Into<Amount>, network: Network, ) -> Result<MeltQuote, Error>

Melt Quote for BIP353 human-readable address

This method resolves a BIP353 address (e.g., “alice@example.com”) to a Bitcoin payment instruction, requires a BOLT12 offer in that instruction, and then creates a melt quote for that offer.

§Arguments
  • bip353_address - Human-readable address in the format “user@domain.com”
  • amount_msat - Amount to pay in millisatoshis
  • network - Bitcoin network for on-chain address validation in the resolved URI
§Returns

A MeltQuote that can be used to execute the payment

§Errors

This method will return an error if:

  • The BIP353 address format is invalid
  • DNS resolution fails or DNSSEC validation fails
  • No BOLT12 offer is found in the payment instructions
  • The mint fails to provide a quote for the offer
§Example
use cdk::Amount;
let quote = wallet
    .melt_bip353_quote(
        "alice@example.com",
        Amount::from(100_000), // 100 sats in msat
        bitcoin::Network::Bitcoin,
    )
    .await?;
Source§

impl Wallet

Source

pub async fn melt_lightning_address_quote( &self, lightning_address: &str, amount_msat: impl Into<Amount>, ) -> Result<MeltQuote, Error>

Melt Quote for Lightning address

This method resolves a Lightning address (e.g., “alice@example.com”) to a Lightning invoice and then creates a melt quote for that invoice.

§Arguments
  • lightning_address - Lightning address in the format “user@domain.com”
  • amount_msat - Amount to pay in millisatoshis
§Returns

A MeltQuote that can be used to execute the payment

§Errors

This method will return an error if:

  • The Lightning address format is invalid
  • HTTP request to the Lightning address service fails
  • The amount is outside the acceptable range
  • The service returns an error
  • The mint fails to provide a quote for the invoice
§Example
use cdk::Amount;
let quote = wallet
    .melt_lightning_address_quote("alice@example.com", Amount::from(100_000)) // 100 sats in msat
    .await?;
Source§

impl Wallet

Source

pub async fn quote_onchain_melt_options( &self, address: &str, amount: Amount, max_fee_amount: Option<Amount>, ) -> Result<Vec<MeltQuote>, Error>

Fetch available onchain melt quote options.

Source

pub async fn select_onchain_melt_quote( &self, quote: MeltQuote, ) -> Result<MeltQuote, Error>

Persist a selected onchain melt quote.

Source§

impl Wallet

Source

pub async fn cross_mint_transfer_quote_max( &self, target_wallet: &Wallet, ) -> Result<CrossMintTransferQuote, Error>

Create quotes for transferring the maximum amount allowed by the source balance and both mints’ advertised BOLT11 limits.

The destination wallet creates a BOLT11 mint quote and this wallet asks its mint for the corresponding melt quote. Because the melt fee reserve can depend on the invoice amount, the method repeats this process until the destination amount fits the source balance after both the melt fee reserve and the input fee for all unspent source proofs.

The returned plan assumes all currently unspent source proofs are used. To preserve that accounting, prepare the melt with Wallet::prepare_melt_proofs and confirm it with MeltConfirmOptions::skip_swap.

The melt fee is a reserve. If the actual Lightning fee is lower, the source mint can return the difference as change, so a successful melt may leave a small source balance.

The returned plan covers one Lightning payment. If an advertised quote maximum is below the source balance, complete the plan and call this method again to transfer the remaining balance.

§Remote side effects

Finding the maximum can require several probes because the source mint’s fee reserve is only known after the destination mint creates an invoice. Every probe creates a mint quote at the destination and a melt quote at the source. Only the returned pair is persisted locally; the other remote quotes cannot be cancelled and remain at their mints until they expire. Avoid calling this method speculatively or in an unbounded loop.

Source

pub async fn prepare_melt( &self, quote_id: &str, metadata: HashMap<String, String>, ) -> Result<PreparedMelt<'_>, Error>

Prepare a melt operation without executing it.

Source

pub async fn prepare_melt_proofs( &self, quote_id: &str, proofs: Proofs, metadata: HashMap<String, String>, ) -> Result<PreparedMelt<'_>, Error>

Prepare a melt operation with specific proofs.

Source

pub async fn prepare_melt_token( &self, quote_id: &str, encoded_token: &str, metadata: HashMap<String, String>, ) -> Result<PreparedMelt<'_>, Error>

Prepare a melt operation from an encoded token.

Decodes the token, validates unit and mint URL, extracts proofs, and delegates to prepare_melt_proofs.

Source

pub async fn finalize_pending_melts(&self) -> Result<Vec<FinalizedMelt>, Error>

Finalize pending melt operations.

Source

pub async fn get_active_melt_quotes(&self) -> Result<Vec<MeltQuote>, Error>

Get all active melt quotes from the wallet

Source

pub async fn get_pending_melt_quotes(&self) -> Result<Vec<MeltQuote>, Error>

Get pending melt quotes

Source

pub async fn melt_human_readable_quote( &self, address: &str, amount_msat: impl Into<Amount>, network: Network, ) -> Result<MeltQuote, Error>

Get a melt quote for a human-readable address

This method accepts a human-readable address that could be either a BIP353 address or a Lightning address. It intelligently determines which to try based on mint support:

  1. If the mint supports Bolt12, it tries BIP353 first
  2. Falls back to Lightning address only if BIP353 resolution fails
  3. If BIP353 resolves but does not contain a usable BOLT12 offer, it does NOT fall back
  4. If the mint doesn’t support Bolt12, it tries Lightning address directly

The network parameter is forwarded to the BIP353 resolver for on-chain address validation in the resolved URI.

Source

pub async fn melt_human_readable( &self, address: &str, amount_msat: impl Into<Amount>, network: Network, ) -> Result<MeltQuote, Error>

Get a melt quote for a human-readable address (alias for melt_human_readable_quote)

Source

pub async fn melt_quote<T, R>( &self, method: T, request: R, options: Option<MeltOptions>, extra: Option<String>, ) -> Result<MeltQuote, Error>
where T: Into<PaymentMethod> + Debug, R: Display,

Melt quote for all payment methods

Accepts Bolt11Invoice, Offer, String, or &str for the request parameter.

§Onchain

The onchain payment method is not reachable through this generic entry point: onchain melt quotes require a payout amount (the address alone is insufficient) and the mint returns an array of candidate fee tiers that must be selected explicitly. Callers needing onchain should use Wallet::quote_onchain_melt_options to fetch the candidate quotes and Wallet::select_onchain_melt_quote to persist the chosen one. Invoking melt_quote with KnownMethod::Onchain returns Error::UnsupportedPaymentMethod.

Source

pub async fn check_melt_quote_status( &self, quote_id: &str, ) -> Result<MeltQuote, Error>

Check melt quote status and return the persisted version and ownership.

Source§

impl Wallet

Source

pub fn set_metadata_cache_ttl(&self, ttl: Option<Duration>)

Sets the metadata cache TTL.

The TTL determines how often the wallet re-fetches keysets and mint info. Because the cache is shared, this affects all wallets using the same mint.

None means cached data never expires. Default: 1 hour.

Source

pub fn get_metadata_cache_info(&self) -> FreshnessStatus

Get information about metadata cache info

Source§

impl Wallet

Source

pub async fn prepare_pay_request( &self, payment_request: PaymentRequest, custom_amount: Option<Amount>, ) -> Result<PreparedPaymentRequest, Error>

Prepare a NUT-18 payment request and freeze its selected mint fees.

The returned payment must be explicitly completed with PreparedPaymentRequest::confirm or released with PreparedPaymentRequest::cancel.

Source§

impl Wallet

Source

pub async fn get_unspent_proofs(&self) -> Result<Proofs, Error>

Get unspent proofs for mint

Source

pub async fn get_pending_proofs(&self) -> Result<Proofs, Error>

Get pending Proofs

Source

pub async fn get_reserved_proofs(&self) -> Result<Proofs, Error>

Get reserved Proofs

Source

pub async fn get_pending_spent_proofs(&self) -> Result<Proofs, Error>

Get pending spent Proofs

Source

pub async fn get_proofs_by_states( &self, states: Vec<State>, ) -> Result<Proofs, Error>

Get proofs filtered by states

Source

pub async fn get_proofs_with( &self, state: Option<Vec<State>>, spending_conditions: Option<Vec<SpendingConditions>>, ) -> Result<Proofs, Error>

Get this wallet’s Proofs that match the args

Source

pub async fn unreserve_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Error>

Return proofs to unspent allowing them to be selected and spent

Source

pub async fn check_proofs_spent( &self, proofs: Proofs, ) -> Result<Vec<ProofState>, Error>

NUT-07 Check the state of a Proof with the mint

Source

pub async fn check_all_pending_proofs(&self) -> Result<Amount, Error>

Checks pending proofs for spent status and marks spent proofs accordingly.

§Legacy Recovery Function

This function is intended for recovering orphaned proofs that were stuck in Pending, Reserved, or PendingSpent state before the saga pattern was implemented, or proofs whose saga was deleted without proper cleanup.

Important: This function only operates on proofs that are NOT currently associated with an active saga operation (i.e., used_by_operation is None). Proofs managed by active sagas are skipped to avoid interfering with in-flight operations.

For proofs that are part of active sagas, use the appropriate saga recovery mechanism (recover_incomplete_sagas) or saga-specific methods like SendSaga::revoke().

§Returns

The total amount of orphaned proofs that remain pending (not spent by the mint) after checking.

Source

pub fn select_exact_proofs( amount: Amount, proofs: Proofs, active_keyset_ids: &Vec<Id>, fees_and_keyset_amounts: &KeysetFeeAndAmounts, include_fees: bool, ) -> Result<(Proofs, Option<(Proof, Amount)>), Error>

Select exact proofs

This function is similar to select_proofs but it the selected proofs will not exceed the requested Amount, it will include a Proof and the exacto amount needed form that Proof to perform a swap.

The intent is to perform a swap with info, or include the Proof as part of the return if the swap is not needed or if the swap failed.

Source

pub fn select_proofs( amount: Amount, proofs: Proofs, active_keyset_ids: &Vec<Id>, fees_and_keyset_amounts: &KeysetFeeAndAmounts, include_fees: bool, ) -> Result<Proofs, Error>

Select proofs

Source§

impl Wallet

Source

pub async fn receive_proofs( &self, proofs: Proofs, opts: ReceiveOptions, memo: Option<String>, token: Option<String>, ) -> Result<Amount, Error>

Receive proofs using the saga pattern

This is the internal implementation that uses the saga pattern for proper crash recovery and compensation.

Source

pub async fn receive( &self, encoded_token: &str, opts: ReceiveOptions, ) -> Result<Amount, Error>

Receive

§Synopsis
 use std::sync::Arc;

 use cdk::amount::SplitTarget;
 use cdk_sqlite::wallet::memory;
 use cdk::nuts::CurrencyUnit;
 use cdk::wallet::{ReceiveOptions, Wallet};
 use rand::random;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
 let seed = random::<[u8; 64]>();
 let mint_url = "https://testnut.cashudevkit.org";
 let unit = CurrencyUnit::Sat;

 let localstore = memory::empty().await?;
 let wallet = Wallet::new(mint_url, unit, Arc::new(localstore), seed, None).unwrap();
 let token = "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJhbW91bnQiOjEsInNlY3JldCI6ImI0ZjVlNDAxMDJhMzhiYjg3NDNiOTkwMzU5MTU1MGYyZGEzZTQxNWEzMzU0OTUyN2M2MmM5ZDc5MGVmYjM3MDUiLCJDIjoiMDIzYmU1M2U4YzYwNTMwZWVhOWIzOTQzZmRhMWEyY2U3MWM3YjNmMGNmMGRjNmQ4NDZmYTc2NWFhZjc3OWZhODFkIiwiaWQiOiIwMDlhMWYyOTMyNTNlNDFlIn1dLCJtaW50IjoiaHR0cHM6Ly90ZXN0bnV0LmNhc2h1LnNwYWNlIn1dLCJ1bml0Ijoic2F0In0=";
 let amount_receive = wallet.receive(token, ReceiveOptions::default()).await?;
 Ok(())
}
Source

pub async fn receive_raw( &self, binary_token: &Vec<u8>, opts: ReceiveOptions, ) -> Result<Amount, Error>

Receive

§Synopsis
 use std::sync::Arc;

 use cdk::amount::SplitTarget;
 use cdk_sqlite::wallet::memory;
 use cdk::nuts::CurrencyUnit;
 use cdk::wallet::{ReceiveOptions, Wallet};
 use cdk::util::hex;
 use rand::random;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
 let seed = random::<[u8; 64]>();
 let mint_url = "https://testnut.cashudevkit.org";
 let unit = CurrencyUnit::Sat;

 let localstore = memory::empty().await?;
 let wallet = Wallet::new(mint_url, unit, Arc::new(localstore), seed, None).unwrap();
 let token_raw = hex::decode("6372617742a4617481a261694800ad268c4d1f5826617081a3616101617378403961366462623834376264323332626137366462306466313937323136623239643362386363313435353363643237383237666331636339343266656462346561635821038618543ffb6b8695df4ad4babcde92a34a96bdcd97dcee0d7ccf98d4721267926164695468616e6b20796f75616d75687474703a2f2f6c6f63616c686f73743a33333338617563736174").unwrap();
 let amount_receive = wallet.receive_raw(&token_raw, ReceiveOptions::default()).await?;
 Ok(())
}
Source§

impl Wallet

Source

pub async fn sync_proofs_state(&self, proofs: Proofs) -> Result<(), Error>

Synchronizes the states with the mint

Source§

impl Wallet

Source

pub async fn recover_incomplete_sagas(&self) -> Result<RecoveryReport, Error>

Recover from incomplete operations after a crash. Call on startup.

Handles interrupted swap, send, receive, and melt operations to prevent proofs from being stuck in reserved states. Requires network connection.

Source§

impl Wallet

Source

pub async fn prepare_send( &self, amount: Amount, opts: SendOptions, ) -> Result<PreparedSend<'_>, Error>

Prepare a send transaction

This function prepares a send transaction by selecting proofs to send and proofs to swap. By doing so, it ensures that the wallet user is able to view the fees associated with the send transaction before confirming.

§Example
let prepared = wallet
    .prepare_send(Amount::from(10), SendOptions::default())
    .await?;
println!("Fee: {}", prepared.fee());
let token = prepared.confirm(None).await?;
Source

pub async fn get_pending_sends(&self) -> Result<Vec<Uuid>, Error>

Returns operation IDs for pending sends (tokens created but not claimed).

Source

pub async fn revoke_send(&self, operation_id: Uuid) -> Result<Amount, Error>

Reclaims funds by swapping proofs back to the wallet.

Source

pub async fn check_send_status(&self, operation_id: Uuid) -> Result<bool, Error>

Returns true if the token has been claimed by the recipient.

Source§

impl Wallet

Source

pub async fn wait_and_mint_quote( &self, quote: MintQuote, amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, timeout_duration: Duration, ) -> Result<Proofs, Error>

Mints a mint quote once it is paid

Source

pub fn wait_for_payment( &self, event: &MintQuote, timeout_duration: Duration, ) -> BoxFuture<'_, Result<Option<Amount>, Error>>

Returns a BoxFuture that will wait for payment on the given event with a timeout check

Source§

impl Wallet

Source

pub fn proof_stream( &self, quote: MintQuote, amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> SingleMintQuoteProofStream<'_>

Streams all proofs from a single mint quote

Source

pub fn mints_proof_stream( &self, quotes: Vec<MintQuote>, amount_split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> MultipleMintQuoteProofStream<'_>

Streams all new proofs for a set of mints

Source

pub fn payment_stream<T>(&self, events: T) -> PaymentStream<'_>
where T: Into<WaitableEvent>,

Returns a BoxFuture that will wait for payment on the given event with a timeout check

Source§

impl Wallet

Source

pub async fn swap( &self, amount: Option<Amount>, amount_split_target: SplitTarget, input_proofs: Proofs, spending_conditions: Option<SpendingConditions>, include_fees: bool, use_p2bk: bool, ) -> Result<Option<Proofs>, Error>

Swap proofs using the saga pattern.

This method reserves the input proofs before performing the swap, ensuring they cannot be used by concurrent operations.

Source§

impl Wallet

Source

pub async fn list_transactions( &self, direction: Option<TransactionDirection>, ) -> Result<Vec<Transaction>, Error>

List transactions

Source

pub async fn get_transaction( &self, id: TransactionId, ) -> Result<Option<Transaction>, Error>

Get transaction by ID

Source

pub async fn get_proofs_for_transaction( &self, id: TransactionId, ) -> Result<Proofs, Error>

Get proofs for a transaction by transaction ID

This retrieves all proofs associated with a transaction by looking up the transaction’s Y values and fetching the corresponding proofs.

Source

pub async fn revert_transaction(&self, id: TransactionId) -> Result<(), Error>

Revert a transaction by reclaiming unspent proofs.

For transactions created by the saga pattern (with saga_id set), this function loads the associated send saga and calls revoke() on it, which properly handles the saga lifecycle including state transitions and cleanup.

For legacy transactions (without saga_id), this function checks the proofs with the mint and marks any spent proofs accordingly. Unspent proofs are left in their current state for manual recovery.

§Errors

Returns an error if:

  • The transaction is not found
  • The transaction is not outgoing
  • The saga is not in a revocable state (e.g., already completed)
  • The token has already been claimed by the recipient
Source§

impl Wallet

Source

pub fn new( mint_url: &str, unit: CurrencyUnit, localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>, seed: [u8; 64], target_proof_count: Option<usize>, ) -> Result<Self, Error>

Create new Wallet using the builder pattern

§Synopsis
use std::sync::Arc;

use bitcoin::bip32::Xpriv;
use cdk::nuts::CurrencyUnit;
use cdk::wallet::{Wallet, WalletBuilder};
use cdk_sqlite::wallet::memory;
use rand::random;

async fn test() -> anyhow::Result<()> {
    let seed = random::<[u8; 64]>();
    let mint_url = "https://testnut.cashudevkit.org";
    let unit = CurrencyUnit::Sat;

    let localstore = memory::empty().await?;
    let wallet = WalletBuilder::new()
        .mint_url(mint_url.parse().unwrap())
        .unit(unit)
        .localstore(Arc::new(localstore))
        .seed(seed)
        .build();
    Ok(())
}
Source

pub fn set_rate_limiting_config(&self, config: RateLimitConfig)

Replace the client-side rate-limit configuration at runtime.

Applies to every host the wallet’s limiter paces, not only the mint: the buckets already in use and any created later. That includes third-party hosts the wallet’s transport reaches, such as an LNURL service or an OIDC provider.

It is a no-op when the wallet paces nothing, either because rate limiting was disabled (WalletBuilder::without_rate_limiting) or because a custom client (WalletBuilder::client/WalletBuilder::shared_client) replaced the main transport and no rate-limited auth client remains. With a custom main client plus a CAT it reconfigures only the blind-auth client’s pacing.

When the wallet was built through a WalletRepository, the limiter is shared with every other wallet in that repository, so this reconfigures pacing repository-wide.

Wallet::is_rate_limited reports whether the call took effect, since the no-op cases are otherwise silent.

Source

pub fn disable_rate_limiting(&self)

Disable client-side rate limiting at runtime.

Has the same reach as Wallet::set_rate_limiting_config: every host the wallet’s limiter paces, repository-wide for a repository-built wallet, and a no-op when the wallet paces nothing.

Source

pub fn is_rate_limited(&self) -> bool

Whether this wallet’s requests are being paced right now.

False both when pacing was turned off and when the wallet paces nothing at all, which is the case Wallet::set_rate_limiting_config silently ignores.

Source

pub async fn flush_rate_limits(&self)

Wait until the rate-limit budget this wallet has drawn down has been handed to storage.

Persistence is otherwise best effort: the request path never waits for the store, and dropping a wallet leaves the final write to a detached background task. A caller that does not await this barrier can rebuild the wallet, or tear down the runtime, before that write lands, and the rebuilt wallet then starts with a full burst. Await it before dropping a wallet whose budget must carry over.

The wait is bounded, so a slow or hung store cannot hang shutdown; on timeout the budget is simply not persisted.

Has the same reach as Wallet::set_rate_limiting_config: every host the wallet’s limiter paces, repository-wide for a wallet built through a WalletRepository, and a no-op when the wallet paces nothing.

Source

pub async fn subscribe<T: Into<WalletParams>>( &self, query: T, ) -> Result<ActiveSubscription, Error>

Subscribe to events

Source

pub fn oidc_client( &self, openid_discovery: String, client_id: Option<String>, ) -> OidcClient

Create an OIDC client using this wallet’s mint connector transport.

Source

pub async fn subscribe_mint_quote_state( &self, quote_ids: Vec<String>, method: PaymentMethod, ) -> Result<ActiveSubscription, Error>

Subscribe to mint quote state changes for the given quote IDs and payment method

Source

pub async fn get_proofs_fee( &self, proofs: &Proofs, ) -> Result<ProofsFeeBreakdown, Error>

Fee required to redeem proof set

Source

pub async fn get_proofs_fee_by_count( &self, proofs_per_keyset: HashMap<Id, u64>, ) -> Result<ProofsFeeBreakdown, Error>

Fee required to redeem proof set by count

Source

pub async fn get_keyset_count_fee( &self, keyset_id: &Id, count: u64, ) -> Result<Amount, Error>

Get fee for count of proofs in a keyset

Source

pub async fn get_keyset_count_fee_with_policy( &self, keyset_id: &Id, count: u64, policy: KeysetLoadPolicy, ) -> Result<Amount, Error>

Calculate fee for a given number of proofs using a specific KeysetLoadPolicy.

Source

pub async fn calculate_fee( &self, proof_count: u64, keyset_id: Id, ) -> Result<Amount, Error>

Calculate fee for a given number of proofs with the specified keyset

Source

pub async fn update_mint_url( &mut self, new_mint_url: MintUrl, ) -> Result<(), Error>

Update Mint information and related entries in the event a mint changes its URL

Source

pub async fn fetch_mint_info(&self) -> Result<Option<MintInfo>, Error>

Query mint for current mint information

Source

pub async fn load_mint_info(&self) -> Result<MintInfo, Error>

Load mint info from cache

This is a helper function that loads the mint info from the metadata cache using the configured TTL. Unlike fetch_mint_info(), this does not make a network call if the cache is fresh.

Source

pub async fn restore(&self) -> Result<Restored, Error>

Restore proofs from the mint using the NUT-13 spec defaults (batch size 100, gap 3).

This is a thin wrapper over Wallet::restore_with_opts. Call that directly if you need to override the batch size or gap limit.

Source

pub async fn restore_with_opts( &self, opts: NUT13Options, ) -> Result<Restored, Error>

Restore proofs from the mint using the given NUT13Options.

Scans each keyset in batches of opts.batch_size blinded messages and stops after opts.max_gap consecutive empty batches. Lowering batch_size trades scan latency for a gentler request pattern.

Source

pub async fn verify_token_p2pk( &self, token: &Token, spending_conditions: SpendingConditions, ) -> Result<(), Error>

Verify all proofs in token have meet the required spend Can be used to allow a wallet to accept payments offline while reducing the risk of claiming back to the limits let by the spending_conditions

Source

pub async fn verify_token_dleq(&self, token: &Token) -> Result<(), Error>

Verify all proofs in token have a valid DLEQ proof

Source

pub fn set_client(&mut self, client: Arc<dyn MintConnector + Send + Sync>)

Set the client (MintConnector) for this wallet

This allows updating the connector without recreating the wallet.

Source

pub fn mint_connector(&self) -> Arc<dyn MintConnector + Send + Sync> ⓘ

Get the connector used by this wallet.

Source

pub fn set_target_proof_count(&mut self, count: usize)

Set the target proof count for this wallet

This controls how many proofs of each denomination the wallet tries to maintain.

Source

pub async fn generate_public_key(&self) -> Result<PublicKey, Error>

generates and stores public key in database

Source

pub async fn get_public_key( &self, pubkey: &PublicKey, ) -> Result<Option<P2PKSigningKey>, Error>

gets public key by it’s hex value

Source

pub async fn get_public_keys(&self) -> Result<Vec<P2PKSigningKey>, Error>

gets list of stored public keys in database

Source

pub async fn get_latest_public_key( &self, ) -> Result<Option<P2PKSigningKey>, Error>

Gets the latest generated P2PK signing key (most recently created)

Trait Implementations§

Source§

impl Clone for Wallet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Wallet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Wallet

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Wallet for Wallet

Source§

fn generate_public_key<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PublicKey, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

generates and stores public key in database

Source§

fn get_public_key<'life0, 'life1, 'async_trait>( &'life0 self, pubkey: &'life1 PublicKey, ) -> Pin<Box<dyn Future<Output = Result<Option<P2PKSigningKey>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

gets public key by it’s hex value

Source§

fn get_public_keys<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<P2PKSigningKey>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

gets list of stored public keys in database

Source§

fn get_latest_public_key<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<P2PKSigningKey>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the latest generated P2PK signing key (most recently created)

Source§

fn get_signing_key<'life0, 'life1, 'async_trait>( &'life0 self, pubkey: &'life1 PublicKey, ) -> Pin<Box<dyn Future<Output = Result<Option<SecretKey>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

try to get secret key from p2pk signing key in localstore

Source§

type Error = Error

Error type
Source§

type Amount = Amount

Amount type (e.g. cdk_common::Amount or FFI Amount)
Source§

type MintUrl = MintUrl

Mint URL type
Source§

type CurrencyUnit = CurrencyUnit

Currency unit type
Source§

type MintInfo = MintInfo

Mint info type
Source§

type KeySetInfo = KeySet

Keyset info type
Source§

type MintQuote = MintQuote

Mint quote type
Source§

type MeltQuote = MeltQuote

Melt quote type
Source§

type CrossMintTransferQuote = CrossMintTransferQuote

Cross-mint transfer quote type
Source§

type PaymentMethod = PaymentMethod

Payment method type
Source§

type MeltOptions = MeltOptions

Melt options type
Source§

type OperationId = Uuid

Operation ID type (CDK uses Uuid, FFI uses String)
Source§

type PreparedSend<'a> = PreparedSend<'a>

Prepared send type
Source§

type PreparedMelt<'a> = PreparedMelt<'a>

Prepared melt type
Source§

type Subscription = RemoteActiveConsumer<SubscriptionClient>

Active subscription handle for receiving notifications
Source§

type SubscribeParams = Params<Arc<String>>

Subscribe params type
Source§

type RecoveryReport = RecoveryReport

Saga recovery report type
Source§

fn mint_url(&self) -> MintUrl

Get the mint URL this wallet is connected to
Source§

fn unit(&self) -> CurrencyUnit

Get the currency unit of this wallet
Source§

fn total_balance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Total unspent balance of the wallet
Source§

fn total_pending_balance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Total pending balance of the wallet
Source§

fn total_reserved_balance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Total reserved balance of the wallet
Source§

fn fetch_mint_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<MintInfo>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch mint info from the mint (always makes a network call)
Source§

fn load_mint_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<MintInfo, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load mint info (from cache if fresh, otherwise fetches)
Source§

fn keysets<'life0, 'async_trait>( &'life0 self, policy: KeysetLoadPolicy, ) -> Pin<Box<dyn Future<Output = Result<Vec<KeySet>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all keysets for this wallet’s unit. Read more
Source§

fn active_keyset<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<KeySet, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the active keyset with the lowest fees. Read more
Source§

fn keyset<'life0, 'async_trait>( &'life0 self, keyset_id: Id, ) -> Pin<Box<dyn Future<Output = Result<KeySet, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a single keyset by ID.
Source§

fn get_keyset_fees_and_amounts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<KeysetFeeAndAmounts, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get fees and available amounts for all keysets
Source§

fn get_keyset_count_fee<'life0, 'life1, 'async_trait>( &'life0 self, keyset_id: &'life1 Id, count: u64, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get fee for count of proofs in a keyset
Source§

fn get_keyset_fees_and_amounts_by_id<'life0, 'async_trait>( &'life0 self, keyset_id: Id, ) -> Pin<Box<dyn Future<Output = Result<FeeAndAmounts, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get fees and amounts for a specific keyset ID
Source§

fn mint_quote<'life0, 'async_trait>( &'life0 self, method: PaymentMethod, amount: Option<Amount>, description: Option<String>, extra: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<MintQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a mint quote for the given payment method
Source§

fn melt_quote<'life0, 'async_trait>( &'life0 self, method: PaymentMethod, request: String, options: Option<MeltOptions>, extra: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<MeltQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a melt quote for the given payment method
Source§

fn cross_mint_transfer_quote_max<'life0, 'life1, 'async_trait>( &'life0 self, target_wallet: &'life1 Self, ) -> Pin<Box<dyn Future<Output = Result<CrossMintTransferQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create destination mint and source melt quotes for the maximum amount allowed by the source balance and both mints’ advertised limits. Read more
Source§

fn list_transactions<'life0, 'async_trait>( &'life0 self, direction: Option<TransactionDirection>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List transactions, optionally filtered by direction
Source§

fn get_transaction<'life0, 'async_trait>( &'life0 self, id: TransactionId, ) -> Pin<Box<dyn Future<Output = Result<Option<Transaction>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a transaction by ID
Source§

fn get_proofs_for_transaction<'life0, 'async_trait>( &'life0 self, id: TransactionId, ) -> Pin<Box<dyn Future<Output = Result<Proofs, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get proofs for a transaction by transaction ID
Source§

fn revert_transaction<'life0, 'async_trait>( &'life0 self, id: TransactionId, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Revert a transaction by reclaiming unspent proofs
Source§

fn check_all_pending_proofs<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check all pending proofs and return total amount still pending
Source§

fn recover_incomplete_sagas<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RecoveryReport, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Recover from incomplete operations after a crash
Source§

fn check_proofs_spent<'life0, 'async_trait>( &'life0 self, proofs: Proofs, ) -> Pin<Box<dyn Future<Output = Result<Vec<ProofState>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if proofs are spent
Source§

fn get_keyset_fees_by_id<'life0, 'async_trait>( &'life0 self, keyset_id: Id, ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get fees for a specific keyset ID
Source§

fn calculate_fee<'life0, 'async_trait>( &'life0 self, proof_count: u64, keyset_id: Id, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Calculate fee for a given number of proofs with the specified keyset
Source§

fn receive<'life0, 'life1, 'async_trait>( &'life0 self, encoded_token: &'life1 str, options: ReceiveOptions, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Receive an encoded token
Source§

fn receive_proofs<'life0, 'async_trait>( &'life0 self, proofs: Proofs, options: ReceiveOptions, memo: Option<String>, token: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive proofs directly
Source§

fn prepare_send<'life0, 'async_trait>( &'life0 self, amount: Amount, options: SendOptions, ) -> Pin<Box<dyn Future<Output = Result<PreparedSend<'_>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prepare a send transaction
Source§

fn get_pending_sends<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get pending send operation IDs
Source§

fn revoke_send<'life0, 'async_trait>( &'life0 self, operation_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Revoke a pending send operation
Source§

fn check_send_status<'life0, 'async_trait>( &'life0 self, operation_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a pending send has been claimed
Source§

fn mint<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> Pin<Box<dyn Future<Output = Result<Proofs, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mint tokens for a quote
Source§

fn mint_unissued_quotes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Amount, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check and mint any paid but unissued mint quotes
Source§

fn check_mint_quote_status<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<MintQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check mint quote status
Source§

fn fetch_mint_quote<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, payment_method: Option<PaymentMethod>, ) -> Pin<Box<dyn Future<Output = Result<MintQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a mint quote from the mint and store it locally
Source§

fn fetch_mint_quote_with_key_search<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, payment_method: Option<Self::PaymentMethod>, key_search_limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Self::MintQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a mint quote and try to recover its NUT-20 signing key from the seed. Read more
Source§

fn prepare_melt<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, metadata: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<PreparedMelt<'_>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepare a melt operation
Source§

fn prepare_melt_proofs<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, proofs: Proofs, metadata: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<PreparedMelt<'_>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepare a melt operation with specific proofs
Source§

fn prepare_melt_token<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, quote_id: &'life1 str, encoded_token: &'life2 str, metadata: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<PreparedMelt<'_>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Prepare a melt operation from an encoded token Read more
Source§

fn swap<'life0, 'async_trait>( &'life0 self, amount: Option<Amount>, split_target: SplitTarget, input_proofs: Proofs, spending_conditions: Option<SpendingConditions>, include_fees: bool, use_p2bk: bool, ) -> Pin<Box<dyn Future<Output = Result<Option<Proofs>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Swap proofs
Source§

fn set_cat<'life0, 'async_trait>( &'life0 self, cat: String, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set Clear Auth Token (CAT)
Source§

fn set_refresh_token<'life0, 'async_trait>( &'life0 self, refresh_token: String, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set refresh token
Source§

fn refresh_access_token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Refresh access token using stored refresh token
Source§

fn mint_blind_auth<'life0, 'async_trait>( &'life0 self, amount: Amount, ) -> Pin<Box<dyn Future<Output = Result<Proofs, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mint blind auth tokens
Source§

fn get_unspent_auth_proofs<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuthProof>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get unspent auth proofs
Source§

fn restore<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Restored, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Restore wallet from seed
Source§

fn restore_with_opts<'life0, 'async_trait>( &'life0 self, opts: NUT13Options, ) -> Pin<Box<dyn Future<Output = Result<Restored, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Restore wallet from seed with custom NUT13Options
Source§

fn verify_token_dleq<'life0, 'life1, 'async_trait>( &'life0 self, token_str: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Verify DLEQ proofs in a token
Source§

fn subscribe_mint_quote_state<'life0, 'async_trait>( &'life0 self, quote_ids: Vec<String>, method: PaymentMethod, ) -> Pin<Box<dyn Future<Output = Result<ActiveSubscription, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to mint quote state updates Read more
Source§

fn set_metadata_cache_ttl(&self, ttl_secs: Option<u64>)

Set metadata cache TTL (time-to-live) in seconds Read more
Source§

fn set_rate_limiting_config(&self, config: Option<RateLimitConfig>)

Configure client-side request pacing, or turn it off with None. Read more
Source§

fn is_rate_limited(&self) -> bool

Whether requests from this wallet are being paced right now. Read more
Source§

fn flush_rate_limits<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Wait until the rate-limit budget drawn down so far has been persisted. Read more
Source§

fn subscribe<'life0, 'async_trait>( &'life0 self, params: WalletParams, ) -> Pin<Box<dyn Future<Output = Result<ActiveSubscription, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to wallet events
Source§

fn melt_bip353_quote<'life0, 'life1, 'async_trait>( &'life0 self, bip353_address: &'life1 str, amount_msat: Amount, network: Network, ) -> Pin<Box<dyn Future<Output = Result<MeltQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a melt quote for a BIP353 address
Source§

fn melt_lightning_address_quote<'life0, 'life1, 'async_trait>( &'life0 self, lightning_address: &'life1 str, amount_msat: Amount, ) -> Pin<Box<dyn Future<Output = Result<MeltQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a melt quote for a Lightning address
Source§

fn melt_human_readable_quote<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, amount_msat: Amount, network: Network, ) -> Pin<Box<dyn Future<Output = Result<MeltQuote, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a melt quote for a human-readable address Read more
Source§

fn get_proofs_by_states<'life0, 'async_trait>( &'life0 self, states: Vec<State>, ) -> Pin<Box<dyn Future<Output = Result<Proofs, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get proofs filtered by states Read more
Source§

fn melt_human_readable<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, amount_msat: Self::Amount, network: Network, ) -> Pin<Box<dyn Future<Output = Result<Self::MeltQuote, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get a melt quote for a human-readable address (alias for melt_human_readable_quote)
Source§

fn check_mint_quote<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Self::MintQuote, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Check a mint quote status (alias for check_mint_quote_status)
Source§

fn mint_unified<'life0, 'life1, 'async_trait>( &'life0 self, quote_id: &'life1 str, split_target: SplitTarget, spending_conditions: Option<SpendingConditions>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Proof>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Mint tokens for a quote (alias for mint)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more