File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ pub struct Cli {
26
26
#[ clap( short, long) ]
27
27
long : bool ,
28
28
29
+ /// Switch to testnet mode
30
+ #[ clap( short, long) ]
31
+ testnet : bool ,
32
+
29
33
#[ clap( subcommand) ]
30
34
pub action : Action ,
31
35
}
@@ -72,11 +76,11 @@ impl Cli {
72
76
let xkey: ExtendedKey < miniscript:: Segwitv0 > = seed
73
77
. into_extended_key ( )
74
78
. context ( "Failed to convert mnemonic into an extended key" ) ?;
75
- let xprv = xkey. into_xprv ( Network :: Testnet ) . unwrap ( ) ;
79
+ let xprv = xkey. into_xprv ( self . network ( ) ) . unwrap ( ) ;
76
80
Wallet :: new (
77
81
Bip84 ( xprv. clone ( ) , KeychainKind :: External ) ,
78
82
Some ( Bip84 ( xprv. clone ( ) , KeychainKind :: External ) ) ,
79
- Network :: Testnet ,
83
+ self . network ( ) ,
80
84
MemoryDatabase :: default ( ) ,
81
85
)
82
86
. context ( "Failed to create wallet" )
@@ -110,6 +114,14 @@ impl Cli {
110
114
print ! ( "{descriptor}" ) ;
111
115
Ok ( ( ) )
112
116
}
117
+
118
+ fn network ( & self ) -> Network {
119
+ if self . testnet {
120
+ Network :: Testnet
121
+ } else {
122
+ Network :: Bitcoin
123
+ }
124
+ }
113
125
}
114
126
115
127
#[ derive( clap:: Subcommand , Clone ) ]
You can’t perform that action at this time.
0 commit comments