Skip to content

Commit 6c911d7

Browse files
committed
feat(hwi): add address subcommand for hwi
fix clippy issues
1 parent 5d3a1fd commit 6c911d7

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
@@ -474,6 +474,8 @@ pub enum HwiSubCommand {
474474
Devices,
475475
/// Register hardware wallet
476476
Register,
477+
/// Generate address
478+
Address,
477479
}
478480

479481
/// Subcommands available in REPL mode.

src/handlers.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,10 @@ pub async fn handle_offline_wallet_subcommand(
631631
//TODO: return status of wallet registration
632632
Ok(json!({ "hmac": hmac }))
633633
}
634+
HwiSubCommand::Address => {
635+
let address = wallet.next_unused_address(KeychainKind::External);
636+
Ok(json!({ "address": address.address }))
637+
}
634638
},
635639
}
636640
}
@@ -1197,9 +1201,9 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
11971201
}
11981202
};
11991203

1200-
let mut wallet = new_persisted_wallet(network, &mut persister, &wallet_opts)?;
1204+
let mut wallet = new_persisted_wallet(network, &mut persister, wallet_opts)?;
12011205
let result =
1202-
handle_offline_wallet_subcommand(&mut wallet, &wallet_opts, &cli_opts, offline_subcommand.clone())
1206+
handle_offline_wallet_subcommand(&mut wallet, wallet_opts, &cli_opts, offline_subcommand.clone())
12031207
.await?;
12041208
wallet.persist(&mut persister)?;
12051209
result
@@ -1355,6 +1359,7 @@ async fn respond(
13551359
ReplSubCommand::Exit => None,
13561360
};
13571361
if let Some(value) = response {
1362+
let value = serde_json::to_string_pretty(&value).map_err(|e| e.to_string())?;
13581363
writeln!(std::io::stdout(), "{value}").map_err(|e| e.to_string())?;
13591364
std::io::stdout().flush().map_err(|e| e.to_string())?;
13601365
Ok(false)

0 commit comments

Comments
 (0)