Skip to content

Commit feae54c

Browse files
committed
Merge #578: Add default impl for Miniscript::num_der_paths
88f7f5b Add default impl or num_der_paths (Tobin C. Harding) Pull request description: The trait method `MiniscriptKey::num_der_paths` often returns 0, lets just make this the default. ACKs for top commit: apoelstra: ACK 88f7f5b Tree-SHA512: 848f06f56a4af57912d64a8e28ee730ff878b06234ffdb2324e104bcab1c9daeff25c938dc3d05714502e8ac4ce47701e85ac34b2ddd4588ae0d305b3a8cb739
2 parents 1f645ad + 88f7f5b commit feae54c

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

src/interpreter/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ impl MiniscriptKey for BitcoinKey {
127127
type Hash256 = hash256::Hash;
128128
type Ripemd160 = ripemd160::Hash;
129129
type Hash160 = hash160::Hash;
130-
131-
fn num_der_paths(&self) -> usize {
132-
0
133-
}
134130
}
135131

136132
impl<'txin> Interpreter<'txin> {

src/lib.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
166166

167167
/// Returns the number of different derivation paths in this key. Only >1 for keys
168168
/// in BIP389 multipath descriptors.
169-
fn num_der_paths(&self) -> usize;
169+
fn num_der_paths(&self) -> usize {
170+
0
171+
}
170172

171173
/// The associated [`bitcoin::hashes::sha256::Hash`] for this [`MiniscriptKey`], used in the
172174
/// sha256 fragment.
@@ -190,10 +192,6 @@ impl MiniscriptKey for bitcoin::secp256k1::PublicKey {
190192
type Hash256 = hash256::Hash;
191193
type Ripemd160 = ripemd160::Hash;
192194
type Hash160 = hash160::Hash;
193-
194-
fn num_der_paths(&self) -> usize {
195-
0
196-
}
197195
}
198196

199197
impl MiniscriptKey for bitcoin::PublicKey {
@@ -202,10 +200,6 @@ impl MiniscriptKey for bitcoin::PublicKey {
202200
!self.compressed
203201
}
204202

205-
fn num_der_paths(&self) -> usize {
206-
0
207-
}
208-
209203
type Sha256 = sha256::Hash;
210204
type Hash256 = hash256::Hash;
211205
type Ripemd160 = ripemd160::Hash;
@@ -221,21 +215,13 @@ impl MiniscriptKey for bitcoin::secp256k1::XOnlyPublicKey {
221215
fn is_x_only_key(&self) -> bool {
222216
true
223217
}
224-
225-
fn num_der_paths(&self) -> usize {
226-
0
227-
}
228218
}
229219

230220
impl MiniscriptKey for String {
231221
type Sha256 = String; // specify hashes as string
232222
type Hash256 = String;
233223
type Ripemd160 = String;
234224
type Hash160 = String;
235-
236-
fn num_der_paths(&self) -> usize {
237-
0
238-
}
239225
}
240226

241227
/// Trait describing public key types which can be converted to bitcoin pubkeys

0 commit comments

Comments
 (0)