@@ -148,37 +148,29 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
148
148
}
149
149
} else if script_pubkey. is_p2pkh ( ) {
150
150
// 2. `Pkh`: creates a `PkH` descriptor if partial_sigs has the corresponding pk
151
- let partial_sig_contains_pk = inp
152
- . partial_sigs
153
- . iter ( )
154
- . filter ( |& ( & pk, _sig) | {
155
- // Indirect way to check the equivalence of pubkey-hashes.
156
- // Create a pubkey hash and check if they are the same.
157
- // THIS IS A BUG AND *WILL* PRODUCE WRONG SATISFACTIONS FOR UNCOMPRESSED KEYS
158
- // Partial sigs loses the compressed flag that is necessary
159
- // TODO: See https://github.com/rust-bitcoin/rust-bitcoin/pull/836
160
- // The type checker will fail again after we update to 0.28 and this can be removed
161
- let addr = bitcoin:: Address :: p2pkh ( & pk, bitcoin:: Network :: Bitcoin ) ;
162
- * script_pubkey == addr. script_pubkey ( )
163
- } )
164
- . next ( ) ;
151
+ let partial_sig_contains_pk = inp. partial_sigs . iter ( ) . find ( |& ( & pk, _sig) | {
152
+ // Indirect way to check the equivalence of pubkey-hashes.
153
+ // Create a pubkey hash and check if they are the same.
154
+ // THIS IS A BUG AND *WILL* PRODUCE WRONG SATISFACTIONS FOR UNCOMPRESSED KEYS
155
+ // Partial sigs loses the compressed flag that is necessary
156
+ // TODO: See https://github.com/rust-bitcoin/rust-bitcoin/pull/836
157
+ // The type checker will fail again after we update to 0.28 and this can be removed
158
+ let addr = bitcoin:: Address :: p2pkh ( & pk, bitcoin:: Network :: Bitcoin ) ;
159
+ * script_pubkey == addr. script_pubkey ( )
160
+ } ) ;
165
161
match partial_sig_contains_pk {
166
162
Some ( ( pk, _sig) ) => Ok ( Descriptor :: new_pkh ( * pk) ) ,
167
163
None => Err ( InputError :: MissingPubkey ) ,
168
164
}
169
165
} else if script_pubkey. is_v0_p2wpkh ( ) {
170
166
// 3. `Wpkh`: creates a `wpkh` descriptor if the partial sig has corresponding pk.
171
- let partial_sig_contains_pk = inp
172
- . partial_sigs
173
- . iter ( )
174
- . filter ( |& ( & pk, _sig) | {
175
- // Indirect way to check the equivalence of pubkey-hashes.
176
- // Create a pubkey hash and check if they are the same.
177
- let addr = bitcoin:: Address :: p2wpkh ( & pk, bitcoin:: Network :: Bitcoin )
178
- . expect ( "Address corresponding to valid pubkey" ) ;
179
- * script_pubkey == addr. script_pubkey ( )
180
- } )
181
- . next ( ) ;
167
+ let partial_sig_contains_pk = inp. partial_sigs . iter ( ) . find ( |& ( & pk, _sig) | {
168
+ // Indirect way to check the equivalence of pubkey-hashes.
169
+ // Create a pubkey hash and check if they are the same.
170
+ let addr = bitcoin:: Address :: p2wpkh ( & pk, bitcoin:: Network :: Bitcoin )
171
+ . expect ( "Address corresponding to valid pubkey" ) ;
172
+ * script_pubkey == addr. script_pubkey ( )
173
+ } ) ;
182
174
match partial_sig_contains_pk {
183
175
Some ( ( pk, _sig) ) => Ok ( Descriptor :: new_wpkh ( * pk) ?) ,
184
176
None => Err ( InputError :: MissingPubkey ) ,
@@ -228,15 +220,11 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
228
220
}
229
221
} else if redeem_script. is_v0_p2wpkh ( ) {
230
222
// 6. `ShWpkh` case
231
- let partial_sig_contains_pk = inp
232
- . partial_sigs
233
- . iter ( )
234
- . filter ( |& ( & pk, _sig) | {
235
- let addr = bitcoin:: Address :: p2wpkh ( & pk, bitcoin:: Network :: Bitcoin )
236
- . expect ( "Address corresponding to valid pubkey" ) ;
237
- * redeem_script == addr. script_pubkey ( )
238
- } )
239
- . next ( ) ;
223
+ let partial_sig_contains_pk = inp. partial_sigs . iter ( ) . find ( |& ( & pk, _sig) | {
224
+ let addr = bitcoin:: Address :: p2wpkh ( & pk, bitcoin:: Network :: Bitcoin )
225
+ . expect ( "Address corresponding to valid pubkey" ) ;
226
+ * redeem_script == addr. script_pubkey ( )
227
+ } ) ;
240
228
match partial_sig_contains_pk {
241
229
Some ( ( pk, _sig) ) => Ok ( Descriptor :: new_sh_wpkh ( * pk) ?) ,
242
230
None => Err ( InputError :: MissingPubkey ) ,
0 commit comments