mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-21 13:55:45 +01:00
* Split the database trait into read and transactions. The transaction traits will encapsulate all database changes and also expect READ-and-lock operations to read and lock records from the database for exclusive access, thereby avoiding race conditions. The Transaction trait expects a `rollback` operation on Drop unless the transaction has been committed. * fix: melt quote duplicate error This change stops a second melt quote from being created if there is an existing valid melt quote for an invoice already. If the first melt quote has expired then we allow for a new melt quote to be created. --------- Co-authored-by: thesimplekid <tsk@thesimplekid.com>
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
use cdk::nuts::nut00::ProofsMethods;
|
|
use cdk::wallet::multi_mint_wallet::MultiMintWallet;
|
|
|
|
pub async fn check_pending(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
|
|
let wallets = multi_mint_wallet.get_wallets().await;
|
|
|
|
for (i, wallet) in wallets.iter().enumerate() {
|
|
let mint_url = wallet.mint_url.clone();
|
|
println!("{i}: {mint_url}");
|
|
|
|
// Get all pending proofs
|
|
let pending_proofs = wallet.get_pending_proofs().await?;
|
|
if pending_proofs.is_empty() {
|
|
println!("No pending proofs found");
|
|
continue;
|
|
}
|
|
|
|
println!(
|
|
"Found {} pending proofs with {} {}",
|
|
pending_proofs.len(),
|
|
pending_proofs.total_amount()?,
|
|
wallet.unit
|
|
);
|
|
|
|
// Try to reclaim any proofs that are no longer pending
|
|
match wallet.reclaim_unspent(pending_proofs).await {
|
|
Ok(()) => println!("Successfully reclaimed pending proofs"),
|
|
Err(e) => println!("Error reclaimed pending proofs: {e}"),
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|