@@ -172,6 +172,36 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
172
172
}
173
173
len
174
174
}
175
+
176
+ /// Maximum number of witness elements used to satisfy the Miniscript
177
+ /// fragment, including the witness script itself. Used to estimate
178
+ /// the weight of the `VarInt` that specifies this number in a serialized
179
+ /// transaction.
180
+ ///
181
+ /// This function may returns Error when the Miniscript is
182
+ /// impossible to satisfy
183
+ pub fn max_satisfaction_witness_elements ( & self ) -> Result < usize , Error > {
184
+ self . ext
185
+ . stack_elem_count_sat
186
+ . map ( |x| x + 1 )
187
+ . ok_or ( Error :: ImpossibleSatisfaction )
188
+ }
189
+
190
+ /// Maximum size, in bytes, of a satisfying witness. For Segwit outputs
191
+ /// `one_cost` should be set to 2, since the number `1` requires two
192
+ /// bytes to encode. For non-segwit outputs `one_cost` should be set to
193
+ /// 1, since `OP_1` is available in scriptSigs.
194
+ ///
195
+ /// In general, it is not recommended to use this function directly, but
196
+ /// to instead call the corresponding function on a `Descriptor`, which
197
+ /// will handle the segwit/non-segwit technicalities for you.
198
+ ///
199
+ /// All signatures are assumed to be 73 bytes in size, including the
200
+ /// length prefix (segwit) or push opcode (pre-segwit) and sighash
201
+ /// postfix.
202
+ pub fn max_satisfaction_size ( & self ) -> Result < usize , Error > {
203
+ Ctx :: max_satisfaction_size ( self ) . ok_or ( Error :: ImpossibleSatisfaction )
204
+ }
175
205
}
176
206
177
207
/// `PartialOrd` of `Miniscript` must depend only on node and not the type information.
@@ -306,38 +336,6 @@ impl<Ctx: ScriptContext> Miniscript<Ctx::Key, Ctx> {
306
336
}
307
337
}
308
338
309
- impl < Pk : MiniscriptKey , Ctx : ScriptContext > Miniscript < Pk , Ctx > {
310
- /// Maximum number of witness elements used to satisfy the Miniscript
311
- /// fragment, including the witness script itself. Used to estimate
312
- /// the weight of the `VarInt` that specifies this number in a serialized
313
- /// transaction.
314
- ///
315
- /// This function may returns Error when the Miniscript is
316
- /// impossible to satisfy
317
- pub fn max_satisfaction_witness_elements ( & self ) -> Result < usize , Error > {
318
- self . ext
319
- . stack_elem_count_sat
320
- . map ( |x| x + 1 )
321
- . ok_or ( Error :: ImpossibleSatisfaction )
322
- }
323
-
324
- /// Maximum size, in bytes, of a satisfying witness. For Segwit outputs
325
- /// `one_cost` should be set to 2, since the number `1` requires two
326
- /// bytes to encode. For non-segwit outputs `one_cost` should be set to
327
- /// 1, since `OP_1` is available in scriptSigs.
328
- ///
329
- /// In general, it is not recommended to use this function directly, but
330
- /// to instead call the corresponding function on a `Descriptor`, which
331
- /// will handle the segwit/non-segwit technicalities for you.
332
- ///
333
- /// All signatures are assumed to be 73 bytes in size, including the
334
- /// length prefix (segwit) or push opcode (pre-segwit) and sighash
335
- /// postfix.
336
- pub fn max_satisfaction_size ( & self ) -> Result < usize , Error > {
337
- Ctx :: max_satisfaction_size ( self ) . ok_or ( Error :: ImpossibleSatisfaction )
338
- }
339
- }
340
-
341
339
impl < Pk : MiniscriptKey , Ctx : ScriptContext > ForEachKey < Pk > for Miniscript < Pk , Ctx > {
342
340
fn for_each_key < ' a , F : FnMut ( & ' a Pk ) -> bool > ( & ' a self , mut pred : F ) -> bool {
343
341
for ms in self . pre_order_iter ( ) {
0 commit comments