File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ pub mod psbt;
116116
117117mod util;
118118
119+ use std:: io:: Write ;
119120use std:: str:: FromStr ;
120121use std:: { error, fmt, hash, str} ;
121122
@@ -155,6 +156,23 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
155156 fn to_pubkeyhash ( & self ) -> Self :: Hash ;
156157}
157158
159+ impl MiniscriptKey for bitcoin:: secp256k1:: PublicKey {
160+ /// `is_uncompressed` always returns `false`
161+ fn is_uncompressed ( & self ) -> bool {
162+ false
163+ }
164+
165+ type Hash = hash160:: Hash ;
166+
167+ fn to_pubkeyhash ( & self ) -> Self :: Hash {
168+ let mut engine = hash160:: Hash :: engine ( ) ;
169+ engine
170+ . write_all ( & self . serialize ( ) )
171+ . expect ( "engines don't error" ) ;
172+ hash160:: Hash :: from_engine ( engine)
173+ }
174+ }
175+
158176impl MiniscriptKey for bitcoin:: PublicKey {
159177 /// `is_uncompressed` returns true only for
160178 /// bitcoin::Publickey type if the underlying key is uncompressed.
You can’t perform that action at this time.
0 commit comments