optimize import rescanning
This commit is contained in:
@@ -393,23 +393,30 @@ void MainWindow::importPrivKey() {
|
|||||||
|
|
||||||
pui.helpLbl->setText(QString() %
|
pui.helpLbl->setText(QString() %
|
||||||
"Please paste your private keys (z-Addr or t-Addr) here, one per line.\n" %
|
"Please paste your private keys (z-Addr or t-Addr) here, one per line.\n" %
|
||||||
"The keys will be imported into your connected zcashd node");
|
"The keys will be imported into your connected zcashd node");
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) {
|
if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) {
|
||||||
auto keys = pui.privKeyTxt->toPlainText().trimmed().split("\n");
|
auto keys = pui.privKeyTxt->toPlainText().trimmed().split("\n");
|
||||||
|
|
||||||
|
auto fnFinished = [=] (auto) {
|
||||||
|
qDebug() << "finished";
|
||||||
|
ui->statusBar->showMessage("Key import rescan finished");
|
||||||
|
};
|
||||||
|
|
||||||
for (int i=0; i < keys.length(); i++) {
|
for (int i=0; i < keys.length(); i++) {
|
||||||
auto key = keys[i].trimmed();
|
auto key = keys[i].trimmed();
|
||||||
if (key.startsWith("S") ||
|
if (key.startsWith("S") ||
|
||||||
key.startsWith("secret")) { // Z key
|
key.startsWith("secret")) { // Z key
|
||||||
rpc->importZPrivKey(key, [=] (auto) {} );
|
rpc->importZPrivKey(key, i == key.length() -1, fnFinished);
|
||||||
} else { // T Key
|
} else { // T Key
|
||||||
rpc->importTPrivKey(key, [=] (auto) {} );
|
rpc->importTPrivKey(key, i == key.length() -1, fnFinished);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox::information(this,
|
QMessageBox::information(this,
|
||||||
"Imported", "The keys were imported. It may be a while to rescan the blockchain with the new keys.",
|
"Imported", "The keys were imported. It may take several minutes to rescan the blockchain with the new keys for your balance to be shown accurately.",
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupBalancesTab() {
|
void MainWindow::setupBalancesTab() {
|
||||||
|
|||||||
@@ -184,24 +184,24 @@ void RPC::getTPrivKey(QString addr, const std::function<void(json)>& cb) {
|
|||||||
doRPC(payload, cb);
|
doRPC(payload, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPC::importZPrivKey(QString addr, const std::function<void(json)>& cb) {
|
void RPC::importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) {
|
||||||
json payload = {
|
json payload = {
|
||||||
{"jsonrpc", "1.0"},
|
{"jsonrpc", "1.0"},
|
||||||
{"id", "someid"},
|
{"id", "someid"},
|
||||||
{"method", "z_importkey"},
|
{"method", "z_importkey"},
|
||||||
{"params", { addr.toStdString() }},
|
{"params", { addr.toStdString(), (rescan? "yes" : "no") }},
|
||||||
};
|
};
|
||||||
|
|
||||||
doRPC(payload, cb);
|
doRPC(payload, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RPC::importTPrivKey(QString addr, const std::function<void(json)>& cb) {
|
void RPC::importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) {
|
||||||
json payload = {
|
json payload = {
|
||||||
{"jsonrpc", "1.0"},
|
{"jsonrpc", "1.0"},
|
||||||
{"id", "someid"},
|
{"id", "someid"},
|
||||||
{"method", "importprivkey"},
|
{"method", "importprivkey"},
|
||||||
{"params", { addr.toStdString() }},
|
{"params", { addr.toStdString(), (rescan? "yes" : "no") }},
|
||||||
};
|
};
|
||||||
|
|
||||||
doRPC(payload, cb);
|
doRPC(payload, cb);
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ public:
|
|||||||
|
|
||||||
void getZPrivKey(QString addr, const std::function<void(json)>& cb);
|
void getZPrivKey(QString addr, const std::function<void(json)>& cb);
|
||||||
void getTPrivKey(QString addr, const std::function<void(json)>& cb);
|
void getTPrivKey(QString addr, const std::function<void(json)>& cb);
|
||||||
void importZPrivKey(QString addr, const std::function<void(json)>& cb);
|
void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
|
||||||
void importTPrivKey(QString addr, const std::function<void(json)>& cb);
|
void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
|
||||||
|
|
||||||
Turnstile* getTurnstile() { return turnstile; }
|
Turnstile* getTurnstile() { return turnstile; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user