check for bad wallet type

pull/242/head
larteyoh 2 months ago
parent 3b8058620f
commit 3c82d42b6c

@ -558,6 +558,9 @@ Page {
} else if(loginError == Enum.LoginError.WalletIsOpenedByAnotherProgram) {
messageBox.text = qsTr("Wallet is opened by another program")
messageBox.open()
} else if(loginError == Enum.LoginError.WalletBadWalletType) {
messageBox.text = qsTr("Bad wallet type")
messageBox.open()
} else if(loginError == Enum.LoginError.DaemonIsNotConnected) {
messageBox.text = qsTr("Daemon (neromon) is not connected")
messageBox.open()

@ -169,10 +169,12 @@ int neroshop::Wallet::open(const std::string& path, const std::string& password)
} catch (const std::exception& e) {
std::string error_msg = e.what();
neroshop::print(error_msg, 1);//tools::error::invalid_password
if(neroshop::string::contains(error_msg, "wallet cannot be opened")) {
if(neroshop::string::contains(error_msg, "wallet cannot be opened as")) {
return static_cast<int>(WalletError::BadNetworkType);
} else if(neroshop::string::contains(error_msg, "invalid password")) {
return static_cast<int>(WalletError::WrongPassword);
} else if(neroshop::string::contains(error_msg, "Invalid decimal point specification")) {
return static_cast<int>(WalletError::BadWalletType);
} else {
return static_cast<int>(WalletError::IsOpenedByAnotherProgram);
}

@ -38,6 +38,7 @@ enum class WalletError {
DoesNotExist,
BadNetworkType,
IsNotOpened, // monero_wallet_obj is nullptr
BadWalletType,
};
class Wallet : public monero_wallet_listener {

@ -1819,6 +1819,8 @@ int neroshop::Backend::loginWithWalletFile(WalletController* wallet_controller,
return static_cast<int>(EnumWrapper::LoginError::WalletBadNetworkType);
if(wallet_error == static_cast<int>(WalletError::IsNotOpened))
return static_cast<int>(EnumWrapper::LoginError::WalletIsNotOpened);
if(wallet_error == static_cast<int>(WalletError::BadWalletType))
return static_cast<int>(EnumWrapper::LoginError::WalletBadWalletType);
}
return static_cast<int>(EnumWrapper::LoginError::Ok);
});

@ -21,6 +21,7 @@ public:
DoesNotExist,
BadNetworkType,
IsNotOpened, // monero_wallet_obj is nullptr
BadWalletType,
};
Q_ENUM(WalletError)
@ -43,6 +44,7 @@ public:
WalletDoesNotExist = static_cast<int>(WalletError::DoesNotExist),
WalletBadNetworkType = static_cast<int>(WalletError::BadNetworkType),
WalletIsNotOpened = static_cast<int>(WalletError::IsNotOpened),
WalletBadWalletType = static_cast<int>(WalletError::BadWalletType),
DaemonIsNotConnected = 10,

Loading…
Cancel
Save