diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6562979..4bd099d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -209,16 +209,27 @@ MainWindow::MainWindow(QWidget *parent) : config->server = Settings::getInstance()->getSettings().server; // 3. Attempt to restore wallet with the seed phrase { - char* resp = litelib_initialize_new_from_phrase(config->dangerous, config->server.toStdString().c_str(), - seed.toStdString().c_str(), birthday, number); - QString reply = litelib_process_response(resp); - - if (reply.toUpper().trimmed() != "OK") { - QMessageBox::warning(this, tr("Failed to restore wallet"), + QString reply = ""; + try { + char* resp = litelib_initialize_new_from_phrase(config->dangerous, config->server.toStdString().c_str(), + seed.toStdString().c_str(), birthday, number); + reply = litelib_process_response(resp); + + if (reply.toUpper().trimmed() != "OK") { + QMessageBox::warning(this, tr("Failed to restore wallet"), + tr("Couldn't restore the wallet") + "\n" + reply, + QMessageBox::Ok); + return false; + } + } catch (const std::exception& e) { + //TODO: try another server with getRandomServer() + qDebug() << __func__ << ": caught an exception! Bailing out: " << e.what(); + QMessageBox::warning(this, tr("Failed to restore wallet"), tr("Couldn't restore the wallet") + "\n" + reply, QMessageBox::Ok); - - } + return false; + } + } // 4. Finally attempt to save the wallet