Skip to content

Commit 0ec9ccc

Browse files
committed
Check pubkey size and type before serializing
Signed-off-by: Harshil Jani <[email protected]>
1 parent f805716 commit 0ec9ccc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/miniscript/satisfy.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Placeholder<Pk> {
473473
/// Replaces the placeholders with the information given by the satisfier
474474
pub fn satisfy_self<Sat: Satisfier<Pk>>(&self, sat: &Sat) -> Option<Vec<u8>> {
475475
match self {
476-
Placeholder::Pubkey(pk, _) => Some(pk.to_public_key().to_bytes()),
476+
Placeholder::Pubkey(pk, size) => {
477+
if *size==34 as usize {
478+
return Some(pk.to_public_key().to_bytes());
479+
}else{
480+
return Some(pk.to_x_only_pubkey().serialize().to_vec())
481+
}
482+
},//length = 32 for XOnly
477483
Placeholder::Hash256Preimage(h) => sat.lookup_hash256(h).map(|p| p.to_vec()),
478484
Placeholder::Sha256Preimage(h) => sat.lookup_sha256(h).map(|p| p.to_vec()),
479485
Placeholder::Hash160Preimage(h) => sat.lookup_hash160(h).map(|p| p.to_vec()),

0 commit comments

Comments
 (0)