|
@@ -1,5 +1,3 @@
|
|
|
-use std::collections::BTreeMap;
|
|
|
-
|
|
|
use anyhow::Result;
|
|
|
use cdk::mint_url::MintUrl;
|
|
|
use cdk::nuts::{CurrencyUnit, Proof};
|
|
@@ -13,27 +11,57 @@ pub async fn proofs(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
|
|
|
async fn list_proofs(
|
|
|
multi_mint_wallet: &MultiMintWallet,
|
|
|
) -> Result<Vec<(MintUrl, (Vec<Proof>, CurrencyUnit))>> {
|
|
|
- let wallets_proofs: BTreeMap<MintUrl, (Vec<Proof>, CurrencyUnit)> =
|
|
|
- multi_mint_wallet.list_proofs().await?;
|
|
|
+ let mut proofs_vec = Vec::new();
|
|
|
|
|
|
- let mut proofs_vec = Vec::with_capacity(wallets_proofs.len());
|
|
|
+ let wallets = multi_mint_wallet.get_wallets().await;
|
|
|
|
|
|
- for (i, (mint_url, proofs)) in wallets_proofs.iter().enumerate() {
|
|
|
- let mint_url = mint_url.clone();
|
|
|
+ for (i, wallet) in wallets.iter().enumerate() {
|
|
|
+ let mint_url = wallet.mint_url.clone();
|
|
|
println!("{i}: {mint_url}");
|
|
|
- println!("| Amount | Unit | Secret | DLEQ proof included");
|
|
|
- println!("|----------|------|------------------------------------------------------------------|--------------------");
|
|
|
- for proof in &proofs.0 {
|
|
|
+ println!("| Amount | Unit | State | Secret | DLEQ proof included");
|
|
|
+ println!("|----------|------|----------|------------------------------------------------------------------|--------------------");
|
|
|
+
|
|
|
+ // Unspent proofs
|
|
|
+ let unspent_proofs = wallet.get_unspent_proofs().await?;
|
|
|
+ for proof in unspent_proofs.iter() {
|
|
|
+ println!(
|
|
|
+ "| {:8} | {:4} | {:8} | {:64} | {}",
|
|
|
+ proof.amount,
|
|
|
+ wallet.unit,
|
|
|
+ "unspent",
|
|
|
+ proof.secret,
|
|
|
+ proof.dleq.is_some()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // Pending proofs
|
|
|
+ let pending_proofs = wallet.get_pending_proofs().await?;
|
|
|
+ for proof in pending_proofs {
|
|
|
println!(
|
|
|
- "| {:8} | {:4} | {:64} | {}",
|
|
|
+ "| {:8} | {:4} | {:8} | {:64} | {}",
|
|
|
proof.amount,
|
|
|
- proofs.1,
|
|
|
+ wallet.unit,
|
|
|
+ "pending",
|
|
|
proof.secret,
|
|
|
proof.dleq.is_some()
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ // Reserved proofs
|
|
|
+ let reserved_proofs = wallet.get_reserved_proofs().await?;
|
|
|
+ for proof in reserved_proofs {
|
|
|
+ println!(
|
|
|
+ "| {:8} | {:4} | {:8} | {:64} | {}",
|
|
|
+ proof.amount,
|
|
|
+ wallet.unit,
|
|
|
+ "reserved",
|
|
|
+ proof.secret,
|
|
|
+ proof.dleq.is_some()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
println!();
|
|
|
- proofs_vec.push((mint_url, proofs.clone()))
|
|
|
+ proofs_vec.push((mint_url, (unspent_proofs, wallet.unit.clone())));
|
|
|
}
|
|
|
Ok(proofs_vec)
|
|
|
}
|