Skip to content

Commit d589fe9

Browse files
committed
Merge #436: Remove ToPublicKey bound for max_satisfaction_weight
edf7587 Remove ToPublicKey bound for max_satisfaction_weight (eunoia_1729) Pull request description: Resolves: #432 ACKs for top commit: SarcasticNastik: ACK edf7587 apoelstra: ACK edf7587 sanket1729: ACK edf7587 Tree-SHA512: 57ca26abf31d5022ded5f7ca82f652605794a1c9f0d6b483158018865f4815d8298621ecd0e90af59bfebb70095a039f83b2873b0d245864b2fece480c648c65
2 parents f6dc945 + edf7587 commit d589fe9

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/descriptor/mod.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,27 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
316316
Descriptor::Tr(ref tr) => tr.sanity_check(),
317317
}
318318
}
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+
}
319340
}
320341

321342
impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
@@ -447,27 +468,6 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
447468
txin.script_sig = script_sig;
448469
Ok(())
449470
}
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-
}
471471
}
472472

473473
impl<P, Q> TranslatePk<P, Q> for Descriptor<P>

0 commit comments

Comments
 (0)