Skip to content

Commit

Permalink
[GUI][Bug] MnWizard: Fix validators for masternode alias and port
Browse files Browse the repository at this point in the history
- alias cannot contain spaces or #. But any other character should be
allowed.
- the port number should be fixed per-network. No need to add a
validator there
Github-Pull: #1545
Rebased-From: 0e3c18f
  • Loading branch information
random-zebra authored and Fuzzbawls committed May 5, 2020
1 parent c3a1611 commit d352817
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/qt/pivx/masternodewizarddialog.cpp
Expand Up @@ -12,6 +12,8 @@
#include <QFile>
#include <QIntValidator>
#include <QHostAddress>
#include <QRegularExpression>
#include <QRegularExpressionValidator>

MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *parent) :
QDialog(parent),
Expand Down Expand Up @@ -50,7 +52,9 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare

ui->lineEditName->setPlaceholderText(tr("e.g user_masternode"));
initCssEditLine(ui->lineEditName);
ui->lineEditName->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9]+"), ui->lineEditName));
// MN alias must not contain spaces or "#" character
QRegularExpression rx("^(?:(?![\\#\\s]).)*");
ui->lineEditName->setValidator(new QRegularExpressionValidator(rx, ui->lineEditName));

// Frame 4
setCssProperty(ui->labelTitle4, "text-title-dialog");
Expand All @@ -62,12 +66,10 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
initCssEditLine(ui->lineEditIpAddress);
initCssEditLine(ui->lineEditPort);
ui->stackedWidget->setCurrentIndex(pos);
ui->lineEditPort->setValidator(new QIntValidator(0, 9999999, ui->lineEditPort));
ui->lineEditPort->setEnabled(false); // use default port number
if (walletModel->isRegTestNetwork()) {
ui->lineEditPort->setEnabled(false);
ui->lineEditPort->setText("51476");
} else if (walletModel->isTestNetwork()) {
ui->lineEditPort->setEnabled(false);
ui->lineEditPort->setText("51474");
} else {
ui->lineEditPort->setText("51472");
Expand Down

0 comments on commit d352817

Please sign in to comment.