-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathaddeditadrenalinenode.cpp
128 lines (114 loc) · 4.2 KB
/
addeditadrenalinenode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "addeditadrenalinenode.h"
#include "ui_addeditadrenalinenode.h"
#include "masternodeconfig.h"
#include "masternodemanager.h"
#include "ui_masternodemanager.h"
#include "walletdb.h"
#include "wallet.h"
#include "ui_interface.h"
#include "util.h"
#include "key.h"
#include "script.h"
#include "init.h"
#include "base58.h"
#include <QMessageBox>
#include <QClipboard>
AddEditAdrenalineNode::AddEditAdrenalineNode(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddEditAdrenalineNode)
{
ui->setupUi(this);
//Labels
ui->aliasLineEdit->setPlaceholderText("Enter your Masternode alias");
ui->addressLineEdit->setPlaceholderText("Enter your IP & port");
ui->privkeyLineEdit->setPlaceholderText("Enter your Masternode private key");
ui->txhashLineEdit->setPlaceholderText("Enter your 5000 CROP TXID");
ui->outputindexLineEdit->setPlaceholderText("Enter your transaction output index");
ui->rewardaddressLineEdit->setPlaceholderText("Enter a reward recive address");
ui->rewardpercentageLineEdit->setPlaceholderText("Input the % for the reward");
}
AddEditAdrenalineNode::~AddEditAdrenalineNode()
{
delete ui;
}
void AddEditAdrenalineNode::on_okButton_clicked()
{
if(ui->aliasLineEdit->text() == "")
{
QMessageBox msg;
msg.setText("Please enter an alias.");
msg.exec();
return;
}
else if(ui->addressLineEdit->text() == "")
{
QMessageBox msg;
msg.setText("Please enter an ip address and port. (123.45.67.89:9999)");
msg.exec();
return;
}
else if(ui->privkeyLineEdit->text() == "")
{
QMessageBox msg;
msg.setText("Please enter a masternode private key. This can be found using the \"masternode genkey\" command in the console.");
msg.exec();
return;
}
else if(ui->txhashLineEdit->text() == "")
{
QMessageBox msg;
msg.setText("Please enter the transaction hash for the transaction that has 5000 coins");
msg.exec();
return;
}
else if(ui->outputindexLineEdit->text() == "")
{
QMessageBox msg;
msg.setText("Please enter a transaction output index. This can be found using the \"masternode outputs\" command in the console.");
msg.exec();
return;
}
else
{
std::string sAlias = ui->aliasLineEdit->text().toStdString();
std::string sAddress = ui->addressLineEdit->text().toStdString();
std::string sMasternodePrivKey = ui->privkeyLineEdit->text().toStdString();
std::string sTxHash = ui->txhashLineEdit->text().toStdString();
std::string sOutputIndex = ui->outputindexLineEdit->text().toStdString();
std::string sRewardAddress = ui->rewardaddressLineEdit->text().toStdString();
std::string sRewardPercentage = ui->rewardpercentageLineEdit->text().toStdString();
boost::filesystem::path pathConfigFile = GetDataDir() / "masternode.conf";
boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::app);
if (stream.is_open())
{
stream << sAlias << " " << sAddress << " " << sMasternodePrivKey << " " << sTxHash << " " << sOutputIndex;
if (sRewardAddress != "" && sRewardPercentage != ""){
stream << " " << sRewardAddress << ":" << sRewardPercentage << std::endl;
} else {
stream << std::endl;
}
stream.close();
}
masternodeConfig.add(sAlias, sAddress, sMasternodePrivKey, sTxHash, sOutputIndex, sRewardAddress, sRewardPercentage);
accept();
}
}
void AddEditAdrenalineNode::on_cancelButton_clicked()
{
reject();
}
void AddEditAdrenalineNode::on_AddEditAddressPasteButton_clicked()
{
// Paste text from clipboard into recipient field
ui->addressLineEdit->setText(QApplication::clipboard()->text());
}
void AddEditAdrenalineNode::on_AddEditPrivkeyPasteButton_clicked()
{
// Paste text from clipboard into recipient field
ui->privkeyLineEdit->setText(QApplication::clipboard()->text());
}
void AddEditAdrenalineNode::on_AddEditTxhashPasteButton_clicked()
{
// Paste text from clipboard into recipient field
ui->txhashLineEdit->setText(QApplication::clipboard()->text());
}