Skip to content

Commit e98f5f2

Browse files
committed
adding testnet/bitcoin differentiation
1 parent 7c350d4 commit e98f5f2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/cli.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub struct Cli {
2626
#[clap(short, long)]
2727
long: bool,
2828

29+
/// Switch to testnet mode
30+
#[clap(short, long)]
31+
testnet: bool,
32+
2933
#[clap(subcommand)]
3034
pub action: Action,
3135
}
@@ -72,11 +76,11 @@ impl Cli {
7276
let xkey: ExtendedKey<miniscript::Segwitv0> = seed
7377
.into_extended_key()
7478
.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();
7680
Wallet::new(
7781
Bip84(xprv.clone(), KeychainKind::External),
7882
Some(Bip84(xprv.clone(), KeychainKind::External)),
79-
Network::Testnet,
83+
self.network(),
8084
MemoryDatabase::default(),
8185
)
8286
.context("Failed to create wallet")
@@ -110,6 +114,14 @@ impl Cli {
110114
print!("{descriptor}");
111115
Ok(())
112116
}
117+
118+
fn network(&self) -> Network {
119+
if self.testnet {
120+
Network::Testnet
121+
} else {
122+
Network::Bitcoin
123+
}
124+
}
113125
}
114126

115127
#[derive(clap::Subcommand, Clone)]

0 commit comments

Comments
 (0)