Skip to content

Commit 0b591ab

Browse files
committed
update pk types
1 parent 84e42ee commit 0b591ab

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/psbt/finalizer.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
157157
// Partial sigs loses the compressed flag that is necessary
158158
// TODO: See https://github.com/rust-bitcoin/rust-bitcoin/pull/836
159159
// The type checker will fail again after we update to 0.28 and this can be removed
160-
let pk = bitcoin::PublicKey::new(pk);
161160
let addr = bitcoin::Address::p2pkh(&pk, bitcoin::Network::Bitcoin);
162161
*script_pubkey == addr.script_pubkey()
163162
})
164163
.next();
165164
match partial_sig_contains_pk {
166-
Some((pk, _sig)) => Ok(Descriptor::new_pkh(bitcoin::PublicKey::new(*pk))),
165+
Some((pk, _sig)) => Ok(Descriptor::new_pkh(*pk)),
167166
None => Err(InputError::MissingPubkey),
168167
}
169168
} else if script_pubkey.is_v0_p2wpkh() {
@@ -174,14 +173,13 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
174173
.filter(|&(&pk, _sig)| {
175174
// Indirect way to check the equivalence of pubkey-hashes.
176175
// Create a pubkey hash and check if they are the same.
177-
let pk = bitcoin::PublicKey::new(pk);
178176
let addr = bitcoin::Address::p2wpkh(&pk, bitcoin::Network::Bitcoin)
179177
.expect("Address corresponding to valid pubkey");
180178
*script_pubkey == addr.script_pubkey()
181179
})
182180
.next();
183181
match partial_sig_contains_pk {
184-
Some((pk, _sig)) => Ok(Descriptor::new_wpkh(bitcoin::PublicKey::new(*pk))?),
182+
Some((pk, _sig)) => Ok(Descriptor::new_wpkh(*pk)?),
185183
None => Err(InputError::MissingPubkey),
186184
}
187185
} else if script_pubkey.is_v0_p2wsh() {
@@ -233,16 +231,13 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
233231
.partial_sigs
234232
.iter()
235233
.filter(|&(&pk, _sig)| {
236-
let pk = bitcoin::PublicKey::new(pk);
237234
let addr = bitcoin::Address::p2wpkh(&pk, bitcoin::Network::Bitcoin)
238235
.expect("Address corresponding to valid pubkey");
239236
*redeem_script == addr.script_pubkey()
240237
})
241238
.next();
242239
match partial_sig_contains_pk {
243-
Some((pk, _sig)) => {
244-
Ok(Descriptor::new_sh_wpkh(bitcoin::PublicKey::new(*pk))?)
245-
}
240+
Some((pk, _sig)) => Ok(Descriptor::new_sh_wpkh(*pk)?),
246241
None => Err(InputError::MissingPubkey),
247242
}
248243
} else {

src/psbt/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl<'psbt, Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfie
288288
fn lookup_ecdsa_sig(&self, pk: &Pk) -> Option<bitcoin::EcdsaSig> {
289289
self.psbt.inputs[self.index]
290290
.partial_sigs
291-
.get(&pk.to_public_key().inner)
291+
.get(&pk.to_public_key())
292292
.map(|sig| *sig)
293293
}
294294

@@ -299,11 +299,9 @@ impl<'psbt, Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfie
299299
self.psbt.inputs[self.index]
300300
.partial_sigs
301301
.iter()
302-
.filter(|&(pubkey, _sig)| {
303-
bitcoin::PublicKey::new(*pubkey).to_pubkeyhash() == Pk::hash_to_hash160(pkh)
304-
})
302+
.filter(|&(pubkey, _sig)| pubkey.to_pubkeyhash() == Pk::hash_to_hash160(pkh))
305303
.next()
306-
.map(|(pk, sig)| (bitcoin::PublicKey::new(*pk), *sig))
304+
.map(|(pk, sig)| (*pk, *sig))
307305
}
308306

309307
fn check_after(&self, n: u32) -> bool {
@@ -448,7 +446,7 @@ fn sanity_check(psbt: &Psbt) -> Result<(), Error> {
448446
InputError::WrongSigHashFlag {
449447
required: target_ecdsa_sighash_ty,
450448
got: flag,
451-
pubkey: bitcoin::PublicKey::new(*key),
449+
pubkey: *key,
452450
},
453451
index,
454452
));

0 commit comments

Comments
 (0)