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)
Context
Surfaced by CodeRabbit during review of #711. Pre-existing behavior — the method moved from an inherent
implonManagedCoreAccountto a trait default inManagedAccountTrait(#728), with the same logic.Problem
For Standard accounts,
ManagedAccountTrait::get_next_receive_address_indexreturnsSome(highest_generated + 1)when every generated address has been used. For single-pool account variants (CoinJoin, Identity*, AssetLock*, Provider*, DashPay*, PlatformPayment),get_next_address_indexreturns `None` in the same exhausted-pool case: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:
Files
key-wallet/src/managed_account/managed_account_trait.rs(theget_next_address_indexdefault impl)Original review thread: #711 (review comment 3187368612)