Browse Source

Try another server if current is down when creating new seed

pull/125/head
Duke 1 year ago
parent
commit
3f8ae1f9d7
  1. 20
      src/firsttimewizard.cpp

20
src/firsttimewizard.cpp

@ -293,10 +293,26 @@ void NewSeedPage::initializePage() {
// Call the library to create a new wallet.
qDebug() << __func__;
char* resp = litelib_initialize_new(parent->dangerous,parent->server.toStdString().c_str());
QString reply = litelib_process_response(resp);
QString reply = "";
try {
char* resp = litelib_initialize_new(parent->dangerous,parent->server.toStdString().c_str());
reply = litelib_process_response(resp);
} catch (const std::exception& e) {
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
}
qDebug() << __func__ << ": reply=" << reply;
if (reply.toUpper().trimmed() != "OK") {
qDebug() << "Lite server " << parent->server << " is down, getting a random one";
parent->server = Settings::getRandomServer();
qDebug() << __func__ << ": new server is " << parent->server;
// retry with the new server
char* resp = litelib_initialize_new(parent->dangerous,parent->server.toStdString().c_str());
reply = litelib_process_response(resp);
}
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false);
if (parsed.is_discarded() || parsed.is_null() || parsed.find("seed") == parsed.end()) {
form.txtSeed->setPlainText(tr("Error creating a wallet") + "\n" + reply);

Loading…
Cancel
Save