Skip to content

Commit

Permalink
GUI: MN creation wizard, get default port number from the client model.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Mar 4, 2022
1 parent 34e4df4 commit a71aeda
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ int ClientModel::getNumBlocksAtStartup()
return numBlocksAtStartup;
}

unsigned int ClientModel::getNetworkPort()
{
return Params().GetDefaultPort();
}

quint64 ClientModel::getTotalBytesRecv() const
{
if(!g_connman)
Expand Down
2 changes: 2 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/masternodeswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 6 additions & 13 deletions src/qt/pivx/masternodewizarddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/qt/pivx/masternodewizarddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "masternodeconfig.h"
#include "qt/pivx/pwidget.h"

class ClientModel;
class ContactsDropdown;
class MNModel;
class QLineEdit;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a71aeda

Please sign in to comment.