Merge bitcoindevkit/bdk-ffi#120: Fix Wallet.broadcast function, now returns a tx id as a hex string
851f61296a16fb9dfbcad00e3e3f11331a56eb12 Fix Wallet.broadcast function, now returns a tx id as a hex string (Steve Myers) Pull request description: ACKs for top commit: thunderbiscuit: Tested ACK 851f612. Tree-SHA512: 86e1d39029924e4fa3a0c21e9f45c1ba0694f4db9d1cfd8dee25a5675d5a8b7851a7c712ce57fb74382a7428fcecbe8ecee4b7b87b9245672bbd6ccea63dfc13
This commit is contained in:
commit
b1d483463f
@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Fix Wallet.broadcast function, now returns a tx id as a hex string
|
||||
|
||||
## [v0.4.0]
|
||||
|
||||
- Add dual license MIT and Apache 2.0
|
||||
|
@ -131,7 +131,7 @@ interface Wallet {
|
||||
[Throws=BdkError]
|
||||
void sync(BdkProgress progress_update, u32? max_address_param);
|
||||
[Throws=BdkError]
|
||||
Transaction broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
|
||||
string broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
|
||||
};
|
||||
|
||||
interface PartiallySignedBitcoinTransaction {
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -1,3 +1,4 @@
|
||||
use bdk::bitcoin::hashes::hex::ToHex;
|
||||
use bdk::bitcoin::secp256k1::Secp256k1;
|
||||
use bdk::bitcoin::util::psbt::PartiallySignedTransaction;
|
||||
use bdk::bitcoin::{Address, Network};
|
||||
@ -201,7 +202,7 @@ impl PartiallySignedBitcoinTransaction {
|
||||
|
||||
impl WalletHolder<AnyBlockchain> for Wallet {
|
||||
fn get_wallet(&self) -> MutexGuard<BdkWallet<AnyBlockchain, AnyDatabase>> {
|
||||
self.wallet_mutex.lock().unwrap()
|
||||
self.wallet_mutex.lock().expect("wallet")
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,11 +266,10 @@ impl Wallet {
|
||||
.sync(BdkProgressHolder { progress_update }, max_address_param)
|
||||
}
|
||||
|
||||
fn broadcast(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result<Transaction, Error> {
|
||||
fn broadcast(&self, psbt: &PartiallySignedBitcoinTransaction) -> Result<String, Error> {
|
||||
let tx = psbt.internal.lock().unwrap().clone().extract_tx();
|
||||
self.get_wallet().broadcast(&tx)?;
|
||||
let tx_details = self.get_wallet().get_tx(&tx.txid(), true)?;
|
||||
Ok(Transaction::from(&tx_details.unwrap()))
|
||||
let txid = self.get_wallet().broadcast(&tx)?;
|
||||
Ok(txid.to_hex())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user