]> Untitled Git - bdk/commitdiff
feat(wallet): make `Wallet::insert_tx` generic
author志宇 <hello@evanlinjin.me>
Tue, 3 Sep 2024 05:18:20 +0000 (13:18 +0800)
committer志宇 <hello@evanlinjin.me>
Tue, 3 Sep 2024 06:03:07 +0000 (14:03 +0800)
Instead of having `Transaction` as input, have
`T: Into<Arc<Transaction>>`.

crates/wallet/src/wallet/mod.rs

index 5cad6bb867998c67199b019a17d656307b894773..8513251aebba043a226413ca19bc677a88f5ad85 100644 (file)
@@ -1093,7 +1093,7 @@ impl Wallet {
     /// By default the inserted `tx` won't be considered "canonical" because it's not known
     /// whether the transaction exists in the best chain. To know whether it exists, the tx
     /// must be broadcast to the network and the wallet synced via a chain source.
-    pub fn insert_tx(&mut self, tx: Transaction) -> bool {
+    pub fn insert_tx<T: Into<Arc<Transaction>>>(&mut self, tx: T) -> bool {
         let mut changeset = ChangeSet::default();
         changeset.merge(self.indexed_graph.insert_tx(tx).into());
         let ret = !changeset.is_empty();