Allow multiple accounts with the same view key#1
Open
cordialsys-agent wants to merge 1 commit intomasterfrom
Open
Allow multiple accounts with the same view key#1cordialsys-agent wants to merge 1 commit intomasterfrom
cordialsys-agent wants to merge 1 commit intomasterfrom
Conversation
The accounts_by_address LMDB table comparator only compared view_public (32 bytes), causing MDB_GET_BOTH lookups to match any account sharing the same view key. This prevented registering multiple addresses that share a view key (e.g., exchange deposit addresses with a shared view key for centralized scanning). Fix: compare the full account_address (view_public + spend_public, 64 bytes) so each address is uniquely indexed regardless of whether they share a view key. Note: this changes the LMDB sort order, requiring a database wipe and rescan when upgrading.
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.
Summary
accounts_by_addressLMDB comparator to compare the full 64-byte address (view_public + spend_public) instead of only the 32-byte view_publicProblem
The DUPSORT comparator on the
accounts_by_addresstable only comparedaddress.view_public. When a second address with the same view key was registered,MDB_GET_BOTHmatched the existing entry and returned "account already exists" (500 Internal Server Error via REST, or "Account with specified address already exists" via CLI).Fix
One-line change:
MONERO_COMPARE(account_by_address, address.view_public)→MONERO_COMPARE(account_by_address, address)Breaking change
This changes the LMDB sort order, requiring a database wipe and rescan when upgrading.
Test plan
list_accountsget_address_infoget_unspent_outs