]> Untitled Git - bdk/commitdiff
feat(bdk): add `Wallet::list_output` method
author志宇 <hello@evanlinjin.me>
Wed, 1 Nov 2023 05:25:28 +0000 (13:25 +0800)
committer志宇 <hello@evanlinjin.me>
Mon, 20 Nov 2023 20:38:03 +0000 (04:38 +0800)
crates/bdk/src/wallet/mod.rs

index f479330fef1b2415aef1d1c9938cd2e075cdf1f0..a1d834672d5a9f5fe59c54a0db6ad677952e7885 100644 (file)
@@ -748,6 +748,20 @@ impl<D> Wallet<D> {
             .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<Item = LocalOutput> + '_ {
+        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()