From 7fc76619abc33993e919e9e2c99d95f51f376cc9 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 15 Feb 2024 15:41:02 -0300 Subject: [PATCH] Deprecate across the board max_satisfaction_weight 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. --- src/descriptor/bare.rs | 9 ++++++++- src/descriptor/mod.rs | 6 ++++-- src/descriptor/segwitv0.rs | 9 ++++++++- src/descriptor/sh.rs | 6 ++++-- src/descriptor/tr.rs | 5 ++++- src/psbt/mod.rs | 6 ++++++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/descriptor/bare.rs b/src/descriptor/bare.rs index a72953d3a..9b9de78cc 100644 --- a/src/descriptor/bare.rs +++ b/src/descriptor/bare.rs @@ -83,7 +83,10 @@ impl Bare { /// /// # Errors /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)). - #[deprecated(note = "use max_weight_to_satisfy instead")] + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> Result { let scriptsig_len = self.ms.max_satisfaction_size()?; Ok(4 * (varint_len(scriptsig_len) + scriptsig_len)) @@ -253,6 +256,10 @@ impl Pkh { /// Assumes all ec-signatures are 73 bytes, including push opcode and /// sighash suffix. Includes the weight of the VarInts encoding the /// scriptSig and witness stack length. + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> usize { 4 * (1 + 73 + BareCtx::pk_len(&self.pk)) } } diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index a81a2786e..c5d96016b 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -341,8 +341,10 @@ impl Descriptor { /// /// # Errors /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)). - #[deprecated(note = "use max_weight_to_satisfy instead")] - #[allow(deprecated)] + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> Result { let weight = match *self { Descriptor::Bare(ref bare) => bare.max_satisfaction_weight()?, diff --git a/src/descriptor/segwitv0.rs b/src/descriptor/segwitv0.rs index 6b9cd8a2c..a7455a403 100644 --- a/src/descriptor/segwitv0.rs +++ b/src/descriptor/segwitv0.rs @@ -101,7 +101,10 @@ impl Wsh { /// /// # Errors /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)). - #[deprecated(note = "use max_weight_to_satisfy instead")] + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> Result { let (script_size, max_sat_elems, max_sat_size) = match self.inner { WshInner::SortedMulti(ref smv) => ( @@ -360,6 +363,10 @@ impl Wpkh { /// Assumes all ec-signatures are 73 bytes, including push opcode and /// sighash suffix. Includes the weight of the VarInts encoding the /// scriptSig and witness stack length. + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> usize { 4 + 1 + 73 + Segwitv0::pk_len(&self.pk) } } diff --git a/src/descriptor/sh.rs b/src/descriptor/sh.rs index dfede59da..133fd313d 100644 --- a/src/descriptor/sh.rs +++ b/src/descriptor/sh.rs @@ -232,8 +232,10 @@ impl Sh { /// /// # Errors /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)). - #[deprecated(note = "use max_weight_to_satisfy instead")] - #[allow(deprecated)] + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> Result { Ok(match self.inner { // add weighted script sig, len byte stays the same diff --git a/src/descriptor/tr.rs b/src/descriptor/tr.rs index 2ef33d9a9..e1cb307fe 100644 --- a/src/descriptor/tr.rs +++ b/src/descriptor/tr.rs @@ -309,7 +309,10 @@ impl Tr { /// /// # Errors /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)). - #[deprecated(note = "use max_weight_to_satisfy instead")] + #[deprecated( + since = "10.0.0", + 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." + )] pub fn max_satisfaction_weight(&self) -> Result { let tree = match self.tap_tree() { // key spend path: diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index e72e62a0b..d0ab79179 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -1010,7 +1010,9 @@ trait PsbtFields { fn tap_key_origins( &mut self, ) -> &mut BTreeMap, bip32::KeySource)>; + #[allow(dead_code)] fn proprietary(&mut self) -> &mut BTreeMap>; + #[allow(dead_code)] fn unknown(&mut self) -> &mut BTreeMap>; // `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 { ) -> &mut BTreeMap, bip32::KeySource)> { &mut self.tap_key_origins } + #[allow(dead_code)] fn proprietary(&mut self) -> &mut BTreeMap> { &mut self.proprietary } + #[allow(dead_code)] fn unknown(&mut self) -> &mut BTreeMap> { &mut self.unknown } fn tap_scripts(&mut self) -> Option<&mut BTreeMap> { @@ -1064,9 +1068,11 @@ impl PsbtFields for psbt::Output { ) -> &mut BTreeMap, bip32::KeySource)> { &mut self.tap_key_origins } + #[allow(dead_code)] fn proprietary(&mut self) -> &mut BTreeMap> { &mut self.proprietary } + #[allow(dead_code)] fn unknown(&mut self) -> &mut BTreeMap> { &mut self.unknown } fn tap_tree(&mut self) -> Option<&mut Option> { Some(&mut self.tap_tree) }