Skip to content

Commit 9b70524

Browse files
committed
feat(hwi): add address subcommand for hwi
fix clippy issues
1 parent 61f06a2 commit 9b70524

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/commands.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ pub enum HwiSubCommand {
488488
Devices,
489489
/// Register hardware wallet
490490
Register,
491+
/// Generate address
492+
Address,
491493
}
492494

493495
/// Subcommands available in REPL mode.

src/handlers.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ pub async fn handle_offline_wallet_subcommand(
627627
//TODO: return status of wallet registration
628628
Ok(json!({ "hmac": hmac }))
629629
}
630+
HwiSubCommand::Address => {
631+
let address = wallet.next_unused_address(KeychainKind::External);
632+
Ok(json!({ "address": address.address }))
633+
}
630634
},
631635
}
632636
}
@@ -1192,9 +1196,9 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
11921196
}
11931197
};
11941198

1195-
let mut wallet = new_persisted_wallet(network, &mut persister, &wallet_opts)?;
1199+
let mut wallet = new_persisted_wallet(network, &mut persister, wallet_opts)?;
11961200
let result =
1197-
handle_offline_wallet_subcommand(&mut wallet, &wallet_opts, &cli_opts, offline_subcommand.clone())
1201+
handle_offline_wallet_subcommand(&mut wallet, wallet_opts, &cli_opts, offline_subcommand.clone())
11981202
.await?;
11991203
wallet.persist(&mut persister)?;
12001204
result
@@ -1359,6 +1363,7 @@ async fn respond(
13591363
ReplSubCommand::Exit => None,
13601364
};
13611365
if let Some(value) = response {
1366+
let value = serde_json::to_string_pretty(&value).map_err(|e| e.to_string())?;
13621367
writeln!(std::io::stdout(), "{value}").map_err(|e| e.to_string())?;
13631368
std::io::stdout().flush().map_err(|e| e.to_string())?;
13641369
Ok(false)

0 commit comments

Comments
 (0)