Skip to content

Commit 3426ca5

Browse files
committed
Merge #638: Deprecate across the board max_satisfaction_weight
7fc7661 Deprecate across the board max_satisfaction_weight (Jose Storopoli) Pull request description: Adds a `since=10.0.0` to all `max_satisfaction_weight` deprecations. Adds a note telling users to check #476 for more details. Closes #637. ACKs for top commit: apoelstra: ACK 7fc7661 tcharding: ACK 7fc7661 Tree-SHA512: 90a75bd44d5b0bec5044fc58186323f6c992e43958a912d9d36a1bda411ef6156076ac2125ee6dc8806a742b0aef046ae1f540911301972c8c2f95bb02ec8980
2 parents f1211c7 + 7fc7661 commit 3426ca5

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

src/descriptor/bare.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
8383
///
8484
/// # Errors
8585
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
86-
#[deprecated(note = "use max_weight_to_satisfy instead")]
86+
#[deprecated(
87+
since = "10.0.0",
88+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
89+
)]
8790
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
8891
let scriptsig_len = self.ms.max_satisfaction_size()?;
8992
Ok(4 * (varint_len(scriptsig_len) + scriptsig_len))
@@ -253,6 +256,10 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
253256
/// Assumes all ec-signatures are 73 bytes, including push opcode and
254257
/// sighash suffix. Includes the weight of the VarInts encoding the
255258
/// scriptSig and witness stack length.
259+
#[deprecated(
260+
since = "10.0.0",
261+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
262+
)]
256263
pub fn max_satisfaction_weight(&self) -> usize { 4 * (1 + 73 + BareCtx::pk_len(&self.pk)) }
257264
}
258265

src/descriptor/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
341341
///
342342
/// # Errors
343343
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
344-
#[deprecated(note = "use max_weight_to_satisfy instead")]
345-
#[allow(deprecated)]
344+
#[deprecated(
345+
since = "10.0.0",
346+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
347+
)]
346348
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
347349
let weight = match *self {
348350
Descriptor::Bare(ref bare) => bare.max_satisfaction_weight()?,

src/descriptor/segwitv0.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ impl<Pk: MiniscriptKey> Wsh<Pk> {
101101
///
102102
/// # Errors
103103
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
104-
#[deprecated(note = "use max_weight_to_satisfy instead")]
104+
#[deprecated(
105+
since = "10.0.0",
106+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
107+
)]
105108
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
106109
let (script_size, max_sat_elems, max_sat_size) = match self.inner {
107110
WshInner::SortedMulti(ref smv) => (
@@ -360,6 +363,10 @@ impl<Pk: MiniscriptKey> Wpkh<Pk> {
360363
/// Assumes all ec-signatures are 73 bytes, including push opcode and
361364
/// sighash suffix. Includes the weight of the VarInts encoding the
362365
/// scriptSig and witness stack length.
366+
#[deprecated(
367+
since = "10.0.0",
368+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
369+
)]
363370
pub fn max_satisfaction_weight(&self) -> usize { 4 + 1 + 73 + Segwitv0::pk_len(&self.pk) }
364371
}
365372

src/descriptor/sh.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ impl<Pk: MiniscriptKey> Sh<Pk> {
232232
///
233233
/// # Errors
234234
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
235-
#[deprecated(note = "use max_weight_to_satisfy instead")]
236-
#[allow(deprecated)]
235+
#[deprecated(
236+
since = "10.0.0",
237+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
238+
)]
237239
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
238240
Ok(match self.inner {
239241
// add weighted script sig, len byte stays the same

src/descriptor/tr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
309309
///
310310
/// # Errors
311311
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
312-
#[deprecated(note = "use max_weight_to_satisfy instead")]
312+
#[deprecated(
313+
since = "10.0.0",
314+
note = "Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476."
315+
)]
313316
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
314317
let tree = match self.tap_tree() {
315318
// key spend path:

src/psbt/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,9 @@ trait PsbtFields {
10101010
fn tap_key_origins(
10111011
&mut self,
10121012
) -> &mut BTreeMap<bitcoin::key::XOnlyPublicKey, (Vec<TapLeafHash>, bip32::KeySource)>;
1013+
#[allow(dead_code)]
10131014
fn proprietary(&mut self) -> &mut BTreeMap<psbt::raw::ProprietaryKey, Vec<u8>>;
1015+
#[allow(dead_code)]
10141016
fn unknown(&mut self) -> &mut BTreeMap<psbt::raw::Key, Vec<u8>>;
10151017

10161018
// `tap_tree` only appears in psbt::Output, so it's returned as an option of a mutable ref
@@ -1037,9 +1039,11 @@ impl PsbtFields for psbt::Input {
10371039
) -> &mut BTreeMap<bitcoin::key::XOnlyPublicKey, (Vec<TapLeafHash>, bip32::KeySource)> {
10381040
&mut self.tap_key_origins
10391041
}
1042+
#[allow(dead_code)]
10401043
fn proprietary(&mut self) -> &mut BTreeMap<psbt::raw::ProprietaryKey, Vec<u8>> {
10411044
&mut self.proprietary
10421045
}
1046+
#[allow(dead_code)]
10431047
fn unknown(&mut self) -> &mut BTreeMap<psbt::raw::Key, Vec<u8>> { &mut self.unknown }
10441048

10451049
fn tap_scripts(&mut self) -> Option<&mut BTreeMap<ControlBlock, (ScriptBuf, LeafVersion)>> {
@@ -1064,9 +1068,11 @@ impl PsbtFields for psbt::Output {
10641068
) -> &mut BTreeMap<bitcoin::key::XOnlyPublicKey, (Vec<TapLeafHash>, bip32::KeySource)> {
10651069
&mut self.tap_key_origins
10661070
}
1071+
#[allow(dead_code)]
10671072
fn proprietary(&mut self) -> &mut BTreeMap<psbt::raw::ProprietaryKey, Vec<u8>> {
10681073
&mut self.proprietary
10691074
}
1075+
#[allow(dead_code)]
10701076
fn unknown(&mut self) -> &mut BTreeMap<psbt::raw::Key, Vec<u8>> { &mut self.unknown }
10711077

10721078
fn tap_tree(&mut self) -> Option<&mut Option<taproot::TapTree>> { Some(&mut self.tap_tree) }

0 commit comments

Comments
 (0)