diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index af405bda9..462d9049e 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -130,6 +130,8 @@ impl MiniscriptKey for BitcoinKey { BitcoinKey::XOnlyPublicKey(_) => false, } } + fn is_x_only_key(&self) -> bool { false } + fn num_der_paths(&self) -> usize { 0 } } impl<'txin> Interpreter<'txin> { diff --git a/src/lib.rs b/src/lib.rs index 01472a2df..0a67f7e85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,16 +155,16 @@ pub use crate::primitives::relative_locktime::{RelLockTime, RelLockTimeError}; /// Trait representing a key which can be converted to a hash type. pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Hash { - /// Returns true if the key is serialized uncompressed, defaults to `false`. - fn is_uncompressed(&self) -> bool { false } + /// Returns true if the key is serialized uncompressed. + fn is_uncompressed(&self) -> bool; - /// Returns true if the key is an x-only pubkey, defaults to `false`. - fn is_x_only_key(&self) -> bool { false } + /// Returns true if the key is an x-only pubkey. + fn is_x_only_key(&self) -> bool; - /// Returns the number of different derivation paths in this key, defaults to `0`. + /// Returns the number of different derivation paths in this key. /// /// Only >1 for keys in BIP389 multipath descriptors. - fn num_der_paths(&self) -> usize { 0 } + fn num_der_paths(&self) -> usize; /// The type used in the sha256 fragment. type Sha256: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash; @@ -184,6 +184,10 @@ impl MiniscriptKey for bitcoin::secp256k1::PublicKey { type Hash256 = hash256::Hash; type Ripemd160 = ripemd160::Hash; type Hash160 = hash160::Hash; + + fn is_uncompressed(&self) -> bool { false } + fn is_x_only_key(&self) -> bool { false } + fn num_der_paths(&self) -> usize { 0 } } impl MiniscriptKey for bitcoin::PublicKey { @@ -193,6 +197,8 @@ impl MiniscriptKey for bitcoin::PublicKey { type Hash160 = hash160::Hash; fn is_uncompressed(&self) -> bool { !self.compressed } + fn is_x_only_key(&self) -> bool { false } + fn num_der_paths(&self) -> usize { 0 } } impl MiniscriptKey for bitcoin::secp256k1::XOnlyPublicKey { @@ -201,7 +207,9 @@ impl MiniscriptKey for bitcoin::secp256k1::XOnlyPublicKey { type Ripemd160 = ripemd160::Hash; type Hash160 = hash160::Hash; + fn is_uncompressed(&self) -> bool { false } fn is_x_only_key(&self) -> bool { true } + fn num_der_paths(&self) -> usize { 0 } } impl MiniscriptKey for String { @@ -209,6 +217,10 @@ impl MiniscriptKey for String { type Hash256 = String; type Ripemd160 = String; type Hash160 = String; + + fn is_uncompressed(&self) -> bool { false } + fn is_x_only_key(&self) -> bool { false } + fn num_der_paths(&self) -> usize { 0 } } /// Trait describing key types that can be converted to bitcoin public keys.