Skip to content

Commit

Permalink
Merge #666: Manually implement is_uncompressed for BitcoinKey
Browse files Browse the repository at this point in the history
52198dd Manually implement is_uncompressed for BitcoinKey (Tobin C. Harding)

Pull request description:

  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.

  Originally done, and discussed, in #620.

ACKs for top commit:
  apoelstra:
    ACK 52198dd

Tree-SHA512: 59f514d24120cfc452e60c361f851280b0515e4b63eb5d2a94d84e39821e6c80f3af07eee5fc5f80bd7198d2e09c6e4465f6f6ef3e8f38dba87ef77a2e1a3b9a
  • Loading branch information
apoelstra committed Mar 28, 2024
2 parents fb3f36a + 52198dd commit 481784e
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 481784e

Please sign in to comment.