16 #include <QMessageBox> 20 #if QT_VERSION < 0x050200 21 const QDateTime dateTime1 = QDateTime::currentDateTime();
22 const QDateTime dateTime2 = QDateTime(dateTime1.date(), dateTime1.time(), Qt::UTC);
23 return dateTime1.secsTo(dateTime2);
25 return QDateTime::currentDateTime().offsetFromUtc();
39 int columnAliasWidth = 100;
40 int columnAddressWidth = 200;
41 int columnProtocolWidth = 60;
42 int columnStatusWidth = 80;
43 int columnActiveWidth = 130;
44 int columnLastSeenWidth = 130;
61 QAction *startAliasAction =
new QAction(tr(
"Start alias"),
this);
67 timer =
new QTimer(
this);
104 std::string strStatusHtml;
105 strStatusHtml +=
"<center>Alias: " + strAlias;
109 std::string strError;
115 strStatusHtml +=
"<br>Successfully started masternode.";
120 strStatusHtml +=
"<br>Failed to start masternode.<br>Error: " + strError;
125 strStatusHtml +=
"</center>";
128 msg.setText(QString::fromStdString(strStatusHtml));
136 int nCountSuccessful = 0;
137 int nCountFailed = 0;
138 std::string strFailedHtml;
141 std::string strError;
144 int32_t nOutputIndex = 0;
151 if(strCommand ==
"start-missing" &&
mnodeman.
Has(outpoint))
continue;
162 strFailedHtml +=
"\nFailed to start " + mne.
getAlias() +
". Error: " + strError;
167 std::string returnObj;
168 returnObj =
strprintf(
"Successfully started %d masternodes, failed to start %d, total %d", nCountSuccessful, nCountFailed, nCountFailed + nCountSuccessful);
169 if (nCountFailed > 0) {
170 returnObj += strFailedHtml;
174 msg.setText(QString::fromStdString(returnObj));
182 bool fOldRowFound =
false;
193 if(nNewRow == 0 && !fOldRowFound) {
201 QTableWidgetItem *aliasItem =
new QTableWidgetItem(strAlias);
202 QTableWidgetItem *addrItem =
new QTableWidgetItem(fFound ? QString::fromStdString(infoMn.
addr.
ToString()) : strAddr);
203 QTableWidgetItem *protocolItem =
new QTableWidgetItem(QString::number(fFound ? infoMn.
nProtocolVersion : -1));
206 QTableWidgetItem *lastSeenItem =
new QTableWidgetItem(QString::fromStdString(
DateTimeStrFormat(
"%Y-%m-%d %H:%M",
225 static int64_t nTimeMyListUpdated = 0;
232 if(nSecondsTillUpdate > 0 && !fForce)
return;
233 nTimeMyListUpdated =
GetTime();
237 int32_t nOutputIndex = 0;
257 static int64_t nTimeListUpdated =
GetTime();
266 if(nSecondsToWait > 0)
return;
279 for(
auto& mnpair : mapMasternodes)
284 QTableWidgetItem *addressItem =
new QTableWidgetItem(QString::fromStdString(mn.
addr.
ToString()));
285 QTableWidgetItem *protocolItem =
new QTableWidgetItem(QString::number(mn.
nProtocolVersion));
286 QTableWidgetItem *statusItem =
new QTableWidgetItem(QString::fromStdString(mn.
GetStatus()));
293 strToFilter = addressItem->text() +
" " +
294 protocolItem->text() +
" " +
295 statusItem->text() +
" " +
296 activeSecondsItem->text() +
" " +
297 lastSeenItem->text() +
" " +
325 std::string strAlias;
330 QModelIndexList selected = selectionModel->selectedRows();
332 if(selected.count() == 0)
return;
334 QModelIndex index = selected.at(0);
335 int nSelectedRow = index.row();
340 QMessageBox::StandardButton
retval = QMessageBox::question(
this, tr(
"Confirm masternode start"),
341 tr(
"Are you sure you want to start masternode %1?").arg(QString::fromStdString(strAlias)),
342 QMessageBox::Yes | QMessageBox::Cancel,
343 QMessageBox::Cancel);
345 if(
retval != QMessageBox::Yes)
return;
352 if(!
ctx.isValid())
return;
364 QMessageBox::StandardButton
retval = QMessageBox::question(
this, tr(
"Confirm all masternodes start"),
365 tr(
"Are you sure you want to start ALL masternodes?"),
366 QMessageBox::Yes | QMessageBox::Cancel,
367 QMessageBox::Cancel);
369 if(
retval != QMessageBox::Yes)
return;
376 if(!
ctx.isValid())
return;
389 QMessageBox::critical(
this, tr(
"Command is not available right now"),
390 tr(
"You can't use this command until masternode list is synced"));
395 QMessageBox::StandardButton
retval = QMessageBox::question(
this,
396 tr(
"Confirm missing masternodes start"),
397 tr(
"Are you sure you want to start MISSING masternodes?"),
398 QMessageBox::Yes | QMessageBox::Cancel,
399 QMessageBox::Cancel);
401 if(
retval != QMessageBox::Yes)
return;
408 if(!
ctx.isValid())
return;
std::string DurationToDHMS(int64_t nDurationTime)
MasternodeList(const PlatformStyle *platformStyle, QWidget *parent=0)
QTableWidget * tableWidgetMyMasternodes
CMasternodeSync masternodeSync
std::vector< CMasternodeEntry > & getEntries()
CMasternodeConfig masternodeConfig
#define TRY_LOCK(cs, name)
void setWalletModel(WalletModel *walletModel)
void Relay(CConnman &connman)
#define MY_MASTERNODELIST_UPDATE_SECONDS
const std::string & getOutputIndex() const
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
ClientModel * clientModel
CCriticalSection cs_mymnlist
const std::string & getTxHash() const
EncryptionStatus getEncryptionStatus() const
std::string ToString(bool fUseGetnameinfo=true) const
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const std::string & getIp() const
void on_tableWidgetMyMasternodes_itemSelectionChanged()
std::string GetStatus() const
void setClientModel(ClientModel *clientModel)
bool ParseInt32(const std::string &str, int32_t *out)
static secp256k1_context * ctx
void showContextMenu(const QPoint &)
bool GetMasternodeInfo(const COutPoint &outpoint, masternode_info_t &mnInfoRet)
uint256 uint256S(const char *str)
static bool Create(const COutPoint &outpoint, const CService &service, const CKey &keyCollateralAddressNew, const CPubKey &pubKeyCollateralAddressNew, const CKey &keyMasternodeNew, const CPubKey &pubKeyMasternodeNew, std::string &strErrorRet, CMasternodeBroadcast &mnbRet)
Create Masternode broadcast, needs to be relayed manually after that.
QPushButton * startButton
#define MASTERNODELIST_FILTER_COOLDOWN_SECONDS
void setupUi(QWidget *MasternodeList)
void on_startButton_clicked()
#define MASTERNODELIST_UPDATE_SECONDS
CPubKey pubKeyCollateralAddress
void on_filterLineEdit_textChanged(const QString &strFilterIn)
std::map< COutPoint, CMasternode > GetFullMasternodeMap()
void StartAll(std::string strCommand="start-all")
void on_startMissingButton_clicked()
CCriticalSection cs_mnlist
bool Lock(bool fAllowMixing=false)
static std::string StateToString(int nStateIn)
void StartAlias(std::string strAlias)
WalletModel * walletModel
std::unique_ptr< CConnman > g_connman
void NotifyMasternodeUpdates(CConnman &connman)
const std::string & getAlias() const
bool Has(const COutPoint &outpoint)
void on_startAllButton_clicked()
void updateMyMasternodeInfo(QString strAlias, QString strAddr, const COutPoint &outpoint)
int64_t GetTime()
For unit testing.
void UpdateMasternodeList(CMasternodeBroadcast mnb, CConnman &connman)
Update masternode list and maps using provided CMasternodeBroadcast.
const std::string & getPrivKey() const
bool IsMasternodeListSynced()
QTableWidget * tableWidgetMasternodes
int64_t nTimeFilterUpdated
void on_UpdateButton_clicked()
void updateMyNodeList(bool fForce=false)
UnlockContext requestUnlock(bool fForMixingOnly=false)