From 11ba16ec1bec922e5ffd7fcf3903eec9caf227e7 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Fri, 22 Apr 2022 14:10:00 -0700 Subject: [PATCH] Move txid getter to PartiallySignedBitcoinTransaction --- src/bdk.udl | 3 ++- src/lib.rs | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bdk.udl b/src/bdk.udl index 61f5f9f..5429127 100644 --- a/src/bdk.udl +++ b/src/bdk.udl @@ -116,7 +116,7 @@ interface Blockchain { [Throws=BdkError] constructor(BlockchainConfig config); [Throws=BdkError] - string broadcast([ByRef] PartiallySignedBitcoinTransaction psbt); + void broadcast([ByRef] PartiallySignedBitcoinTransaction psbt); }; callback interface Progress { @@ -143,6 +143,7 @@ interface PartiallySignedBitcoinTransaction { [Throws=BdkError] constructor(string psbt_base64); string serialize(); + string txid(); }; interface TxBuilder { diff --git a/src/lib.rs b/src/lib.rs index e1db46c..caa1396 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,12 +133,9 @@ impl Blockchain { self.blockchain_mutex.lock().expect("blockchain") } - fn broadcast(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result { + fn broadcast(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result<(), Error> { let tx = psbt.internal.lock().unwrap().clone().extract_tx(); - self.get_blockchain().broadcast(&tx)?; - // TODO move txid getter to PartiallySignedBitcoinTransaction - let txid = tx.txid(); - Ok(txid.to_hex()) + self.get_blockchain().broadcast(&tx) } } @@ -184,6 +181,12 @@ impl PartiallySignedBitcoinTransaction { let psbt = self.internal.lock().unwrap().clone(); psbt.to_string() } + + fn txid(&self) -> String { + let tx = self.internal.lock().unwrap().clone().extract_tx(); + let txid = tx.txid(); + txid.to_hex() + } } impl Wallet { @@ -220,8 +223,6 @@ impl Wallet { &self, blockchain: &Blockchain, progress: Option>, - //progress_update: Box, - //max_address_param: Option, ) -> Result<(), BdkError> { let bdk_sync_opts = BdkSyncOptions { progress: progress.map(|p| {