Skip to content

Commit b19d480

Browse files
authored
feat: Add --mnemonic-file CLI argument (#285)
Replace hardcoded mnemonic with a CLI argument.
1 parent 72ac033 commit b19d480

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dash-spv/src/main.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
152152
.default_value("20")
153153
.value_parser(clap::value_parser!(usize)),
154154
)
155+
.arg(
156+
Arg::new("mnemonic-file")
157+
.long("mnemonic-file")
158+
.value_name("PATH")
159+
.help("Path to file containing BIP39 mnemonic phrase")
160+
.required(true),
161+
)
155162
.get_matches();
156163

157164
let log_level: LevelFilter = matches
@@ -169,6 +176,13 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
169176
n => return Err(format!("Invalid network: {}", n).into()),
170177
};
171178

179+
let mnemonic_path =
180+
matches.get_one::<String>("mnemonic-file").ok_or("Missing mnemonic-file argument")?;
181+
let mnemonic_phrase = std::fs::read_to_string(mnemonic_path)
182+
.map_err(|e| format!("Failed to read mnemonic file '{}': {}", mnemonic_path, e))?
183+
.trim()
184+
.to_string();
185+
172186
// Parse validation mode
173187
let validation_str =
174188
matches.get_one::<String>("validation-mode").ok_or("Missing validation-mode argument")?;
@@ -290,7 +304,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
290304
// Create the wallet manager
291305
let mut wallet_manager = WalletManager::<ManagedWalletInfo>::new();
292306
let wallet_id = wallet_manager.create_wallet_from_mnemonic(
293-
"enemy check owner stumble unaware debris suffer peanut good fabric bleak outside",
307+
mnemonic_phrase.as_str(),
294308
"",
295309
&[network],
296310
None,

0 commit comments

Comments
 (0)