wallet rpc: restore callbacks when reopening wallets
What changed, and why it matters
This commit fixes a state-tracking bug in a Monero wallet library. When a wallet client object was reused to open or create another wallet, an internal 'closed' flag was not reset. This could leave event/callback listeners disabled on the reopened wallet, causing the application to miss important notifications such as incoming transactions or sync updates.
Review callback and listener restoration logic tied to isClosed, ensure closeWallet() correctly sets isClosed=true and clears state, and add tests covering reuse of a MoneroWalletRpc client to open/create multiple wallets. No immediate emergency response is indicated from this diff alone.
Security signals we found
State-management bug in wallet lifecycle
Missing reset of closed flag on reused RPC client
Potential loss of transaction/sync callbacks after wallet reopen
No input validation or cryptographic weakness visible in diff
Evidence from the diff
MoneroWalletRpc tracks wallet lifecycle with an isClosed boolean. When a wallet is closed, callbacks are presumably torn down and isClosed set true. The openWallet() and createWallet() paths did not reset isClosed to false after successfully opening/creating a new wallet on a reused client. Consequently, code paths that guard on isClosed (e.g., callback registration/restore) would treat the newly opened wallet as still closed, breaking event delivery. The patch adds isClosed = false in both methods after the wallet is opened/created.
Changed components
src/main/java/monero/wallet/MoneroWalletRpc.javaMoneroWalletRpc.openWallet()MoneroWalletRpc.createWallet()Inspect captured patch +2 / −0
### src/main/java/monero/wallet/MoneroWalletRpc.java
@@ -303,6 +303,7 @@ public MoneroWalletRpc openWallet(MoneroWalletConfig config) {
rpc.sendJsonRequest("open_wallet", params);
clear();
path = config.getPath();
+ isClosed = false;
// set connection manager or server
if (config.getConnectionManager() != null) {
@@ -372,6 +373,7 @@ public MoneroWalletRpc createWallet(MoneroWalletConfig config) {
if (config.getSeed() != null) createWalletFromSeed(config);
else if (config.getPrivateSpendKey() != null || config.getPrimaryAddress() != null) createWalletFromKeys(config);
else createWalletRandom(config);
+ isClosed = false;
// set connection manager or server
if (config.getConnectionManager() != null) {Why this scored 26/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.