Browse Source

Strip leading/trailing whitespace from wallet birthdays

pull/84/head
Duke Leto 2 years ago
parent
commit
9e8e95200c
  1. 7
      src/firsttimewizard.cpp

7
src/firsttimewizard.cpp

@ -649,7 +649,7 @@ RestoreSeedPage::RestoreSeedPage(FirstTimeWizard *parent) : QWizardPage(parent)
bool RestoreSeedPage::validatePage() {
// 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();
qDebug() << __func__ << ": seed length=" << seedLength;
if (seedLength != 24) {
@ -662,11 +662,12 @@ bool RestoreSeedPage::validatePage() {
// 2. Validate birthday
QString birthday_str = form.txtBirthday->text();
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) {
qDebug() << __func__ << ": Failed to parse wallet birthday=" << birthday_str;
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);
return false;
}

Loading…
Cancel
Save