6 #include "ui_masternodewizarddialog.h"
13 #include <QIntValidator>
14 #include <QRegularExpression>
16 static inline QString formatParagraph(
const QString& str) {
17 return "<p align=\"justify\" style=\"text-align:center;\">" + str +
"</p>";
20 static inline QString formatHtmlContent(
const QString& str) {
21 return "<html><body>" + str +
"</body></html>";
24 static void initBtn(std::initializer_list<QPushButton*> args)
26 QSize BUTTON_SIZE = QSize(22, 22);
27 for (QPushButton* btn : args) {
28 btn->setMinimumSize(BUTTON_SIZE);
29 btn->setMaximumSize(BUTTON_SIZE);
33 btn->setVisible(
false);
40 icConfirm1(new QPushButton(this)),
41 icConfirm3(new QPushButton(this)),
42 icConfirm4(new QPushButton(this)),
48 this->setStyleSheet(parent->styleSheet());
50 ui->frame->setContentsMargins(10,10,10,10);
57 ui->pushNumber1->setEnabled(
false);
58 ui->pushNumber3->setEnabled(
false);
59 ui->pushNumber4->setEnabled(
false);
60 ui->pushName1->setEnabled(
false);
61 ui->pushName3->setEnabled(
false);
62 ui->pushName4->setEnabled(
false);
70 ui->labelMessage1a->setText(formatHtmlContent(
71 formatParagraph(tr(
"To create a PIVX Masternode you must dedicate %1 (the unit of PIVX) "
72 "to the network (however, these coins are still yours and will never leave your possession).").arg(collateralAmountStr)) +
73 formatParagraph(tr(
"You can deactivate the node and unlock the coins at any time."))));
79 ui->labelMessage3->setText(formatHtmlContent(
80 formatParagraph(tr(
"A transaction of %1 will be made").arg(collateralAmountStr)) +
81 formatParagraph(tr(
"to a new empty address in your wallet.")) +
82 formatParagraph(tr(
"The Address is labeled under the master node's name."))));
86 QRegularExpression rx(
"^(?:(?![\\#\\s]).)*");
87 ui->lineEditName->setValidator(
new QRegularExpressionValidator(rx,
ui->lineEditName));
96 ui->stackedWidget->setCurrentIndex(
pos);
97 ui->lineEditPort->setEnabled(
false);
99 ui->lineEditPort->setText(
"51476");
101 ui->lineEditPort->setText(
"51474");
103 ui->lineEditPort->setText(
"51472");
116 ui->btnBack->setVisible(
false);
119 connect(
ui->pushButtonSkip, &QPushButton::clicked,
this, &MasterNodeWizardDialog::close);
126 if (
ui->btnNext)
ui->btnNext->setFocus();
133 ui->stackedWidget->setCurrentIndex(1);
134 ui->pushName4->setChecked(
false);
135 ui->pushName3->setChecked(
true);
136 ui->pushName1->setChecked(
true);
138 ui->pushNumber3->setChecked(
true);
139 ui->btnBack->setVisible(
true);
140 ui->lineEditName->setFocus();
145 if (
ui->lineEditName->text().isEmpty()) {
151 ui->stackedWidget->setCurrentIndex(2);
152 ui->pushName4->setChecked(
false);
153 ui->pushName3->setChecked(
true);
154 ui->pushName1->setChecked(
true);
156 ui->pushNumber4->setChecked(
true);
157 ui->lineEditIpAddress->setFocus();
162 if (
ui->lineEditIpAddress->text().isEmpty()) {
181 QString addressLabel =
ui->lineEditName->text();
182 if (addressLabel.isEmpty()) {
183 returnStr = tr(
"address label cannot be empty");
187 QString addressStr =
ui->lineEditIpAddress->text();
188 QString portStr =
ui->lineEditPort->text();
189 if (addressStr.isEmpty() || portStr.isEmpty()) {
190 returnStr = tr(
"IP or port cannot be empty");
198 std::string alias = addressLabel.toStdString();
199 std::string ipAddress = addressStr.toStdString();
200 std::string port = portStr.toStdString();
221 QString::fromStdString(r.getObjResult()->ToString()),
241 if (
pos == 0)
return;
245 ui->stackedWidget->setCurrentIndex(0);
246 ui->btnNext->setFocus();
247 ui->pushNumber1->setChecked(
true);
248 ui->pushNumber4->setChecked(
false);
249 ui->pushNumber3->setChecked(
false);
250 ui->pushName4->setChecked(
false);
251 ui->pushName3->setChecked(
false);
252 ui->pushName1->setChecked(
true);
254 ui->btnBack->setVisible(
false);
258 ui->stackedWidget->setCurrentIndex(1);
259 ui->lineEditName->setFocus();
260 ui->pushNumber4->setChecked(
false);
261 ui->pushNumber3->setChecked(
true);
262 ui->pushName4->setChecked(
false);
263 ui->pushName3->setChecked(
true);
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
An outpoint - a combination of a transaction hash and an index n into its vout.
bool createMNCollateral(const QString &alias, const QString &addr, COutPoint &ret_outpoint, QString &ret_error)
CAmount getMNCollateralRequiredAmount()
static bool validateMNIP(const QString &addrStr)
CMasternodeConfig::CMasternodeEntry * createLegacyMN(COutPoint &collateralOut, const std::string &alias, std::string &serviceAddr, const std::string &port, const std::string &mnKeyString, QString &ret_error)
int getMasternodeCollateralMinConf()
MasterNodeWizardDialog(WalletModel *walletMode, MNModel *mnModel, QWidget *parent=nullptr)
WalletModel * walletModel
void inform(const QString &text)
Ui::MasterNodeWizardDialog * ui
~MasterNodeWizardDialog() override
void showEvent(QShowEvent *event) override
CMasternodeConfig::CMasternodeEntry * mnEntry
void setText(const QString &text)
Interface to PIVX wallet from Qt view code.
CallResult< Destination > getNewAddress(const std::string &label="") const
bool isTestNetwork() const
bool getMNCollateralCandidate(COutPoint &outPoint)
bool isRegTestNetwork() const
QString formatBalance(CAmount amount, int nDisplayUnit, bool isZpiv)
std::string EncodeSecret(const CKey &key)
void initCssEditLine(QLineEdit *edit, bool isDialog)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
void setCssSubtitleScreen(QWidget *wid)
void setCssBtnPrimary(QPushButton *btn, bool forceUpdate)
bool openDialog(QDialog *widget, QWidget *gui)
void setCssEditLine(QLineEdit *edit, bool isValid, bool forceUpdate)