Skip to content

Allow multiple accounts with the same view key#1

Open
cordialsys-agent wants to merge 1 commit intomasterfrom
fix/shared-view-key-accounts
Open

Allow multiple accounts with the same view key#1
cordialsys-agent wants to merge 1 commit intomasterfrom
fix/shared-view-key-accounts

Conversation

@cordialsys-agent
Copy link
Copy Markdown
Collaborator

Summary

  • Fix accounts_by_address LMDB comparator to compare the full 64-byte address (view_public + spend_public) instead of only the 32-byte view_public
  • This allows registering multiple addresses that share a view key (e.g., exchange deposit addresses with a shared view key for centralized scanning)

Problem

The DUPSORT comparator on the accounts_by_address table only compared address.view_public. When a second address with the same view key was registered, MDB_GET_BOTH matched 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

  • Register two addresses with different spend keys but the same view key
  • Both appear in list_accounts
  • Both return correct balances via get_address_info
  • Both return correct unspent outputs via get_unspent_outs

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant