@@ -23,11 +23,17 @@ use super::{ExtendedDescriptor, IntoWalletDescriptor, KeyMap};
23
23
use crate :: descriptor:: DescriptorError ;
24
24
use crate :: keys:: { DerivableKey , IntoDescriptorKey , ValidNetworks } ;
25
25
use crate :: wallet:: utils:: SecpCtx ;
26
- use crate :: { descriptor, KeychainKind } ;
26
+ use crate :: descriptor;
27
27
28
28
/// Type alias for the return type of [`DescriptorTemplate`], [`descriptor!`](crate::descriptor!) and others
29
29
pub type DescriptorTemplateOut = ( ExtendedDescriptor , KeyMap , ValidNetworks ) ;
30
30
31
+ #[ derive( Clone , Debug ) ]
32
+ pub enum TemplateKeychainKind {
33
+ External ,
34
+ Internal ,
35
+ }
36
+
31
37
/// Trait for descriptor templates that can be built into a full descriptor
32
38
///
33
39
/// Since [`IntoWalletDescriptor`] is implemented for any [`DescriptorTemplate`], they can also be
@@ -232,7 +238,7 @@ impl<K: IntoDescriptorKey<Tap>> DescriptorTemplate for P2TR<K> {
232
238
/// # Ok::<_, Box<dyn std::error::Error>>(())
233
239
/// ```
234
240
#[ derive( Debug , Clone ) ]
235
- pub struct Bip44 < K : DerivableKey < Legacy > > ( pub K , pub KeychainKind ) ;
241
+ pub struct Bip44 < K : DerivableKey < Legacy > > ( pub K , pub TemplateKeychainKind ) ;
236
242
237
243
impl < K : DerivableKey < Legacy > > DescriptorTemplate for Bip44 < K > {
238
244
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -271,7 +277,7 @@ impl<K: DerivableKey<Legacy>> DescriptorTemplate for Bip44<K> {
271
277
/// # Ok::<_, Box<dyn std::error::Error>>(())
272
278
/// ```
273
279
#[ derive( Debug , Clone ) ]
274
- pub struct Bip44Public < K : DerivableKey < Legacy > > ( pub K , pub bip32:: Fingerprint , pub KeychainKind ) ;
280
+ pub struct Bip44Public < K : DerivableKey < Legacy > > ( pub K , pub bip32:: Fingerprint , pub TemplateKeychainKind ) ;
275
281
276
282
impl < K : DerivableKey < Legacy > > DescriptorTemplate for Bip44Public < K > {
277
283
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -309,7 +315,7 @@ impl<K: DerivableKey<Legacy>> DescriptorTemplate for Bip44Public<K> {
309
315
/// # Ok::<_, Box<dyn std::error::Error>>(())
310
316
/// ```
311
317
#[ derive( Debug , Clone ) ]
312
- pub struct Bip49 < K : DerivableKey < Segwitv0 > > ( pub K , pub KeychainKind ) ;
318
+ pub struct Bip49 < K : DerivableKey < Segwitv0 > > ( pub K , pub TemplateKeychainKind ) ;
313
319
314
320
impl < K : DerivableKey < Segwitv0 > > DescriptorTemplate for Bip49 < K > {
315
321
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -348,7 +354,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip49<K> {
348
354
/// # Ok::<_, Box<dyn std::error::Error>>(())
349
355
/// ```
350
356
#[ derive( Debug , Clone ) ]
351
- pub struct Bip49Public < K : DerivableKey < Segwitv0 > > ( pub K , pub bip32:: Fingerprint , pub KeychainKind ) ;
357
+ pub struct Bip49Public < K : DerivableKey < Segwitv0 > > ( pub K , pub bip32:: Fingerprint , pub TemplateKeychainKind ) ;
352
358
353
359
impl < K : DerivableKey < Segwitv0 > > DescriptorTemplate for Bip49Public < K > {
354
360
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -386,7 +392,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip49Public<K> {
386
392
/// # Ok::<_, Box<dyn std::error::Error>>(())
387
393
/// ```
388
394
#[ derive( Debug , Clone ) ]
389
- pub struct Bip84 < K : DerivableKey < Segwitv0 > > ( pub K , pub KeychainKind ) ;
395
+ pub struct Bip84 < K : DerivableKey < Segwitv0 > > ( pub K , pub TemplateKeychainKind ) ;
390
396
391
397
impl < K : DerivableKey < Segwitv0 > > DescriptorTemplate for Bip84 < K > {
392
398
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -425,7 +431,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip84<K> {
425
431
/// # Ok::<_, Box<dyn std::error::Error>>(())
426
432
/// ```
427
433
#[ derive( Debug , Clone ) ]
428
- pub struct Bip84Public < K : DerivableKey < Segwitv0 > > ( pub K , pub bip32:: Fingerprint , pub KeychainKind ) ;
434
+ pub struct Bip84Public < K : DerivableKey < Segwitv0 > > ( pub K , pub bip32:: Fingerprint , pub TemplateKeychainKind ) ;
429
435
430
436
impl < K : DerivableKey < Segwitv0 > > DescriptorTemplate for Bip84Public < K > {
431
437
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -463,7 +469,7 @@ impl<K: DerivableKey<Segwitv0>> DescriptorTemplate for Bip84Public<K> {
463
469
/// # Ok::<_, Box<dyn std::error::Error>>(())
464
470
/// ```
465
471
#[ derive( Debug , Clone ) ]
466
- pub struct Bip86 < K : DerivableKey < Tap > > ( pub K , pub KeychainKind ) ;
472
+ pub struct Bip86 < K : DerivableKey < Tap > > ( pub K , pub TemplateKeychainKind ) ;
467
473
468
474
impl < K : DerivableKey < Tap > > DescriptorTemplate for Bip86 < K > {
469
475
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -502,7 +508,7 @@ impl<K: DerivableKey<Tap>> DescriptorTemplate for Bip86<K> {
502
508
/// # Ok::<_, Box<dyn std::error::Error>>(())
503
509
/// ```
504
510
#[ derive( Debug , Clone ) ]
505
- pub struct Bip86Public < K : DerivableKey < Tap > > ( pub K , pub bip32:: Fingerprint , pub KeychainKind ) ;
511
+ pub struct Bip86Public < K : DerivableKey < Tap > > ( pub K , pub bip32:: Fingerprint , pub TemplateKeychainKind ) ;
506
512
507
513
impl < K : DerivableKey < Tap > > DescriptorTemplate for Bip86Public < K > {
508
514
fn build ( self , network : Network ) -> Result < DescriptorTemplateOut , DescriptorError > {
@@ -521,7 +527,7 @@ macro_rules! expand_make_bipxx {
521
527
pub ( super ) fn make_bipxx_private<K : DerivableKey <$ctx>>(
522
528
bip: u32 ,
523
529
key: K ,
524
- keychain: KeychainKind ,
530
+ keychain: TemplateKeychainKind ,
525
531
network: Network ,
526
532
) -> Result <impl IntoDescriptorKey <$ctx>, DescriptorError > {
527
533
let mut derivation_path = alloc:: vec:: Vec :: with_capacity( 4 ) ;
@@ -538,10 +544,10 @@ macro_rules! expand_make_bipxx {
538
544
derivation_path. push( bip32:: ChildNumber :: from_hardened_idx( 0 ) ?) ;
539
545
540
546
match keychain {
541
- KeychainKind :: External => {
547
+ TemplateKeychainKind :: External => {
542
548
derivation_path. push( bip32:: ChildNumber :: from_normal_idx( 0 ) ?)
543
549
}
544
- KeychainKind :: Internal => {
550
+ TemplateKeychainKind :: Internal => {
545
551
derivation_path. push( bip32:: ChildNumber :: from_normal_idx( 1 ) ?)
546
552
}
547
553
} ;
@@ -554,12 +560,12 @@ macro_rules! expand_make_bipxx {
554
560
bip: u32 ,
555
561
key: K ,
556
562
parent_fingerprint: bip32:: Fingerprint ,
557
- keychain: KeychainKind ,
563
+ keychain: TemplateKeychainKind ,
558
564
network: Network ,
559
565
) -> Result <impl IntoDescriptorKey <$ctx>, DescriptorError > {
560
566
let derivation_path: bip32:: DerivationPath = match keychain {
561
- KeychainKind :: External => vec![ bip32:: ChildNumber :: from_normal_idx( 0 ) ?] . into( ) ,
562
- KeychainKind :: Internal => vec![ bip32:: ChildNumber :: from_normal_idx( 1 ) ?] . into( ) ,
567
+ TemplateKeychainKind :: External => vec![ bip32:: ChildNumber :: from_normal_idx( 0 ) ?] . into( ) ,
568
+ TemplateKeychainKind :: Internal => vec![ bip32:: ChildNumber :: from_normal_idx( 1 ) ?] . into( ) ,
563
569
} ;
564
570
565
571
let source_path = bip32:: DerivationPath :: from( vec![
0 commit comments