Skip to content

Commit 12f4414

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 2867e88 commit 12f4414

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};
@@ -1223,10 +1222,9 @@ impl<D> Wallet<D> {
12231222

12241223
let weighted_utxo = match txout_index.index_of_spk(&txout.script_pubkey) {
12251224
Some(&(keychain, derivation_index)) => {
1226-
#[allow(deprecated)]
12271225
let satisfaction_weight = self
12281226
.get_descriptor_for_keychain(keychain)
1229-
.max_satisfaction_weight()
1227+
.max_weight_to_satisfy()
12301228
.unwrap();
12311229
WeightedUtxo {
12321230
utxo: Utxo::Local(LocalUtxo {
@@ -1244,7 +1242,6 @@ impl<D> Wallet<D> {
12441242
let satisfaction_weight =
12451243
serialize(&txin.script_sig).len() * 4 + serialize(&txin.witness).len();
12461244
WeightedUtxo {
1247-
satisfaction_weight,
12481245
utxo: Utxo::Foreign {
12491246
outpoint: txin.previous_output,
12501247
psbt_input: Box::new(psbt::Input {
@@ -1253,6 +1250,7 @@ impl<D> Wallet<D> {
12531250
..Default::default()
12541251
}),
12551252
},
1253+
satisfaction_weight,
12561254
}
12571255
}
12581256
};
@@ -1556,11 +1554,10 @@ impl<D> Wallet<D> {
15561554
self.list_unspent()
15571555
.map(|utxo| {
15581556
let keychain = utxo.keychain;
1559-
#[allow(deprecated)]
15601557
(
15611558
utxo,
15621559
self.get_descriptor_for_keychain(keychain)
1563-
.max_satisfaction_weight()
1560+
.max_weight_to_satisfy()
15641561
.unwrap(),
15651562
)
15661563
})

crates/bdk/src/wallet/tx_builder.rs

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

288288
for utxo in utxos {
289289
let descriptor = wallet.get_descriptor_for_keychain(utxo.keychain);
290-
#[allow(deprecated)]
291-
let satisfaction_weight = descriptor.max_satisfaction_weight().unwrap();
290+
let satisfaction_weight = descriptor.max_weight_to_satisfy().unwrap();
292291
self.params.utxos.push(WeightedUtxo {
293292
satisfaction_weight,
294293
utxo: Utxo::Local(utxo),
@@ -329,9 +328,10 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
329328
/// causing you to pay a fee that is too high. The party who is broadcasting the transaction can
330329
/// of course check the real input weight matches the expected weight prior to broadcasting.
331330
///
332-
/// To guarantee the `satisfaction_weight` is correct, you can require the party providing the
331+
/// TODO: add notes about the new `max_weight_to_satisfy`
332+
/// To guarantee the `max_weight_to_satisfy` is correct, you can require the party providing the
333333
/// `psbt_input` provide a miniscript descriptor for the input so you can check it against the
334-
/// `script_pubkey` and then ask it for the [`max_satisfaction_weight`].
334+
/// `script_pubkey` and then ask it for the [`max_weight_to_satisfy`].
335335
///
336336
/// This is an **EXPERIMENTAL** feature, API and other major changes are expected.
337337
///
@@ -352,7 +352,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
352352
///
353353
/// [`only_witness_utxo`]: Self::only_witness_utxo
354354
/// [`finish`]: Self::finish
355-
/// [`max_satisfaction_weight`]: miniscript::Descriptor::max_satisfaction_weight
355+
/// [`max_weight_to_satisfy`]: miniscript::Descriptor::max_weight_to_satisfy
356356
pub fn add_foreign_utxo(
357357
&mut self,
358358
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)