From e803ee901002cae4db5ebf3544eb42c6cf81e5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 1 Nov 2023 13:25:28 +0800 Subject: [PATCH] feat(bdk): add `Wallet::list_output` method --- crates/bdk/src/wallet/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs index f479330f..a1d83467 100644 --- a/crates/bdk/src/wallet/mod.rs +++ b/crates/bdk/src/wallet/mod.rs @@ -748,6 +748,20 @@ impl Wallet { .map(|((k, i), full_txo)| new_local_utxo(k, i, full_txo)) } + /// List all relevant outputs (includes both spent and unspent, confirmed and unconfirmed). + /// + /// To list only unspent outputs (UTXOs), use [`Wallet::list_unspent`] instead. + pub fn list_output(&self) -> impl Iterator + '_ { + self.indexed_graph + .graph() + .filter_chain_txouts( + &self.chain, + self.chain.tip().block_id(), + self.indexed_graph.index.outpoints().iter().cloned(), + ) + .map(|((k, i), full_txo)| new_local_utxo(k, i, full_txo)) + } + /// Get all the checkpoints the wallet is currently storing indexed by height. pub fn checkpoints(&self) -> CheckPointIter { self.chain.iter_checkpoints()