From dea4d706cd84e945127a48fa2dc60202ba7f6e6a Mon Sep 17 00:00:00 2001 From: emma31-dev Date: Sat, 17 Oct 2026 09:39:40 +0100 Subject: [PATCH] Change unused address output to list Return all unused external addresses instead of only the next one, wrapping results in ListResult. --- CHANGELOG.md | 1 + src/handlers/offline.rs | 9 ++++++--- tests/integration/offline.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b68802b3..1c7a78f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details. - Routed compact filter (cbf) traffic through the configured SOCKS5 proxy - Rejected `--proxy` on the `rpc` backend, and unsupported proxy options (`--proxy_auth`, `--timeout`) on the `rpc` and `cbf` backends, instead of silently ignoring them - Fixed `compile` rejecting policies that are valid for the requested script type +- Changed unused address output to a list ## [4.0.0] diff --git a/src/handlers/offline.rs b/src/handlers/offline.rs index 15cdd26b..63951cd6 100644 --- a/src/handlers/offline.rs +++ b/src/handlers/offline.rs @@ -111,12 +111,15 @@ impl AppCommand>> for NewAddressCommand { pub struct UnusedAddressCommand; impl AppCommand>> for UnusedAddressCommand { - type Output = AddressResult; + type Output = ListResult; fn execute(&self, ctx: &mut AppContext>) -> Result { let wallet = &mut ctx.state.wallet; - let address_info = wallet.next_unused_address(KeychainKind::External); - Ok(AddressResult::from(address_info)) + let address_info = wallet + .list_unused_addresses(KeychainKind::External) + .map(AddressResult::from) + .collect(); + Ok(ListResult::new(address_info)) } } diff --git a/tests/integration/offline.rs b/tests/integration/offline.rs index 417bf72b..e00ba941 100644 --- a/tests/integration/offline.rs +++ b/tests/integration/offline.rs @@ -50,13 +50,20 @@ mod test_offline { let (cli, mut cmd_init) = setup_wallet_config(); cmd_init.assert().success(); + // `unused-address` before revealing an address + cli.wallet_cmd(&["--wallet", WALLET_NAME, "unused_address"]) + .assert() + .success() + .stdout(predicate::str::contains("\"count\"")) + .stdout(predicate::str::contains("\"items\": []")); + // new address cli.wallet_cmd(&["--wallet", WALLET_NAME, "new_address"]) .assert() .success() .stdout(predicate::str::contains("\"address\":")); - // `unused-address` + // `unused-address` now returns the revealed, unused address cli.wallet_cmd(&["--wallet", WALLET_NAME, "unused_address"]) .assert() .success()