Skip to content

Commit ac42ed3

Browse files
committed
Make max satisfaction API consistent
1 parent 7b6597b commit ac42ed3

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

src/descriptor/segwitv0.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,16 @@ where
214214
}
215215

216216
fn max_satisfaction_weight(&self) -> Option<usize> {
217-
// TODO: Change the max sat functions in sortedmulti for consistency
218217
let (script_size, max_sat_elems, max_sat_size) = match self.inner {
219218
WshInner::SortedMulti(ref smv) => (
220219
smv.script_size(),
221220
smv.max_satisfaction_witness_elements(),
222-
smv.max_satisfaction_size(2), // OP_1 size dummy parameter
221+
smv.max_satisfaction_size(),
223222
),
224223
WshInner::Ms(ref ms) => (
225224
ms.script_size(),
226225
ms.max_satisfaction_witness_elements()?,
227-
ms.max_satisfaction_size()?, // OP_1 size dummy parameter
226+
ms.max_satisfaction_size()?,
228227
),
229228
};
230229
Some(

src/descriptor/sh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ where
309309
ShInner::SortedMulti(ref smv) => {
310310
let ss = smv.script_size();
311311
let ps = push_opcode_size(ss);
312-
let scriptsig_len = ps + ss + smv.max_satisfaction_size(1);
312+
let scriptsig_len = ps + ss + smv.max_satisfaction_size();
313313
4 * (varint_len(scriptsig_len) + scriptsig_len)
314314
}
315315
// add weighted script sig, len byte stays the same

src/descriptor/sortedmulti.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,15 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> SortedMultiVec<Pk, Ctx> {
188188
2 + self.k
189189
}
190190

191-
/// Maximum size, in bytes, of a satisfying witness. For Segwit outputs
192-
/// `one_cost` should be set to 2, since the number `1` requires two
193-
/// bytes to encode. For non-segwit outputs `one_cost` should be set to
194-
/// 1, since `OP_1` is available in scriptSigs.
195-
///
191+
/// Maximum size, in bytes, of a satisfying witness.
196192
/// In general, it is not recommended to use this function directly, but
197193
/// to instead call the corresponding function on a `Descriptor`, which
198194
/// will handle the segwit/non-segwit technicalities for you.
199195
///
200196
/// All signatures are assumed to be 73 bytes in size, including the
201197
/// length prefix (segwit) or push opcode (pre-segwit) and sighash
202198
/// postfix.
203-
///
204-
/// This function may panic on malformed `Miniscript` objects which do not
205-
/// correspond to semantically sane Scripts. (Such scripts should be
206-
/// rejected at parse time. Any exceptions are bugs.)
207-
pub fn max_satisfaction_size(&self, _: usize) -> usize {
199+
pub fn max_satisfaction_size(&self) -> usize {
208200
1 + 73 * self.k
209201
}
210202
}

0 commit comments

Comments
 (0)