Skip to content

key-wallet: get_next_address_index returns None for exhausted single-pool accounts #730

Closed

Description

@QuantumExplorer

Context

Surfaced by CodeRabbit during review of #711. Pre-existing behavior — the method moved from an inherent impl on ManagedCoreAccount to a trait default in ManagedAccountTrait (#728), with the same logic.

Problem

For Standard accounts, ManagedAccountTrait::get_next_receive_address_index returns Some(highest_generated + 1) when every generated address has been used. For single-pool account variants (CoinJoin, Identity*, AssetLock*, Provider*, DashPay*, PlatformPayment), get_next_address_index returns `None` in the same exhausted-pool case:

addresses.unused_addresses().first().and_then(|addr| addresses.address_index(addr))

That's inconsistent — same predicate ("what's the next index I can derive") returns different shapes depending on the account variant.

Suggested fix

Mirror the Standard-account behavior:

if let Some(addr) = addresses.unused_addresses().first() {
    addresses.address_index(addr)
} else {
    let stats = addresses.stats();
    Some(stats.highest_generated.map(|h| h + 1).unwrap_or(0))
}

Files

  • key-wallet/src/managed_account/managed_account_trait.rs (the get_next_address_index default impl)

Original review thread: #711 (review comment 3187368612)

Activity

  1. added
    enhancement
    on May 5, 2026
  2. self-assigned this
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions