]> Untitled Git - bdk/commitdiff
feat(electrum): re-export `transaction_broadcast` method
author志宇 <hello@evanlinjin.me>
Tue, 4 Jun 2024 03:59:39 +0000 (11:59 +0800)
committer志宇 <hello@evanlinjin.me>
Tue, 4 Jun 2024 04:24:41 +0000 (12:24 +0800)
Also: update `wallet_electrum` example to use the method.

crates/electrum/src/bdk_electrum_client.rs
example-crates/wallet_electrum/src/main.rs

index 17480cc5706b632c6e6d19d244a7d324186b2ce6..5f7d59b22ac1269cff8cd03811ce4debf6438170 100644 (file)
@@ -65,6 +65,13 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
         Ok(tx)
     }
 
+    /// Broadcasts a transaction to the network.
+    ///
+    /// This is a re-export of [`ElectrumApi::transaction_broadcast`].
+    pub fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error> {
+        self.inner.transaction_broadcast(tx)
+    }
+
     /// Full scan the keychain scripts specified with the blockchain (via an Electrum client) and
     /// returns updates for [`bdk_chain`] data structures.
     ///
index 017902c8ac7dd4f87c146f011e95aa07b93d823e..73a75184b56c315c9d98de859eb30327c9c62625 100644 (file)
@@ -6,7 +6,7 @@ const BATCH_SIZE: usize = 5;
 use std::io::Write;
 use std::str::FromStr;
 
-use bdk_electrum::electrum_client::{self, ElectrumApi};
+use bdk_electrum::electrum_client;
 use bdk_electrum::BdkElectrumClient;
 use bdk_file_store::Store;
 use bdk_wallet::bitcoin::{Address, Amount};
@@ -93,7 +93,7 @@ fn main() -> Result<(), anyhow::Error> {
     assert!(finalized);
 
     let tx = psbt.extract_tx()?;
-    client.inner.transaction_broadcast(&tx)?;
+    client.transaction_broadcast(&tx)?;
     println!("Tx broadcasted! Txid: {}", tx.txid());
 
     Ok(())