Handle case where private keys are multiline
This commit is contained in:
parent
b792679a93
commit
1456811842
|
@ -830,7 +830,7 @@ void MainWindow::doImport(QList<QString>* keys) {
|
|||
keys->pop_front();
|
||||
bool rescan = keys->isEmpty();
|
||||
|
||||
if (key.startsWith("S") ||
|
||||
if (key.startsWith("SK") ||
|
||||
key.startsWith("secret")) { // Z key
|
||||
rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
|
||||
} else {
|
||||
|
@ -954,6 +954,16 @@ void MainWindow::importPrivKey() {
|
|||
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
|
||||
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) {
|
||||
QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive);
|
||||
QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive);
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
bool isSaplingAddress(QString addr);
|
||||
bool isSproutAddress(QString addr);
|
||||
|
||||
bool isValidSaplingPrivateKey(QString pk);
|
||||
|
||||
bool isSyncing();
|
||||
void setSyncing(bool syncing);
|
||||
|
||||
|
|
Loading…
Reference in New Issue