@@ -16,7 +16,7 @@ use {MiniscriptKey, ToPublicKey};
16
16
#[ derive( Debug , Eq , PartialEq , Clone , Ord , PartialOrd , Hash ) ]
17
17
pub enum DescriptorPublicKey {
18
18
/// Single public key.
19
- SinglePub ( DescriptorSinglePub ) ,
19
+ Single ( SinglePub ) ,
20
20
/// Extended public key (xpub).
21
21
XPub ( DescriptorXKey < bip32:: ExtendedPubKey > ) ,
22
22
}
@@ -25,14 +25,14 @@ pub enum DescriptorPublicKey {
25
25
#[ derive( Debug ) ]
26
26
pub enum DescriptorSecretKey {
27
27
/// Single private key.
28
- SinglePriv ( DescriptorSinglePriv ) ,
28
+ Single ( SinglePriv ) ,
29
29
/// Extended private key (xpriv).
30
30
XPrv ( DescriptorXKey < bip32:: ExtendedPrivKey > ) ,
31
31
}
32
32
33
33
/// A descriptor [`SinglePubKey`] with optional origin information.
34
34
#[ derive( Debug , Eq , PartialEq , Clone , Ord , PartialOrd , Hash ) ]
35
- pub struct DescriptorSinglePub {
35
+ pub struct SinglePub {
36
36
/// Origin information (fingerprint and derivation path).
37
37
pub origin : Option < ( bip32:: Fingerprint , bip32:: DerivationPath ) > ,
38
38
/// The public key.
@@ -41,7 +41,7 @@ pub struct DescriptorSinglePub {
41
41
42
42
/// A descriptor [`bitcoin::PrivateKey`] with optional origin information.
43
43
#[ derive( Debug ) ]
44
- pub struct DescriptorSinglePriv {
44
+ pub struct SinglePriv {
45
45
/// Origin information (fingerprint and derivation path).
46
46
pub origin : Option < ( bip32:: Fingerprint , bip32:: DerivationPath ) > ,
47
47
/// The private key.
@@ -73,7 +73,7 @@ pub enum SinglePubKey {
73
73
impl fmt:: Display for DescriptorSecretKey {
74
74
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
75
75
match self {
76
- & DescriptorSecretKey :: SinglePriv ( ref sk) => {
76
+ & DescriptorSecretKey :: Single ( ref sk) => {
77
77
maybe_fmt_master_id ( f, & sk. origin ) ?;
78
78
sk. key . fmt ( f) ?;
79
79
Ok ( ( ) )
@@ -136,15 +136,15 @@ pub enum Wildcard {
136
136
Hardened ,
137
137
}
138
138
139
- impl DescriptorSinglePriv {
139
+ impl SinglePriv {
140
140
/// Returns the public key of this key
141
141
fn as_public < C : Signing > (
142
142
& self ,
143
143
secp : & Secp256k1 < C > ,
144
- ) -> Result < DescriptorSinglePub , DescriptorKeyParseError > {
144
+ ) -> Result < SinglePub , DescriptorKeyParseError > {
145
145
let pub_key = self . key . public_key ( secp) ;
146
146
147
- Ok ( DescriptorSinglePub {
147
+ Ok ( SinglePub {
148
148
origin : self . origin . clone ( ) ,
149
149
key : SinglePubKey :: FullKey ( pub_key) ,
150
150
} )
@@ -218,7 +218,7 @@ impl error::Error for DescriptorKeyParseError {}
218
218
impl fmt:: Display for DescriptorPublicKey {
219
219
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
220
220
match * self {
221
- DescriptorPublicKey :: SinglePub ( ref pk) => {
221
+ DescriptorPublicKey :: Single ( ref pk) => {
222
222
maybe_fmt_master_id ( f, & pk. origin ) ?;
223
223
match pk. key {
224
224
SinglePubKey :: FullKey ( full_key) => full_key. fmt ( f) ,
@@ -243,7 +243,7 @@ impl fmt::Display for DescriptorPublicKey {
243
243
244
244
impl DescriptorSecretKey {
245
245
/// Return the public version of this key, by applying either
246
- /// [`DescriptorSinglePriv ::as_public`] or [`DescriptorXKey<bip32::ExtendedPrivKey>::as_public`]
246
+ /// [`SinglePriv ::as_public`] or [`DescriptorXKey<bip32::ExtendedPrivKey>::as_public`]
247
247
/// depending on the type of key.
248
248
///
249
249
/// If the key is an "XPrv", the hardened derivation steps will be applied before converting it
@@ -254,8 +254,8 @@ impl DescriptorSecretKey {
254
254
secp : & Secp256k1 < C > ,
255
255
) -> Result < DescriptorPublicKey , DescriptorKeyParseError > {
256
256
Ok ( match self {
257
- & DescriptorSecretKey :: SinglePriv ( ref sk) => {
258
- DescriptorPublicKey :: SinglePub ( sk. as_public ( secp) ?)
257
+ & DescriptorSecretKey :: Single ( ref sk) => {
258
+ DescriptorPublicKey :: Single ( sk. as_public ( secp) ?)
259
259
}
260
260
& DescriptorSecretKey :: XPrv ( ref xprv) => {
261
261
DescriptorPublicKey :: XPub ( xprv. as_public ( secp) ?)
@@ -340,10 +340,7 @@ impl FromStr for DescriptorPublicKey {
340
340
) )
341
341
}
342
342
} ;
343
- Ok ( DescriptorPublicKey :: SinglePub ( DescriptorSinglePub {
344
- key,
345
- origin,
346
- } ) )
343
+ Ok ( DescriptorPublicKey :: Single ( SinglePub { key, origin } ) )
347
344
}
348
345
}
349
346
}
@@ -384,7 +381,7 @@ impl DescriptorPublicKey {
384
381
xpub. xkey . fingerprint ( )
385
382
}
386
383
}
387
- DescriptorPublicKey :: SinglePub ( ref single) => {
384
+ DescriptorPublicKey :: Single ( ref single) => {
388
385
if let Some ( ( fingerprint, _) ) = single. origin {
389
386
fingerprint
390
387
} else {
@@ -416,7 +413,7 @@ impl DescriptorPublicKey {
416
413
} ;
417
414
origin_path. extend ( & xpub. derivation_path )
418
415
}
419
- DescriptorPublicKey :: SinglePub ( ref single) => {
416
+ DescriptorPublicKey :: Single ( ref single) => {
420
417
if let Some ( ( _, ref path) ) = single. origin {
421
418
path. clone ( )
422
419
} else {
@@ -429,7 +426,7 @@ impl DescriptorPublicKey {
429
426
/// Whether or not the key has a wildcards
430
427
pub fn is_deriveable ( & self ) -> bool {
431
428
match * self {
432
- DescriptorPublicKey :: SinglePub ( ..) => false ,
429
+ DescriptorPublicKey :: Single ( ..) => false ,
433
430
DescriptorPublicKey :: XPub ( ref xpub) => xpub. wildcard != Wildcard :: None ,
434
431
}
435
432
}
@@ -475,7 +472,7 @@ impl DescriptorPublicKey {
475
472
secp : & Secp256k1 < C > ,
476
473
) -> Result < bitcoin:: PublicKey , ConversionError > {
477
474
match * self {
478
- DescriptorPublicKey :: SinglePub ( ref pk) => match pk. key {
475
+ DescriptorPublicKey :: Single ( ref pk) => match pk. key {
479
476
SinglePubKey :: FullKey ( pk) => Ok ( pk) ,
480
477
SinglePubKey :: XOnly ( xpk) => Ok ( xpk. to_public_key ( ) ) ,
481
478
} ,
@@ -503,7 +500,7 @@ impl FromStr for DescriptorSecretKey {
503
500
if key_part. len ( ) <= 52 {
504
501
let sk = bitcoin:: PrivateKey :: from_str ( key_part)
505
502
. map_err ( |_| DescriptorKeyParseError ( "Error while parsing a WIF private key" ) ) ?;
506
- Ok ( DescriptorSecretKey :: SinglePriv ( DescriptorSinglePriv {
503
+ Ok ( DescriptorSecretKey :: Single ( SinglePriv {
507
504
key : sk,
508
505
origin : None ,
509
506
} ) )
@@ -693,7 +690,7 @@ impl MiniscriptKey for DescriptorPublicKey {
693
690
694
691
fn is_uncompressed ( & self ) -> bool {
695
692
match self {
696
- DescriptorPublicKey :: SinglePub ( DescriptorSinglePub {
693
+ DescriptorPublicKey :: Single ( SinglePub {
697
694
key : SinglePubKey :: FullKey ( ref key) ,
698
695
..
699
696
} ) => key. is_uncompressed ( ) ,
@@ -703,7 +700,7 @@ impl MiniscriptKey for DescriptorPublicKey {
703
700
704
701
fn is_x_only_key ( & self ) -> bool {
705
702
match self {
706
- DescriptorPublicKey :: SinglePub ( DescriptorSinglePub {
703
+ DescriptorPublicKey :: Single ( SinglePub {
707
704
key : SinglePubKey :: XOnly ( ref _key) ,
708
705
..
709
706
} ) => true ,
0 commit comments