|
|
@ -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); |
|
|
|