What changed, and why it matters
This change fixes a bug in the Monero GUI wallet where testnet and stagenet wallets could not be reopened from the recent wallets list. Previously, the wallet's network type was being overwritten too early or set incorrectly, causing the wrong network to be detected. The fix passes a fallback network type and delays setting the network type until the actual wallet file path is known. There is no direct evidence this is a security vulnerability, but opening a wallet on the wrong network could lead to user confusion or accidental use of the wrong wallet/account.
Treat as a functional bug fix with minor security hygiene value. No urgent security response is indicated from the diff alone. If maintaining a fork, backport to ensure users do not accidentally open wallets on unintended networks. Consider whether network-type confusion could be exploited socially (e.g., tricking a user into operating on the wrong chain), but no exploit code path is visible in this commit.
Security signals we found
Network type misclassification could cause wallet to open on wrong chain
Recent-wallet metadata no longer trusted as authoritative for network type
Fallback behavior added when file-based network detection fails
No explicit security framing in commit message or diff
Evidence from the diff
The patch modifies OSHelper::getNetworkTypeFromFile() to accept a fallbackNetworkType parameter and return it when the address field from getNetworkTypeAndAddressFromFile() is empty (i.e., the network type could not be reliably determined). In WizardController.qml, the persistentSettings.nettype assignment is moved from the file dialog’s onAccepted handler into openWalletFile(), where it uses the resolved wallet_path and the current persistentSettings.nettype as fallback. In WizardOpenWallet1.qml, openSelectedWalletFile() no longer takes or sets networktype from the recent-list metadata, instead delegating network detection to the updated helper. This prevents testnet/stagenet wallets from being misidentified as mainnet when reopened.
Changed components
src/main/oshelper.cppsrc/main/oshelper.hwizard/WizardController.qmlwizard/WizardOpenWallet1.qmlInspect captured patch +10 / −9
### src/main/oshelper.cpp
@@ -304,13 +304,14 @@ std::pair<quint8, QString> OSHelper::getNetworkTypeAndAddressFromFile(const QStr
return std::make_pair(networkType, address);
}
-quint8 OSHelper::getNetworkTypeFromFile(const QString &keysPath) const
+quint8 OSHelper::getNetworkTypeFromFile(const QString &keysPath, quint8 fallbackNetworkType) const
{
QString walletPath = keysPath;
if(keysPath.endsWith(".keys")){
walletPath = keysPath.mid(0,keysPath.length()-5);
}
- return getNetworkTypeAndAddressFromFile(walletPath).first;
+ const auto networkTypeAndAddress = getNetworkTypeAndAddressFromFile(walletPath);
+ return networkTypeAndAddress.second.isEmpty() ? fallbackNetworkType : networkTypeAndAddress.first;
}
void OSHelper::openSeedTemplate() const
### src/main/oshelper.h
@@ -53,7 +53,7 @@ class OSHelper : public QObject
Q_INVOKABLE bool isWritableDirectory(const QString &path) const;
Q_INVOKABLE QString randomPassword(int numBytes = 32) const;
Q_INVOKABLE bool isCapsLock() const;
- Q_INVOKABLE quint8 getNetworkTypeFromFile(const QString &keysPath) const;
+ Q_INVOKABLE quint8 getNetworkTypeFromFile(const QString &keysPath, quint8 fallbackNetworkType) const;
Q_INVOKABLE void openSeedTemplate() const;
bool installed() const;
### wizard/WizardController.qml
@@ -328,7 +328,6 @@ Rectangle {
onAccepted: {
var keysPath = walletManager.urlToLocalPath(fileDialog.selectedFile)
- persistentSettings.nettype = oshelper.getNetworkTypeFromFile(keysPath);
wizardController.openWalletFile(keysPath);
}
onRejected: {
@@ -544,6 +543,8 @@ Rectangle {
else
persistentSettings.wallet_path = fn;
+ persistentSettings.nettype = oshelper.getNetworkTypeFromFile(persistentSettings.wallet_path, persistentSettings.nettype);
+
if(isIOS)
persistentSettings.wallet_path = persistentSettings.wallet_path.replace(appWindow.accountsDir, "");
### wizard/WizardOpenWallet1.qml
@@ -148,8 +148,7 @@ Rectangle {
}
}
- function openSelectedWalletFile(networktype, path) {
- persistentSettings.nettype = parseInt(networktype);
+ function openSelectedWalletFile(path) {
wizardController.openWalletFile(path);
}
@@ -186,8 +185,8 @@ Rectangle {
Keys.onBacktabPressed: recentList.moveUp(index);
Keys.onDownPressed: recentList.moveDown(index);
Keys.onTabPressed: recentList.moveDown(index);
- Keys.onEnterPressed: recentList.openSelectedWalletFile(networktype, path);
- Keys.onReturnPressed: recentList.openSelectedWalletFile(networktype, path);
+ Keys.onEnterPressed: recentList.openSelectedWalletFile(path);
+ Keys.onReturnPressed: recentList.openSelectedWalletFile(path);
Rectangle {
height: 1
@@ -317,7 +316,7 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
- onClicked: recentList.openSelectedWalletFile(networktype, path);
+ onClicked: recentList.openSelectedWalletFile(path);
}
}
}Why this scored 23/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.