Skip to content

Commit 1ef9095

Browse files
committed
fix: remove deprecated `max_satisfaction_weight
- Change deprecated `max_satisfaction_weight` to `max_weight_to_satisfy` - Remove `#[allow(deprecated)]` flags
1 parent f95506b commit 1ef9095

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub mod hardwaresigner;
5656

5757
pub use utils::IsDust;
5858

59-
#[allow(deprecated)]
6059
use coin_selection::DefaultCoinSelectionAlgorithm;
6160
use signer::{SignOptions, SignerOrdering, SignersContainer, TransactionSigner};
6261
use tx_builder::{BumpFee, CreateTx, FeePolicy, TxBuilder, TxParams};
@@ -1286,10 +1285,9 @@ impl<D> Wallet<D> {
12861285

12871286
let weighted_utxo = match txout_index.index_of_spk(&txout.script_pubkey) {
12881287
Some(&(keychain, derivation_index)) => {
1289-
#[allow(deprecated)]
12901288
let satisfaction_weight = self
12911289
.get_descriptor_for_keychain(keychain)
1292-
.max_satisfaction_weight()
1290+
.max_weight_to_satisfy()
12931291
.unwrap();
12941292
WeightedUtxo {
12951293
utxo: Utxo::Local(LocalUtxo {
@@ -1307,7 +1305,6 @@ impl<D> Wallet<D> {
13071305
let satisfaction_weight =
13081306
serialize(&txin.script_sig).len() * 4 + serialize(&txin.witness).len();
13091307
WeightedUtxo {
1310-
satisfaction_weight,
13111308
utxo: Utxo::Foreign {
13121309
outpoint: txin.previous_output,
13131310
psbt_input: Box::new(psbt::Input {
@@ -1316,6 +1313,7 @@ impl<D> Wallet<D> {
13161313
..Default::default()
13171314
}),
13181315
},
1316+
satisfaction_weight,
13191317
}
13201318
}
13211319
};
@@ -1619,11 +1617,10 @@ impl<D> Wallet<D> {
16191617
self.list_unspent()
16201618
.map(|utxo| {
16211619
let keychain = utxo.keychain;
1622-
#[allow(deprecated)]
16231620
(
16241621
utxo,
16251622
self.get_descriptor_for_keychain(keychain)
1626-
.max_satisfaction_weight()
1623+
.max_weight_to_satisfy()
16271624
.unwrap(),
16281625
)
16291626
})

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
295295

296296
for utxo in utxos {
297297
let descriptor = wallet.get_descriptor_for_keychain(utxo.keychain);
298-
#[allow(deprecated)]
299-
let satisfaction_weight = descriptor.max_satisfaction_weight().unwrap();
298+
let satisfaction_weight = descriptor.max_weight_to_satisfy().unwrap();
300299
self.params.utxos.push(WeightedUtxo {
301300
satisfaction_weight,
302301
utxo: Utxo::Local(utxo),
@@ -337,9 +336,10 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
337336
/// causing you to pay a fee that is too high. The party who is broadcasting the transaction can
338337
/// of course check the real input weight matches the expected weight prior to broadcasting.
339338
///
340-
/// To guarantee the `satisfaction_weight` is correct, you can require the party providing the
339+
/// TODO: add notes about the new `max_weight_to_satisfy`
340+
/// To guarantee the `max_weight_to_satisfy` is correct, you can require the party providing the
341341
/// `psbt_input` provide a miniscript descriptor for the input so you can check it against the
342-
/// `script_pubkey` and then ask it for the [`max_satisfaction_weight`].
342+
/// `script_pubkey` and then ask it for the [`max_weight_to_satisfy`].
343343
///
344344
/// This is an **EXPERIMENTAL** feature, API and other major changes are expected.
345345
///
@@ -360,7 +360,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
360360
///
361361
/// [`only_witness_utxo`]: Self::only_witness_utxo
362362
/// [`finish`]: Self::finish
363-
/// [`max_satisfaction_weight`]: miniscript::Descriptor::max_satisfaction_weight
363+
/// [`max_weight_to_satisfy`]: miniscript::Descriptor::max_weight_to_satisfy
364364
pub fn add_foreign_utxo(
365365
&mut self,
366366
outpoint: OutPoint,

crates/bdk/tests/wallet.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,9 @@ fn test_add_foreign_utxo() {
10411041
.unwrap()
10421042
.assume_checked();
10431043
let utxo = wallet2.list_unspent().next().expect("must take!");
1044-
#[allow(deprecated)]
10451044
let foreign_utxo_satisfaction = wallet2
10461045
.get_descriptor_for_keychain(KeychainKind::External)
1047-
.max_satisfaction_weight()
1046+
.max_weight_to_satisfy()
10481047
.unwrap();
10491048

10501049
let psbt_input = psbt::Input {
@@ -1117,10 +1116,9 @@ fn test_calculate_fee_with_missing_foreign_utxo() {
11171116
.unwrap()
11181117
.assume_checked();
11191118
let utxo = wallet2.list_unspent().next().expect("must take!");
1120-
#[allow(deprecated)]
11211119
let foreign_utxo_satisfaction = wallet2
11221120
.get_descriptor_for_keychain(KeychainKind::External)
1123-
.max_satisfaction_weight()
1121+
.max_weight_to_satisfy()
11241122
.unwrap();
11251123

11261124
let psbt_input = psbt::Input {
@@ -1144,10 +1142,9 @@ fn test_calculate_fee_with_missing_foreign_utxo() {
11441142
fn test_add_foreign_utxo_invalid_psbt_input() {
11451143
let (mut wallet, _) = get_funded_wallet(get_test_wpkh());
11461144
let outpoint = wallet.list_unspent().next().expect("must exist").outpoint;
1147-
#[allow(deprecated)]
11481145
let foreign_utxo_satisfaction = wallet
11491146
.get_descriptor_for_keychain(KeychainKind::External)
1150-
.max_satisfaction_weight()
1147+
.max_weight_to_satisfy()
11511148
.unwrap();
11521149

11531150
let mut builder = wallet.build_tx();
@@ -1166,10 +1163,9 @@ fn test_add_foreign_utxo_where_outpoint_doesnt_match_psbt_input() {
11661163
let tx1 = wallet1.get_tx(txid1).unwrap().tx_node.tx.clone();
11671164
let tx2 = wallet2.get_tx(txid2).unwrap().tx_node.tx.clone();
11681165

1169-
#[allow(deprecated)]
11701166
let satisfaction_weight = wallet2
11711167
.get_descriptor_for_keychain(KeychainKind::External)
1172-
.max_satisfaction_weight()
1168+
.max_weight_to_satisfy()
11731169
.unwrap();
11741170

11751171
let mut builder = wallet1.build_tx();
@@ -1211,10 +1207,9 @@ fn test_add_foreign_utxo_only_witness_utxo() {
12111207
.assume_checked();
12121208
let utxo2 = wallet2.list_unspent().next().unwrap();
12131209

1214-
#[allow(deprecated)]
12151210
let satisfaction_weight = wallet2
12161211
.get_descriptor_for_keychain(KeychainKind::External)
1217-
.max_satisfaction_weight()
1212+
.max_weight_to_satisfy()
12181213
.unwrap();
12191214

12201215
let mut builder = wallet1.build_tx();
@@ -2907,10 +2902,9 @@ fn test_taproot_foreign_utxo() {
29072902
.assume_checked();
29082903
let utxo = wallet2.list_unspent().next().unwrap();
29092904
let psbt_input = wallet2.get_psbt_input(utxo.clone(), None, false).unwrap();
2910-
#[allow(deprecated)]
29112905
let foreign_utxo_satisfaction = wallet2
29122906
.get_descriptor_for_keychain(KeychainKind::External)
2913-
.max_satisfaction_weight()
2907+
.max_weight_to_satisfy()
29142908
.unwrap();
29152909

29162910
assert!(

0 commit comments

Comments
 (0)