Skip to content

Commit b656b87

Browse files
committed
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.
1 parent 469c113 commit b656b87

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-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:

0 commit comments

Comments
 (0)