@@ -168,24 +168,16 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
168
168
/// Only >1 for keys in BIP389 multipath descriptors.
169
169
fn num_der_paths ( & self ) -> usize { 0 }
170
170
171
- /// The associated [`sha256::Hash`] for this `MiniscriptKey`, used in the sha256 fragment.
172
- ///
173
- /// [`sha256::Hash`]: bitcoin::hashes::sha256::Hash
171
+ /// The type used in the sha256 fragment.
174
172
type Sha256 : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
175
173
176
- /// The associated [`hash256::Hash`] for this `MiniscriptKey`, used in the hash256 fragment.
177
- ///
178
- /// [`hash256::Hash`]: crate::hash256::Hash
174
+ /// The type used in the hash256 fragment.
179
175
type Hash256 : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
180
176
181
- /// The associated [`ripemd160::Hash`] for this `MiniscriptKey` type, used in the ripemd160 fragment.
182
- ///
183
- /// [`ripemd160::Hash`]: bitcoin::hashes::ripemd160::Hash
177
+ /// The type used in the ripemd160 fragment.
184
178
type Ripemd160 : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
185
179
186
- /// The associated [`hash160::Hash`] for this `MiniscriptKey` type, used in the hash160 fragment.
187
- ///
188
- /// [`hash160::Hash`]: bitcoin::hashes::hash160::Hash
180
+ /// The type used in the hash160 fragment.
189
181
type Hash160 : Clone + Eq + Ord + fmt:: Display + fmt:: Debug + hash:: Hash ;
190
182
}
191
183
@@ -221,38 +213,46 @@ impl MiniscriptKey for String {
221
213
type Hash160 = String ;
222
214
}
223
215
224
- /// Trait describing public key types which can be converted to bitcoin pubkeys
216
+ /// Trait describing key types that can be converted to bitcoin public keys.
225
217
pub trait ToPublicKey : MiniscriptKey {
226
- /// Converts an object to a public key
218
+ /// Converts key to a public key.
227
219
fn to_public_key ( & self ) -> bitcoin:: PublicKey ;
228
220
229
- /// Convert an object to x-only pubkey
221
+ /// Converts key to an x-only public key.
230
222
fn to_x_only_pubkey ( & self ) -> bitcoin:: secp256k1:: XOnlyPublicKey {
231
223
let pk = self . to_public_key ( ) ;
232
224
bitcoin:: secp256k1:: XOnlyPublicKey :: from ( pk. inner )
233
225
}
234
226
235
- /// Obtain the public key hash for this MiniscriptKey
236
- /// Expects an argument to specify the signature type.
237
- /// This would determine whether to serialize the key as 32 byte x-only pubkey
238
- /// or regular public key when computing the hash160
227
+ /// Obtains the pubkey hash for this key (as a ` MiniscriptKey`).
228
+ ///
229
+ /// Expects an argument to specify the signature type. This determines whether to serialize
230
+ /// the key as 32 byte x-only pubkey or regular public key when computing the hash160.
239
231
fn to_pubkeyhash ( & self , sig_type : SigType ) -> hash160:: Hash {
240
232
match sig_type {
241
233
SigType :: Ecdsa => hash160:: Hash :: hash ( & self . to_public_key ( ) . to_bytes ( ) ) ,
242
234
SigType :: Schnorr => hash160:: Hash :: hash ( & self . to_x_only_pubkey ( ) . serialize ( ) ) ,
243
235
}
244
236
}
245
237
246
- /// Converts the generic associated [`MiniscriptKey::Sha256`] to [`sha256::Hash`]
238
+ /// Converts the associated [`MiniscriptKey::Sha256`] type to a [`sha256::Hash`].
239
+ ///
240
+ /// [`sha256::Hash`]: bitcoin::hashes::sha256::Hash
247
241
fn to_sha256 ( hash : & <Self as MiniscriptKey >:: Sha256 ) -> sha256:: Hash ;
248
242
249
- /// Converts the generic associated [`MiniscriptKey::Hash256`] to [`hash256::Hash`]
243
+ /// Converts the associated [`MiniscriptKey::Hash256`] type to a [`hash256::Hash`].
244
+ ///
245
+ /// [`hash256::Hash`]: crate::hash256::Hash
250
246
fn to_hash256 ( hash : & <Self as MiniscriptKey >:: Hash256 ) -> hash256:: Hash ;
251
247
252
- /// Converts the generic associated [`MiniscriptKey::Ripemd160`] to [`ripemd160::Hash`]
248
+ /// Converts the associated [`MiniscriptKey::Ripemd160`] type to a [`ripemd160::Hash`].
249
+ ///
250
+ /// [`ripemd160::Hash`]: bitcoin::hashes::ripemd160::Hash
253
251
fn to_ripemd160 ( hash : & <Self as MiniscriptKey >:: Ripemd160 ) -> ripemd160:: Hash ;
254
252
255
- /// Converts the generic associated [`MiniscriptKey::Hash160`] to [`hash160::Hash`]
253
+ /// Converts the associated [`MiniscriptKey::Hash160`] type to a [`hash160::Hash`].
254
+ ///
255
+ /// [`hash160::Hash`]: bitcoin::hashes::hash160::Hash
256
256
fn to_hash160 ( hash : & <Self as MiniscriptKey >:: Hash160 ) -> hash160:: Hash ;
257
257
}
258
258
0 commit comments