@@ -316,6 +316,27 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
316
316
Descriptor :: Tr ( ref tr) => tr. sanity_check ( ) ,
317
317
}
318
318
}
319
+
320
+ /// Computes an upper bound on the weight of a satisfying witness to the
321
+ /// transaction.
322
+ ///
323
+ /// Assumes all ec-signatures are 73 bytes, including push opcode and
324
+ /// sighash suffix. Includes the weight of the VarInts encoding the
325
+ /// scriptSig and witness stack length.
326
+ ///
327
+ /// # Errors
328
+ /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
329
+ pub fn max_satisfaction_weight ( & self ) -> Result < usize , Error > {
330
+ let weight = match * self {
331
+ Descriptor :: Bare ( ref bare) => bare. max_satisfaction_weight ( ) ?,
332
+ Descriptor :: Pkh ( ref pkh) => pkh. max_satisfaction_weight ( ) ,
333
+ Descriptor :: Wpkh ( ref wpkh) => wpkh. max_satisfaction_weight ( ) ,
334
+ Descriptor :: Wsh ( ref wsh) => wsh. max_satisfaction_weight ( ) ?,
335
+ Descriptor :: Sh ( ref sh) => sh. max_satisfaction_weight ( ) ?,
336
+ Descriptor :: Tr ( ref tr) => tr. max_satisfaction_weight ( ) ?,
337
+ } ;
338
+ Ok ( weight)
339
+ }
319
340
}
320
341
321
342
impl < Pk : MiniscriptKey + ToPublicKey > Descriptor < Pk > {
@@ -447,27 +468,6 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
447
468
txin. script_sig = script_sig;
448
469
Ok ( ( ) )
449
470
}
450
-
451
- /// Computes an upper bound on the weight of a satisfying witness to the
452
- /// transaction.
453
- ///
454
- /// Assumes all ec-signatures are 73 bytes, including push opcode and
455
- /// sighash suffix. Includes the weight of the VarInts encoding the
456
- /// scriptSig and witness stack length.
457
- ///
458
- /// # Errors
459
- /// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
460
- pub fn max_satisfaction_weight ( & self ) -> Result < usize , Error > {
461
- let weight = match * self {
462
- Descriptor :: Bare ( ref bare) => bare. max_satisfaction_weight ( ) ?,
463
- Descriptor :: Pkh ( ref pkh) => pkh. max_satisfaction_weight ( ) ,
464
- Descriptor :: Wpkh ( ref wpkh) => wpkh. max_satisfaction_weight ( ) ,
465
- Descriptor :: Wsh ( ref wsh) => wsh. max_satisfaction_weight ( ) ?,
466
- Descriptor :: Sh ( ref sh) => sh. max_satisfaction_weight ( ) ?,
467
- Descriptor :: Tr ( ref tr) => tr. max_satisfaction_weight ( ) ?,
468
- } ;
469
- Ok ( weight)
470
- }
471
471
}
472
472
473
473
impl < P , Q > TranslatePk < P , Q > for Descriptor < P >
0 commit comments