WizardController: abort saving the wallet if setPassword fails
WizardController: set password for restored temp wallet
This commit is contained in:
1 parent
485a102ce5
commit
dabf417815
3 files changed
+14
-9
No files matched your search
@@ -142,19 +142,19 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password
|
||||
}
|
||||
|
||||
|
||||
Wallet *WalletManager::recoveryWallet(const QString &path, const QString &seed, const QString &seed_offset, NetworkType::Type nettype, quint64 restoreHeight, quint64 kdfRounds)
|
||||
Wallet *WalletManager::recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset, NetworkType::Type nettype, quint64 restoreHeight, quint64 kdfRounds)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_currentWallet) {
|
||||
qDebug() << "Closing open m_currentWallet" << m_currentWallet;
|
||||
delete m_currentWallet;
|
||||
}
|
||||
Monero::Wallet * w = m_pimpl->recoveryWallet(path.toStdString(), "", seed.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight, kdfRounds, seed_offset.toStdString());
|
||||
Monero::Wallet * w = m_pimpl->recoveryWallet(path.toStdString(), password.toStdString(), seed.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight, kdfRounds, seed_offset.toStdString());
|
||||
m_currentWallet = new Wallet(w);
|
||||
return m_currentWallet;
|
||||
}
|
||||
|
||||
Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &language, NetworkType::Type nettype,
|
||||
Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &password, const QString &language, NetworkType::Type nettype,
|
||||
const QString &address, const QString &viewkey, const QString &spendkey,
|
||||
quint64 restoreHeight, quint64 kdfRounds)
|
||||
{
|
||||
@@ -164,7 +164,7 @@ Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &
|
||||
delete m_currentWallet;
|
||||
m_currentWallet = NULL;
|
||||
}
|
||||
Monero::Wallet * w = m_pimpl->createWalletFromKeys(path.toStdString(), "", language.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight,
|
||||
Monero::Wallet * w = m_pimpl->createWalletFromKeys(path.toStdString(), password.toStdString(), language.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight,
|
||||
address.toStdString(), viewkey.toStdString(), spendkey.toStdString(), kdfRounds);
|
||||
m_currentWallet = new Wallet(w);
|
||||
return m_currentWallet;
|
||||
|
||||
@@ -85,11 +85,11 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
|
||||
|
||||
// wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = ""
|
||||
Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &seed, const QString &seed_offset,
|
||||
Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset,
|
||||
NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1);
|
||||
|
||||
Q_INVOKABLE Wallet * createWalletFromKeys(const QString &path,
|
||||
const QString &password,
|
||||
const QString &language,
|
||||
NetworkType::Type nettype,
|
||||
const QString &address,
|
||||
|
||||
@@ -388,7 +388,12 @@ Rectangle {
|
||||
new_wallet_filename = appWindow.accountsDir + new_wallet_filename;
|
||||
}
|
||||
console.log("saving new wallet to", new_wallet_filename);
|
||||
wizardController.m_wallet.setPassword(wizardController.walletOptionsPassword);
|
||||
if (!wizardController.m_wallet.setPassword(wizardController.walletOptionsPassword)) {
|
||||
appWindow.showStatusMessage(qsTr("Failed to set the wallet password"), 3);
|
||||
wizardStateView.wizardRestoreWallet4View.wizardNav.btnNext.enabled = true;
|
||||
wizardStateView.wizardCreateWallet4View.wizardNav.btnNext.enabled = true;
|
||||
return;
|
||||
}
|
||||
wizardController.m_wallet.storeAsync(handler, new_wallet_filename);
|
||||
}
|
||||
|
||||
@@ -404,9 +409,9 @@ Rectangle {
|
||||
var wallet = ''
|
||||
// From seed or keys
|
||||
if(wizardController.walletRestoreMode === 'seed')
|
||||
wallet = walletManager.recoveryWallet('', wizardController.walletOptionsSeed, wizardController.walletOptionsSeedOffset, nettype, restoreHeight, kdfRounds);
|
||||
wallet = walletManager.recoveryWallet('', oshelper.randomPassword(), wizardController.walletOptionsSeed, wizardController.walletOptionsSeedOffset, nettype, restoreHeight, kdfRounds);
|
||||
else
|
||||
wallet = walletManager.createWalletFromKeys('', persistentSettings.language_wallet, nettype,
|
||||
wallet = walletManager.createWalletFromKeys('', oshelper.randomPassword(), persistentSettings.language_wallet, nettype,
|
||||
wizardController.walletOptionsRecoverAddress, wizardController.walletOptionsRecoverViewkey,
|
||||
wizardController.walletOptionsRecoverSpendkey, restoreHeight, kdfRounds)
|
||||
|
||||
|
||||
Reference in new issue
Block a user