@@ -127,21 +127,6 @@ pub struct Older(pub u32);
127127
128128impl < ToPkCtx : Copy , Pk : MiniscriptKey + ToPublicKey < ToPkCtx > > Satisfier < ToPkCtx , Pk > for Older {
129129 fn check_older ( & self , n : u32 ) -> bool {
130- // if n > self.0; we will be returning false anyways
131- if n < HEIGHT_TIME_THRESHOLD && self . 0 >= HEIGHT_TIME_THRESHOLD {
132- false
133- } else {
134- n <= self . 0
135- }
136- }
137- }
138-
139- /// Newtype around `u32` which implements `Satisfier` using `n` as an
140- /// absolute locktime
141- pub struct After ( pub u32 ) ;
142-
143- impl < ToPkCtx : Copy , Pk : MiniscriptKey + ToPublicKey < ToPkCtx > > Satisfier < ToPkCtx , Pk > for After {
144- fn check_after ( & self , n : u32 ) -> bool {
145130 if self . 0 & SEQUENCE_LOCKTIME_DISABLE_FLAG != 0 {
146131 return true ;
147132 }
@@ -161,6 +146,21 @@ impl<ToPkCtx: Copy, Pk: MiniscriptKey + ToPublicKey<ToPkCtx>> Satisfier<ToPkCtx,
161146 }
162147}
163148
149+ /// Newtype around `u32` which implements `Satisfier` using `n` as an
150+ /// absolute locktime
151+ pub struct After ( pub u32 ) ;
152+
153+ impl < ToPkCtx : Copy , Pk : MiniscriptKey + ToPublicKey < ToPkCtx > > Satisfier < ToPkCtx , Pk > for After {
154+ fn check_after ( & self , n : u32 ) -> bool {
155+ // if n > self.0; we will be returning false anyways
156+ if n < HEIGHT_TIME_THRESHOLD && self . 0 >= HEIGHT_TIME_THRESHOLD {
157+ false
158+ } else {
159+ n <= self . 0
160+ }
161+ }
162+ }
163+
164164impl < ToPkCtx : Copy , Pk : MiniscriptKey + ToPublicKey < ToPkCtx > > Satisfier < ToPkCtx , Pk >
165165 for HashMap < Pk , BitcoinSig >
166166{
@@ -627,9 +627,9 @@ impl Satisfaction {
627627 sat_indices. sort_by_key ( |& i| {
628628 let stack_weight = match ( & sats[ i] . stack , & ret_stack[ i] . stack ) {
629629 ( & Witness :: Unavailable , _) | ( & Witness :: Impossible , _) => i64:: MAX ,
630- ( _ , & Witness :: Unavailable ) | ( _ , & Witness :: Impossible ) => {
631- unreachable ! ( "Threshold fragments must be 'd'" )
632- }
630+ // This can only be the case when we have PkH without the corresponding
631+ // Pubkey.
632+ ( _ , & Witness :: Unavailable ) | ( _ , & Witness :: Impossible ) => i64 :: MIN ,
633633 ( & Witness :: Stack ( ref s) , & Witness :: Stack ( ref d) ) => {
634634 witness_size ( s) as i64 - witness_size ( d) as i64
635635 }
@@ -669,7 +669,9 @@ impl Satisfaction {
669669 // For example, the fragment thresh(2, hash, hash, 0, 0)
670670 // is uniquely satisfyiable because there is no satisfaction
671671 // for the 0 fragment
672- else if !sats[ sat_indices[ k] ] . has_sig && sats[ sat_indices[ k] ] . stack != Witness :: Impossible
672+ else if k < sat_indices. len ( )
673+ && !sats[ sat_indices[ k] ] . has_sig
674+ && sats[ sat_indices[ k] ] . stack != Witness :: Impossible
673675 {
674676 // All arguments should be `d`, so dissatisfactions have no
675677 // signatures; and in this branch we assume too many weak
@@ -744,9 +746,8 @@ impl Satisfaction {
744746 sat_indices. sort_by_key ( |& i| {
745747 let stack_weight = match ( & sats[ i] . stack , & ret_stack[ i] . stack ) {
746748 ( & Witness :: Unavailable , _) | ( & Witness :: Impossible , _) => i64:: MAX ,
747- ( _, & Witness :: Unavailable ) | ( _, & Witness :: Impossible ) => {
748- unreachable ! ( "Threshold fragments must be 'd'" )
749- }
749+ // This is only possible when one of the branches has PkH
750+ ( _, & Witness :: Unavailable ) | ( _, & Witness :: Impossible ) => i64:: MIN ,
750751 ( & Witness :: Stack ( ref s) , & Witness :: Stack ( ref d) ) => {
751752 witness_size ( s) as i64 - witness_size ( d) as i64
752753 }
0 commit comments