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