diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 6f1cead258cdc0..4894349ea3f3ae 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -113,6 +113,11 @@ int ClientModel::getNumBlocksAtStartup() return numBlocksAtStartup; } +unsigned int ClientModel::getNetworkPort() +{ + return Params().GetDefaultPort(); +} + quint64 ClientModel::getTotalBytesRecv() const { if(!g_connman) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index dc9c4cc34f0107..ad41358ac50ae1 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -62,6 +62,8 @@ class ClientModel : public QObject int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; int getNumBlocksAtStartup(); + unsigned int getNetworkPort(); + // from cached block index int getNumBlocks(); QDateTime getLastBlockDate() const; diff --git a/src/qt/pivx/masternodeswidget.cpp b/src/qt/pivx/masternodeswidget.cpp index 4c85aef7c5ed1d..530e5792c8f827 100644 --- a/src/qt/pivx/masternodeswidget.cpp +++ b/src/qt/pivx/masternodeswidget.cpp @@ -414,7 +414,7 @@ void MasterNodesWidget::onCreateMNClicked() .arg(GUIUtil::formatBalance(mnCollateralAmount, BitcoinUnits::PIV))); return; } - MasterNodeWizardDialog* dialog = new MasterNodeWizardDialog(walletModel, mnModel, window); + MasterNodeWizardDialog* dialog = new MasterNodeWizardDialog(walletModel, mnModel, clientModel, window); connect(dialog, &MasterNodeWizardDialog::message, this, &PWidget::emitMessage); do { showHideOp(true); diff --git a/src/qt/pivx/masternodewizarddialog.cpp b/src/qt/pivx/masternodewizarddialog.cpp index d799952f55045c..8d8488caa986d5 100644 --- a/src/qt/pivx/masternodewizarddialog.cpp +++ b/src/qt/pivx/masternodewizarddialog.cpp @@ -59,11 +59,12 @@ static void setCardShadow(QWidget* edit) edit->setGraphicsEffect(shadowEffect); } -MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel* model, MNModel* _mnModel, QWidget *parent) : +MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel* model, MNModel* _mnModel, ClientModel* _clientModel, QWidget *parent) : FocusedDialog(parent), ui(new Ui::MasterNodeWizardDialog), walletModel(model), - mnModel(_mnModel) + mnModel(_mnModel), + clientModel(_clientModel) { ui->setupUi(this); setStyleSheet(parent->styleSheet()); @@ -145,17 +146,9 @@ void MasterNodeWizardDialog::initServicePage() initCssEditLine(ui->lineEditIpAddress); initCssEditLine(ui->lineEditPort); ui->stackedWidget->setCurrentIndex(pos); - if (walletModel->isRegTestNetwork()) { - ui->lineEditPort->setEnabled(true); - ui->lineEditPort->setText("51476"); - } else { - ui->lineEditPort->setEnabled(false); // fixed to default port number - if (walletModel->isTestNetwork()) { - ui->lineEditPort->setText("51474"); - } else { - ui->lineEditPort->setText("51472"); - } - } + // Fixed to default port number for mainnet and testnet. + ui->lineEditPort->setEnabled(walletModel->isRegTestNetwork()); + ui->lineEditPort->setText(QString::number(clientModel->getNetworkPort())); } void MasterNodeWizardDialog::initOwnerPage() diff --git a/src/qt/pivx/masternodewizarddialog.h b/src/qt/pivx/masternodewizarddialog.h index 1314c9a7a3191a..f80240f197e39b 100644 --- a/src/qt/pivx/masternodewizarddialog.h +++ b/src/qt/pivx/masternodewizarddialog.h @@ -10,6 +10,7 @@ #include "masternodeconfig.h" #include "qt/pivx/pwidget.h" +class ClientModel; class ContactsDropdown; class MNModel; class QLineEdit; @@ -61,6 +62,7 @@ enum Pages { public: explicit MasterNodeWizardDialog(WalletModel* walletMode, MNModel* mnModel, + ClientModel* clientModel, QWidget *parent = nullptr); ~MasterNodeWizardDialog() override; void showEvent(QShowEvent *event) override; @@ -100,6 +102,7 @@ private Q_SLOTS: WalletModel* walletModel{nullptr}; MNModel* mnModel{nullptr}; + ClientModel* clientModel{nullptr}; void initIntroPage(const QString& collateralAmountStr); void initCollateralPage(const QString& collateralAmountStr);