Skip to content

Commit

Permalink
feat(electrum): re-export transaction_broadcast method
Browse files Browse the repository at this point in the history
Also: update `wallet_electrum` example to use the method.
  • Loading branch information
evanlinjin committed Jun 4, 2024
1 parent 53fa350 commit 2d2656a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions example-crates/wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit 2d2656a

Please sign in to comment.