Skip to content

Commit

Permalink
Manually implement is_uncompressed for BitcoinKey
Browse files Browse the repository at this point in the history
The `interpreter::BitcoinKey` uses the default implementation of
`MiniscriptKey`, which means `is_uncompressed` returns `false`. However
if the full key is a `bitcoin::PublicKey` it may be compressed.

Manually implement `MiniscriptKey::is_uncompressed` for `BitcoinKey` and
return the compressedness of the inner full key.
  • Loading branch information
tcharding committed Oct 17, 2023
1 parent d615b7c commit 42ca0f3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ impl MiniscriptKey for BitcoinKey {
type Hash256 = hash256::Hash;
type Ripemd160 = ripemd160::Hash;
type Hash160 = hash160::Hash;

fn is_uncompressed(&self) -> bool {
match *self {
BitcoinKey::Fullkey(pk) => !pk.compressed,
BitcoinKey::XOnlyPublicKey(_) => false,
}
}
}

impl<'txin> Interpreter<'txin> {
Expand Down

0 comments on commit 42ca0f3

Please sign in to comment.