Handle case where private keys are multiline
This commit is contained in:
@@ -830,7 +830,7 @@ void MainWindow::doImport(QList<QString>* keys) {
|
|||||||
keys->pop_front();
|
keys->pop_front();
|
||||||
bool rescan = keys->isEmpty();
|
bool rescan = keys->isEmpty();
|
||||||
|
|
||||||
if (key.startsWith("S") ||
|
if (key.startsWith("SK") ||
|
||||||
key.startsWith("secret")) { // Z key
|
key.startsWith("secret")) { // Z key
|
||||||
rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
|
rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
|
||||||
} else {
|
} else {
|
||||||
@@ -954,6 +954,16 @@ void MainWindow::importPrivKey() {
|
|||||||
return key.trimmed().split(" ")[0];
|
return key.trimmed().split(" ")[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Special case.
|
||||||
|
// Sometimes, when importing from a paperwallet or such, the key is split by newlines, and might have
|
||||||
|
// been pasted like that. So check to see if the whole thing is one big private key
|
||||||
|
if (Settings::getInstance()->isValidSaplingPrivateKey(keys->join(""))) {
|
||||||
|
auto multiline = keys;
|
||||||
|
keys = new QList<QString>();
|
||||||
|
keys->append(multiline->join(""));
|
||||||
|
delete multiline;
|
||||||
|
}
|
||||||
|
|
||||||
// Start the import. The function takes ownership of keys
|
// Start the import. The function takes ownership of keys
|
||||||
QTimer::singleShot(1, [=]() {doImport(keys);});
|
QTimer::singleShot(1, [=]() {doImport(keys);});
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,16 @@ QString Settings::getZboardAddr() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::isValidSaplingPrivateKey(QString pk) {
|
||||||
|
if (isTestnet()) {
|
||||||
|
QRegExp zspkey("^secret-extended-key-test[0-9a-z]{278}$", Qt::CaseInsensitive);
|
||||||
|
return zspkey.exactMatch(pk);
|
||||||
|
} else {
|
||||||
|
QRegExp zspkey("^secret-extended-key-main[0-9a-z]{278}$", Qt::CaseInsensitive);
|
||||||
|
return zspkey.exactMatch(pk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::isValidAddress(QString addr) {
|
bool Settings::isValidAddress(QString addr) {
|
||||||
QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive);
|
QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive);
|
||||||
QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive);
|
QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ public:
|
|||||||
bool isSaplingAddress(QString addr);
|
bool isSaplingAddress(QString addr);
|
||||||
bool isSproutAddress(QString addr);
|
bool isSproutAddress(QString addr);
|
||||||
|
|
||||||
|
bool isValidSaplingPrivateKey(QString pk);
|
||||||
|
|
||||||
bool isSyncing();
|
bool isSyncing();
|
||||||
void setSyncing(bool syncing);
|
void setSyncing(bool syncing);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user