What changed, and why it matters
This change fixes a bug in the Monero wallet's remote-control interface (RPC server). When creating a new wallet from provided keys, the server now saves the current wallet to disk before generating the new in-memory wallet. Previously, if a wallet file was already open, unsaved changes could be lost because the code only saved when it thought a file was associated. The patch removes an unnecessary check so the save always happens, and a test confirms that an existing wallet's custom data survives the operation.
Treat as a routine bug-fix merge. No immediate incident response is required, but users running wallet RPC services should update to avoid potential loss of unsaved wallet metadata when using generate_from_keys. Review whether other RPC handlers have similar conditional store logic.
Security signals we found
Data-loss bug in wallet state management
RPC wallet operation could discard unsaved metadata/attributes
Fix removes conditional logic that skipped wallet persistence
Functional test added to prevent regression
Evidence from the diff
In wallet_rpc_server.cpp, the on_generate_from_keys handler previously called m_wallet->store() only when wallet_file was non-empty. The patch removes that guard, making the store unconditional before generate_from_keys proceeds to create a new in-memory wallet. The functional test verifies that a user-defined attribute set on the current wallet persists after generate_from_keys and reopening without autosave, demonstrating that the pre-operation store now preserves state. This is a data-loss/correctness fix rather than a cryptographic vulnerability.
Changed components
src/wallet/wallet_rpc_server.cpptests/functional_tests/wallet.pyMonero wallet RPC serverInspect captured patch +10 / −2
### src/wallet/wallet_rpc_server.cpp
@@ -4129,8 +4129,7 @@ namespace tools
{
try
{
- if (!wallet_file.empty())
- m_wallet->store();
+ m_wallet->store();
}
catch (const std::exception &e)
{
### tests/functional_tests/wallet.py
@@ -429,6 +429,15 @@ def generate_from_keys(self):
assert res.address == address
assert wallet.query_key('mnemonic').key == seed
+ attribute = 'wallet-rpc.autosave-test'
+ wallet.auto_refresh(False)
+ wallet.set_attribute(attribute, 'stored')
+ wallet.generate_from_keys(address = address, spendkey = spend_key,
+ viewkey = view_key)
+ wallet.open_wallet(filename, autosave_current = False)
+ assert wallet.get_attribute(attribute).value == 'stored'
+ wallet.auto_refresh(True)
+
wallet.close_wallet()
util_resources.remove_wallet_files(filename)
Why this scored 58/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.