fix: default to a subaddress on Monero/Wownero receive - #3508
Open
thomasbuilds wants to merge 1 commit into
Open
fix: default to a subaddress on Monero/Wownero receive#3508thomasbuilds wants to merge 1 commit into
thomasbuilds wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Author
|
Note: I've never used Dart/Flutter so far, this was made entirely by AI. I'm asking reviewers to verify it works as intended, it has never been built or run on my side. I did my best though to verify everything is correct. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Number (if Applicable): Fixes #1645
Description
With "auto generate subaddresses" enabled (the default), a fresh Monero/Wownero wallet offered the account's primary address (index 0) on the receive screen; a subaddress was only minted after the primary had been used. Rotating manually did work, but the next
save()— autosave runs every 30s — reassigned the receive address back to index 0._getAllUnusedAddresses(): generate a subaddress when index 0 is all the account has, and re-read the list afterwards — the old code mapped the pre-generation snapshot and so never returned the address it had just created. Monero additionally keyed the used-check on index 0 rather than on the newest subaddress. Wownero: the length check now precedes.last, which previously threw on an empty list.updateUnusedSubaddress(): take the highest non-zero index explicitly rather than relying on list position. Three different orderings reach this list depending on which method last populated it, andsubaddresses.lastis index 0 on the reversed one.latestAddress,addressForExchange: floored at index 1.latestAddressmatters because the receive view model assigns it towalletAddresses.addressdirectly, racing the reaction that drivesupdateUnusedSubaddress, so both writers have to agree.addressForExchangeis the deposit address handed to swap providers.isPrimary(Monero): derived positionally fromsubaddresses.first, which on the reversed list is the newest address, so the badge landed on the wrong entry. Now compares the index, matching the Bitcoin branches further down the same function. Also drops a.firstthat threw on an empty list (Wownero).The primary stays in the address list and remains reachable, as integrated addresses require. Only the default changes.
Two notes for reviewers:
The Monero
.first→.lastchange is load-bearing, not cosmetic. The old condition asked "is the primary used?", which is permanently false once we stop handing out the primary — rotation would never fire again.This does not reopen CW-705.
usedAddressesis still not exhaustive; nothing here depends on it being complete, since index 0 is excluded unconditionally rather than tested for use. Relevant because #1620 was reverted in #1656 over a large-wallet perf regression, and its successor #1657 needed a newmonero_cAPI and was never merged.Out of scope:
createNewAddress()inwallet_address_util.darthas the same stale list-ordering assumption, causing the rotate button to add the primary tomanualAddresses. Happy to file separately.Pull Request - Checklist