Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the MiniscriptKey and ToPublicKey traits #620

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Next Next commit
Manually implement is_uncompressed for BitcoinKey
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.
tcharding committed Mar 28, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tcharding Tobin C. Harding
commit 730c492b95ebcd865ea52e6184805416e953cd9a
7 changes: 7 additions & 0 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
@@ -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> {