Make wallet methods take &mut psbt
Rather than consuming it because that is unergonomic.
This commit is contained in:
parent
00f07818f9
commit
5a0c150ff9
@ -13,6 +13,10 @@ Removed `fill_satisfaction` method in favor of enum parameter in `extract_policy
|
|||||||
#### Added
|
#### Added
|
||||||
Timelocks are considered (optionally) in building the `satisfaction` field
|
Timelocks are considered (optionally) in building the `satisfaction` field
|
||||||
|
|
||||||
|
### Wallet
|
||||||
|
|
||||||
|
- Changed `Wallet::{sign, finalize_psbt}` now take a `&mut psbt` rather than consuming it.
|
||||||
|
|
||||||
## [v0.6.0] - [v0.5.1]
|
## [v0.6.0] - [v0.5.1]
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
@ -60,7 +60,7 @@ test-md-docs = ["electrum"]
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bdk-testutils = "0.4"
|
bdk-testutils = "0.4"
|
||||||
bdk-testutils-macros = "0.5"
|
bdk-testutils-macros = { path = "testutils-macros"}
|
||||||
serial_test = "0.4"
|
serial_test = "0.4"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
|
@ -143,9 +143,9 @@ fn main() -> Result<(), bdk::Error> {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let psbt = "...";
|
let psbt = "...";
|
||||||
let psbt = deserialize(&base64::decode(psbt).unwrap())?;
|
let mut psbt = deserialize(&base64::decode(psbt).unwrap())?;
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None)?;
|
let finalized = wallet.sign(&mut psbt, None)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,9 @@
|
|||||||
//! )?;
|
//! )?;
|
||||||
//!
|
//!
|
||||||
//! let psbt = "...";
|
//! let psbt = "...";
|
||||||
//! let psbt = deserialize(&base64::decode(psbt).unwrap())?;
|
//! let mut psbt = deserialize(&base64::decode(psbt).unwrap())?;
|
||||||
//!
|
//!
|
||||||
//! let (signed_psbt, finalized) = wallet.sign(psbt, None)?;
|
//! let finalized = wallet.sign(&mut psbt, None)?;
|
||||||
//!
|
//!
|
||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! }
|
//! }
|
||||||
|
@ -699,24 +699,24 @@ where
|
|||||||
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
||||||
/// # let wallet = doctest_wallet!();
|
/// # let wallet = doctest_wallet!();
|
||||||
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
||||||
/// let (psbt, _) = {
|
/// let (mut psbt, _) = {
|
||||||
/// let mut builder = wallet.build_tx();
|
/// let mut builder = wallet.build_tx();
|
||||||
/// builder
|
/// builder
|
||||||
/// .add_recipient(to_address.script_pubkey(), 50_000)
|
/// .add_recipient(to_address.script_pubkey(), 50_000)
|
||||||
/// .enable_rbf();
|
/// .enable_rbf();
|
||||||
/// builder.finish()?
|
/// builder.finish()?
|
||||||
/// };
|
/// };
|
||||||
/// let (psbt, _) = wallet.sign(psbt, None)?;
|
/// let _ = wallet.sign(&mut psbt, None)?;
|
||||||
/// let tx = psbt.extract_tx();
|
/// let tx = psbt.extract_tx();
|
||||||
/// // broadcast tx but it's taking too long to confirm so we want to bump the fee
|
/// // broadcast tx but it's taking too long to confirm so we want to bump the fee
|
||||||
/// let (psbt, _) = {
|
/// let (mut psbt, _) = {
|
||||||
/// let mut builder = wallet.build_fee_bump(tx.txid())?;
|
/// let mut builder = wallet.build_fee_bump(tx.txid())?;
|
||||||
/// builder
|
/// builder
|
||||||
/// .fee_rate(FeeRate::from_sat_per_vb(5.0));
|
/// .fee_rate(FeeRate::from_sat_per_vb(5.0));
|
||||||
/// builder.finish()?
|
/// builder.finish()?
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// let (psbt, _) = wallet.sign(psbt, None)?;
|
/// let _ = wallet.sign(&mut psbt, None)?;
|
||||||
/// let fee_bumped_tx = psbt.extract_tx();
|
/// let fee_bumped_tx = psbt.extract_tx();
|
||||||
/// // broadcast fee_bumped_tx to replace original
|
/// // broadcast fee_bumped_tx to replace original
|
||||||
/// # Ok::<(), bdk::Error>(())
|
/// # Ok::<(), bdk::Error>(())
|
||||||
@ -843,17 +843,17 @@ where
|
|||||||
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
||||||
/// # let wallet = doctest_wallet!();
|
/// # let wallet = doctest_wallet!();
|
||||||
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
||||||
/// let (psbt, _) = {
|
/// let (mut psbt, _) = {
|
||||||
/// let mut builder = wallet.build_tx();
|
/// let mut builder = wallet.build_tx();
|
||||||
/// builder.add_recipient(to_address.script_pubkey(), 50_000);
|
/// builder.add_recipient(to_address.script_pubkey(), 50_000);
|
||||||
/// builder.finish()?
|
/// builder.finish()?
|
||||||
/// };
|
/// };
|
||||||
/// let (signed_psbt, finalized) = wallet.sign(psbt, None)?;
|
/// let finalized = wallet.sign(&mut psbt, None)?;
|
||||||
/// assert!(finalized, "we should have signed all the inputs");
|
/// assert!(finalized, "we should have signed all the inputs");
|
||||||
/// # Ok::<(), bdk::Error>(())
|
/// # Ok::<(), bdk::Error>(())
|
||||||
pub fn sign(&self, mut psbt: PSBT, assume_height: Option<u32>) -> Result<(PSBT, bool), Error> {
|
pub fn sign(&self, psbt: &mut PSBT, assume_height: Option<u32>) -> Result<bool, Error> {
|
||||||
// this helps us doing our job later
|
// this helps us doing our job later
|
||||||
self.add_input_hd_keypaths(&mut psbt)?;
|
self.add_input_hd_keypaths(psbt)?;
|
||||||
|
|
||||||
for signer in self
|
for signer in self
|
||||||
.signers
|
.signers
|
||||||
@ -862,10 +862,10 @@ where
|
|||||||
.chain(self.change_signers.signers().iter())
|
.chain(self.change_signers.signers().iter())
|
||||||
{
|
{
|
||||||
if signer.sign_whole_tx() {
|
if signer.sign_whole_tx() {
|
||||||
signer.sign(&mut psbt, None, &self.secp)?;
|
signer.sign(psbt, None, &self.secp)?;
|
||||||
} else {
|
} else {
|
||||||
for index in 0..psbt.inputs.len() {
|
for index in 0..psbt.inputs.len() {
|
||||||
signer.sign(&mut psbt, Some(index), &self.secp)?;
|
signer.sign(psbt, Some(index), &self.secp)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -909,9 +909,9 @@ where
|
|||||||
/// Try to finalize a PSBT
|
/// Try to finalize a PSBT
|
||||||
pub fn finalize_psbt(
|
pub fn finalize_psbt(
|
||||||
&self,
|
&self,
|
||||||
mut psbt: PSBT,
|
psbt: &mut PSBT,
|
||||||
assume_height: Option<u32>,
|
assume_height: Option<u32>,
|
||||||
) -> Result<(PSBT, bool), Error> {
|
) -> Result<bool, Error> {
|
||||||
let tx = &psbt.global.unsigned_tx;
|
let tx = &psbt.global.unsigned_tx;
|
||||||
let mut finished = true;
|
let mut finished = true;
|
||||||
|
|
||||||
@ -984,7 +984,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((psbt, finished))
|
Ok(finished)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the secp256k1 context used for all signing operations
|
/// Return the secp256k1 context used for all signing operations
|
||||||
@ -2423,7 +2423,7 @@ mod test {
|
|||||||
.add_recipient(addr.script_pubkey(), 60_000)
|
.add_recipient(addr.script_pubkey(), 60_000)
|
||||||
.add_foreign_utxo(utxo.outpoint, psbt_input, foreign_utxo_satisfaction)
|
.add_foreign_utxo(utxo.outpoint, psbt_input, foreign_utxo_satisfaction)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
details.sent - details.received,
|
details.sent - details.received,
|
||||||
@ -2440,14 +2440,14 @@ mod test {
|
|||||||
"foreign_utxo should be in there"
|
"foreign_utxo should be in there"
|
||||||
);
|
);
|
||||||
|
|
||||||
let (psbt, finished) = wallet1.sign(psbt, None).unwrap();
|
let finished = wallet1.sign(&mut psbt, None).unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
!finished,
|
!finished,
|
||||||
"only one of the inputs should have been signed so far"
|
"only one of the inputs should have been signed so far"
|
||||||
);
|
);
|
||||||
|
|
||||||
let (_, finished) = wallet2.sign(psbt, None).unwrap();
|
let finished = wallet2.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finished, "all the inputs should have been signed now");
|
assert!(finished, "all the inputs should have been signed now");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3466,12 +3466,12 @@ mod test {
|
|||||||
builder
|
builder
|
||||||
.set_single_recipient(addr.script_pubkey())
|
.set_single_recipient(addr.script_pubkey())
|
||||||
.drain_wallet();
|
.drain_wallet();
|
||||||
let (psbt, _) = builder.finish().unwrap();
|
let (mut psbt, _) = builder.finish().unwrap();
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3483,12 +3483,12 @@ mod test {
|
|||||||
builder
|
builder
|
||||||
.set_single_recipient(addr.script_pubkey())
|
.set_single_recipient(addr.script_pubkey())
|
||||||
.drain_wallet();
|
.drain_wallet();
|
||||||
let (psbt, _) = builder.finish().unwrap();
|
let (mut psbt, _) = builder.finish().unwrap();
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3500,12 +3500,12 @@ mod test {
|
|||||||
builder
|
builder
|
||||||
.set_single_recipient(addr.script_pubkey())
|
.set_single_recipient(addr.script_pubkey())
|
||||||
.drain_wallet();
|
.drain_wallet();
|
||||||
let (psbt, _) = builder.finish().unwrap();
|
let (mut psbt, _) = builder.finish().unwrap();
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3517,12 +3517,12 @@ mod test {
|
|||||||
builder
|
builder
|
||||||
.set_single_recipient(addr.script_pubkey())
|
.set_single_recipient(addr.script_pubkey())
|
||||||
.drain_wallet();
|
.drain_wallet();
|
||||||
let (psbt, _) = builder.finish().unwrap();
|
let (mut psbt, _) = builder.finish().unwrap();
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3535,12 +3535,12 @@ mod test {
|
|||||||
builder
|
builder
|
||||||
.set_single_recipient(addr.script_pubkey())
|
.set_single_recipient(addr.script_pubkey())
|
||||||
.drain_wallet();
|
.drain_wallet();
|
||||||
let (psbt, _) = builder.finish().unwrap();
|
let (mut psbt, _) = builder.finish().unwrap();
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3557,10 +3557,10 @@ mod test {
|
|||||||
psbt.inputs[0].bip32_derivation.clear();
|
psbt.inputs[0].bip32_derivation.clear();
|
||||||
assert_eq!(psbt.inputs[0].bip32_derivation.len(), 0);
|
assert_eq!(psbt.inputs[0].bip32_derivation.len(), 0);
|
||||||
|
|
||||||
let (signed_psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert_eq!(finalized, true);
|
assert_eq!(finalized, true);
|
||||||
|
|
||||||
let extracted = signed_psbt.extract_tx();
|
let extracted = psbt.extract_tx();
|
||||||
assert_eq!(extracted.input[0].witness.len(), 2);
|
assert_eq!(extracted.input[0].witness.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3606,7 +3606,7 @@ mod test {
|
|||||||
|
|
||||||
psbt.inputs.push(dud_input);
|
psbt.inputs.push(dud_input);
|
||||||
psbt.global.unsigned_tx.input.push(bitcoin::TxIn::default());
|
psbt.global.unsigned_tx.input.push(bitcoin::TxIn::default());
|
||||||
let (psbt, is_final) = wallet.sign(psbt, None).unwrap();
|
let is_final = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!is_final,
|
!is_final,
|
||||||
"shouldn't be final since we can't sign one of the inputs"
|
"shouldn't be final since we can't sign one of the inputs"
|
||||||
|
@ -297,8 +297,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey(), 25_000);
|
builder.add_recipient(node_addr.script_pubkey(), 25_000);
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
let tx = psbt.extract_tx();
|
let tx = psbt.extract_tx();
|
||||||
println!("{}", bitcoin::consensus::encode::serialize_hex(&tx));
|
println!("{}", bitcoin::consensus::encode::serialize_hex(&tx));
|
||||||
@ -326,8 +326,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey(), 25_000);
|
builder.add_recipient(node_addr.script_pubkey(), 25_000);
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
let sent_txid = wallet.broadcast(psbt.extract_tx()).unwrap();
|
let sent_txid = wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
|
|
||||||
@ -367,8 +367,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey(), 5_000);
|
builder.add_recipient(node_addr.script_pubkey(), 5_000);
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(psbt.extract_tx()).unwrap();
|
wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
|
|
||||||
@ -401,8 +401,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey().clone(), 5_000).enable_rbf();
|
builder.add_recipient(node_addr.script_pubkey().clone(), 5_000).enable_rbf();
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(psbt.extract_tx()).unwrap();
|
wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -411,8 +411,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
||||||
builder.fee_rate(FeeRate::from_sat_per_vb(2.1));
|
builder.fee_rate(FeeRate::from_sat_per_vb(2.1));
|
||||||
let (new_psbt, new_details) = builder.finish().unwrap();
|
let (mut new_psbt, new_details) = builder.finish().unwrap();
|
||||||
let (new_psbt, finalized) = wallet.sign(new_psbt, None).unwrap();
|
let finalized = wallet.sign(&mut new_psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -437,8 +437,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(psbt.extract_tx()).unwrap();
|
wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -447,8 +447,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
||||||
builder.fee_rate(FeeRate::from_sat_per_vb(5.0));
|
builder.fee_rate(FeeRate::from_sat_per_vb(5.0));
|
||||||
let (new_psbt, new_details) = builder.finish().unwrap();
|
let (mut new_psbt, new_details) = builder.finish().unwrap();
|
||||||
let (new_psbt, finalized) = wallet.sign(new_psbt, None).unwrap();
|
let finalized = wallet.sign(&mut new_psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -473,8 +473,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(psbt.extract_tx()).unwrap();
|
wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -483,8 +483,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
||||||
builder.fee_rate(FeeRate::from_sat_per_vb(10.0));
|
builder.fee_rate(FeeRate::from_sat_per_vb(10.0));
|
||||||
let (new_psbt, new_details) = builder.finish().unwrap();
|
let (mut new_psbt, new_details) = builder.finish().unwrap();
|
||||||
let (new_psbt, finalized) = wallet.sign(new_psbt, None).unwrap();
|
let finalized = wallet.sign(&mut new_psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -507,8 +507,8 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_tx();
|
let mut builder = wallet.build_tx();
|
||||||
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
builder.add_recipient(node_addr.script_pubkey().clone(), 49_000).enable_rbf();
|
||||||
let (psbt, details) = builder.finish().unwrap();
|
let (mut psbt, details) = builder.finish().unwrap();
|
||||||
let (psbt, finalized) = wallet.sign(psbt, None).unwrap();
|
let finalized = wallet.sign(&mut psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(psbt.extract_tx()).unwrap();
|
wallet.broadcast(psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
@ -517,10 +517,10 @@ pub fn bdk_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenStream
|
|||||||
|
|
||||||
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
let mut builder = wallet.build_fee_bump(details.txid).unwrap();
|
||||||
builder.fee_rate(FeeRate::from_sat_per_vb(123.0));
|
builder.fee_rate(FeeRate::from_sat_per_vb(123.0));
|
||||||
let (new_psbt, new_details) = builder.finish().unwrap();
|
let (mut new_psbt, new_details) = builder.finish().unwrap();
|
||||||
println!("{:#?}", new_details);
|
println!("{:#?}", new_details);
|
||||||
|
|
||||||
let (new_psbt, finalized) = wallet.sign(new_psbt, None).unwrap();
|
let finalized = wallet.sign(&mut new_psbt, None).unwrap();
|
||||||
assert!(finalized, "Cannot finalize transaction");
|
assert!(finalized, "Cannot finalize transaction");
|
||||||
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
wallet.broadcast(new_psbt.extract_tx()).unwrap();
|
||||||
wallet.sync(noop_progress(), None).unwrap();
|
wallet.sync(noop_progress(), None).unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user