Strip leading/trailing whitespace from wallet birthdays
This commit is contained in:
@@ -649,7 +649,7 @@ RestoreSeedPage::RestoreSeedPage(FirstTimeWizard *parent) : QWizardPage(parent)
|
|||||||
|
|
||||||
bool RestoreSeedPage::validatePage() {
|
bool RestoreSeedPage::validatePage() {
|
||||||
// 1. Validate that we do have 24 words
|
// 1. Validate that we do have 24 words
|
||||||
QString seed = form.txtSeed->toPlainText().replace(QRegExp("[ \n\r\t]+"), " ");
|
QString seed = form.txtSeed->toPlainText().replace(QRegExp("[ \n\r\t]+"), " "); //TODO: use .simplified()
|
||||||
auto seedLength = seed.trimmed().split(" ").length();
|
auto seedLength = seed.trimmed().split(" ").length();
|
||||||
qDebug() << __func__ << ": seed length=" << seedLength;
|
qDebug() << __func__ << ": seed length=" << seedLength;
|
||||||
if (seedLength != 24) {
|
if (seedLength != 24) {
|
||||||
@@ -662,11 +662,12 @@ bool RestoreSeedPage::validatePage() {
|
|||||||
// 2. Validate birthday
|
// 2. Validate birthday
|
||||||
QString birthday_str = form.txtBirthday->text();
|
QString birthday_str = form.txtBirthday->text();
|
||||||
bool ok;
|
bool ok;
|
||||||
qint64 birthday = birthday_str.toUInt(&ok);
|
// simplified() Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.
|
||||||
|
qint64 birthday = birthday_str.simplified().toUInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
qDebug() << __func__ << ": Failed to parse wallet birthday=" << birthday_str;
|
qDebug() << __func__ << ": Failed to parse wallet birthday=" << birthday_str;
|
||||||
QMessageBox::warning(this, tr("Failed to parse wallet birthday"),
|
QMessageBox::warning(this, tr("Failed to parse wallet birthday"),
|
||||||
tr("Couldn't understand wallet birthday. This should be a block height from where to rescan the wallet. You can leave it as '0' if you don't know what it should be."),
|
tr("Couldn't understand wallet birthday. This should be a block height from where to rescan the wallet. You can leave the default if you don't know what it should be."),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user