Skip to content

Commit

Permalink
chore(deps): bump bdk wallet & friends to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Jan 5, 2025
1 parent 207944a commit cbd2911
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 360 deletions.
304 changes: 22 additions & 282 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ arbitrary = { version = "1.3.2", features = ["derive"] }
argh = "0.1"
async-trait = "0.1.80"
base64 = "0.22.1"
bdk_bitcoind_rpc = "0.17.1"
bdk_esplora = { version = "0.20.1", features = [
"async-https",
"async-https-rustls",
"tokio",
], default-features = false }
bdk_wallet = "1.0.0"
bincode = "1.3"
bitcoin = { version = "=0.32.5", features = ["serde"] }
borsh = { version = "1.5.0", features = ["derive"] }
Expand Down
9 changes: 3 additions & 6 deletions bin/strata-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ alloy = { version = "0.3.5", features = [
argh.workspace = true
argon2 = "0.5.3"
async-trait.workspace = true
bdk_bitcoind_rpc = "0.16.0"
bdk_esplora = { version = "0.19.0", features = [
"async-https",
"async-https-rustls",
], default-features = false }
bdk_wallet = { version = "1.0.0-beta.5", features = ["rusqlite"] }
bdk_bitcoind_rpc.workspace = true
bdk_esplora.workspace = true
bdk_wallet = { workspace = true, features = ["rusqlite"] }
bip39 = { version = "2.0.0", features = ["all-languages"] }
config = { version = "0.14.0", default-features = false, features = ["toml"] }
console = "0.15.8"
Expand Down
17 changes: 8 additions & 9 deletions bin/strata-cli/src/cmd/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,15 @@ pub async fn deposit(
.copy_from_slice(recovery_script_hash.as_raw_hash().as_byte_array());
op_return_data[MBL + TNHL..].copy_from_slice(strata_address.as_slice());

let mut psbt = l1w
.build_tx()
let mut psbt = {
let mut builder = l1w.build_tx();

Check warning on line 116 in bin/strata-cli/src/cmd/deposit.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/deposit.rs#L115-L116

Added lines #L115 - L116 were not covered by tests
// Important: the deposit won't be found by the sequencer if the order isn't correct.
.ordering(TxOrdering::Untouched)
.add_recipient(bridge_in_address.script_pubkey(), BRIDGE_IN_AMOUNT)
.add_data(&op_return_data)
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid psbt");
builder.ordering(TxOrdering::Untouched);
builder.add_recipient(bridge_in_address.script_pubkey(), BRIDGE_IN_AMOUNT);
builder.add_data(&op_return_data);
builder.fee_rate(fee_rate);
builder.finish().expect("valid psbt")
};

Check warning on line 123 in bin/strata-cli/src/cmd/deposit.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/deposit.rs#L118-L123

Added lines #L118 - L123 were not covered by tests
l1w.sign(&mut psbt, Default::default()).unwrap();
let _ = term.write_line("Built transaction");

Expand Down
15 changes: 7 additions & 8 deletions bin/strata-cli/src/cmd/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ pub async fn drain(
let fee_rate = get_fee_rate(fee_rate, settings.signet_backend.as_ref()).await;
log_fee_rate(&term, &fee_rate);

let mut psbt = l1w
.build_tx()
.drain_wallet()
.drain_to(address.script_pubkey())
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid transaction");
let mut psbt = {
let mut builder = l1w.build_tx();
builder.drain_wallet();
builder.drain_to(address.script_pubkey());
builder.fee_rate(fee_rate);
builder.finish().expect("valid transaction")
};

Check warning on line 82 in bin/strata-cli/src/cmd/drain.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/drain.rs#L76-L82

Added lines #L76 - L82 were not covered by tests
l1w.sign(&mut psbt, Default::default()).unwrap();
let tx = psbt.extract_tx().expect("fully signed tx");
settings.signet_backend.broadcast_tx(&tx).await.unwrap();
Expand Down
29 changes: 20 additions & 9 deletions bin/strata-cli/src/cmd/recover.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use argh::FromArgs;
use bdk_wallet::{
bitcoin::Amount, chain::ChainOracle, descriptor::IntoWalletDescriptor, KeychainKind, Wallet,
bitcoin::Amount,
chain::{ChainOracle, TxUpdate},
descriptor::IntoWalletDescriptor,
KeychainKind, Update, Wallet,
};
use console::{style, Term};

Expand Down Expand Up @@ -76,8 +79,17 @@ pub async fn recover(args: RecoverArgs, seed: Seed, settings: Settings) {
continue;
}

// F***! BDK 1.0 removed the `insert_tx` method, so we have to do this the hard way
// Taken from https://github.com/bitcoindevkit/bdk/pull/1658/commits/3135e291d777d474ab4b76de36d43a96ff104a3c

Check warning on line 83 in bin/strata-cli/src/cmd/recover.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/recover.rs#L82-L83

Added lines #L82 - L83 were not covered by tests
recovery_wallet.transactions().for_each(|tx| {
l1w.insert_tx(tx.tx_node.tx);
l1w.apply_update(Update {
tx_update: TxUpdate {
txs: vec![tx.tx_node.tx],
..Default::default()
},
..Default::default()
})
.expect("could not insert transaction");

Check warning on line 92 in bin/strata-cli/src/cmd/recover.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/recover.rs#L85-L92

Added lines #L85 - L92 were not covered by tests
});

let recover_to = l1w.reveal_next_address(KeychainKind::External).address;
Expand All @@ -88,13 +100,12 @@ pub async fn recover(args: RecoverArgs, seed: Seed, settings: Settings) {
));

// we want to drain the recovery path to the l1 wallet
let mut psbt = recovery_wallet
.build_tx()
.drain_to(recover_to.script_pubkey())
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid tx");
let mut psbt = {
let mut builder = recovery_wallet.build_tx();
builder.drain_to(recover_to.script_pubkey());
builder.fee_rate(fee_rate);
builder.finish().expect("valid tx")
};

Check warning on line 108 in bin/strata-cli/src/cmd/recover.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/recover.rs#L103-L108

Added lines #L103 - L108 were not covered by tests

recovery_wallet
.sign(&mut psbt, Default::default())
Expand Down
13 changes: 6 additions & 7 deletions bin/strata-cli/src/cmd/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ pub async fn send(args: SendArgs, seed: Seed, settings: Settings) {
l1w.sync().await.unwrap();
let fee_rate = get_fee_rate(args.fee_rate, settings.signet_backend.as_ref()).await;
log_fee_rate(&term, &fee_rate);
let mut psbt = l1w
.build_tx()
.add_recipient(address.script_pubkey(), amount)
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid psbt");
let mut psbt = {
let mut builder = l1w.build_tx();
builder.add_recipient(address.script_pubkey(), amount);
builder.fee_rate(fee_rate);
builder.finish().expect("valid psbt")
};

Check warning on line 66 in bin/strata-cli/src/cmd/send.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-cli/src/cmd/send.rs#L61-L66

Added lines #L61 - L66 were not covered by tests
l1w.sign(&mut psbt, Default::default())
.expect("signable psbt");
let tx = psbt.extract_tx().expect("signed tx");
Expand Down
6 changes: 3 additions & 3 deletions bin/strata-cli/src/signet/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use bdk_esplora::EsploraAsyncExt;
use bdk_wallet::{
bitcoin::{consensus::encode, Block, FeeRate, Transaction},
chain::{
spk_client::{FullScanRequestBuilder, FullScanResult, SyncRequestBuilder, SyncResult},
spk_client::{FullScanRequestBuilder, FullScanResponse, SyncRequestBuilder, SyncResponse},
CheckPoint,
},
KeychainKind,
Expand Down Expand Up @@ -65,8 +65,8 @@ pub struct GetFeeRateError(BoxedErr);
boxed_err!(GetFeeRateError);

pub enum WalletUpdate {
SpkSync(SyncResult),
SpkScan(FullScanResult<KeychainKind>),
SpkSync(SyncResponse),
SpkScan(FullScanResponse<KeychainKind>),
NewBlock(BlockEvent<Block>),
MempoolTxs(Vec<(Transaction, u64)>),
}
Expand Down
5 changes: 2 additions & 3 deletions crates/util/python-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ crate-type = ["cdylib"]
[dependencies]
shrex = { version = "0.1.0", path = "../shrex", features = ["serde"] }

bdk_bitcoind_rpc = "0.16.0"
# TODO: once bdk_wallet 1.0 is released, update this and don't change!
bdk_wallet = "1.0.0-beta.5"
bdk_bitcoind_rpc.workspace = true
bdk_wallet.workspace = true
musig2.workspace = true
# "abi3-py310" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.10
pyo3 = { version = "0.22.6", features = ["extension-module", "abi3-py310"] }
Expand Down
47 changes: 22 additions & 25 deletions crates/util/python-utils/src/drt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ fn deposit_request_transaction_inner(
// Before signing the transaction, we need to sync the wallet with bitcoind
sync_wallet(&mut wallet, &client)?;

let mut psbt = wallet
.build_tx()
let mut psbt = {
let mut builder = wallet.build_tx();
// NOTE: the deposit won't be found by the sequencer if the order isn't correct.
.ordering(TxOrdering::Untouched)
.add_recipient(bridge_in_address.script_pubkey(), BRIDGE_IN_AMOUNT)
.add_data(&op_return_data)
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid psbt");
builder.ordering(TxOrdering::Untouched);
builder.add_recipient(bridge_in_address.script_pubkey(), BRIDGE_IN_AMOUNT);
builder.add_data(&op_return_data);
builder.fee_rate(fee_rate);
builder.finish().expect("valid psbt")
};
wallet.sign(&mut psbt, Default::default()).unwrap();

let tx = psbt.extract_tx().expect("valid tx");
Expand Down Expand Up @@ -216,15 +215,14 @@ fn spend_recovery_path_inner(
sync_wallet(&mut wallet, &client)?;

// Spend the recovery path
let mut psbt = wallet
.build_tx()
.policy_path(path, KeychainKind::External)
.drain_wallet()
.drain_to(address_to_send.script_pubkey())
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid psbt");
let mut psbt = {
let mut builder = wallet.build_tx();
builder.policy_path(path, KeychainKind::External);
builder.drain_wallet();
builder.drain_to(address_to_send.script_pubkey());
builder.fee_rate(fee_rate);
builder.finish().expect("valid psbt")
};
wallet.sign(&mut psbt, Default::default()).unwrap();

let tx = psbt.extract_tx().expect("valid tx");
Expand Down Expand Up @@ -669,13 +667,12 @@ mod tests {

// Send 10 BTC to the change address
let amount = Amount::from_btc(10.0).unwrap();
let mut psbt = wallet
.build_tx()
.add_recipient(change_address.script_pubkey(), amount)
.fee_rate(FeeRate::from_sat_per_vb_unchecked(2))
.clone()
.finish()
.unwrap();
let mut psbt = {
let mut builder = wallet.build_tx();
builder.add_recipient(change_address.script_pubkey(), amount);
builder.fee_rate(FeeRate::from_sat_per_vb_unchecked(2));
builder.finish().unwrap()
};
wallet.sign(&mut psbt, Default::default()).unwrap();
let signed_tx = psbt.extract_tx().unwrap();
trace!(?signed_tx, "signed drt tx");
Expand Down
15 changes: 7 additions & 8 deletions crates/util/python-utils/src/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,13 @@ fn drain_wallet_inner(
// Before signing the transaction, we need to sync the wallet with bitcoind
sync_wallet(&mut wallet, &client)?;

let mut psbt = wallet
.build_tx()
.drain_wallet()
.drain_to(address.script_pubkey())
.fee_rate(fee_rate)
.clone()
.finish()
.expect("valid psbt");
let mut psbt = {
let mut builder = wallet.build_tx();
builder.drain_wallet();
builder.drain_to(address.script_pubkey());
builder.fee_rate(fee_rate);
builder.finish().expect("valid psbt")
};

Check warning on line 260 in crates/util/python-utils/src/taproot.rs

View check run for this annotation

Codecov / codecov/patch

crates/util/python-utils/src/taproot.rs#L254-L260

Added lines #L254 - L260 were not covered by tests
wallet
.sign(&mut psbt, Default::default())
.expect("valid psbt");
Expand Down

0 comments on commit cbd2911

Please sign in to comment.