2 #include <qt/forms/ui_masternodelist.h> 13 #include <validation.h> 19 #include <QMessageBox> 21 #include <QtGui/QClipboard> 25 #if QT_VERSION < 0x050200 26 const QDateTime dateTime1 = QDateTime::currentDateTime();
27 const QDateTime dateTime2 = QDateTime(dateTime1.date(), dateTime1.time(), Qt::UTC);
28 return dateTime1.secsTo(dateTime2);
30 return QDateTime::currentDateTime().offsetFromUtc();
39 fFilterUpdatedDIP3(
true),
40 nTimeFilterUpdatedDIP3(0),
51 int columnAddressWidth = 200;
52 int columnStatusWidth = 80;
53 int columnPoSeScoreWidth = 80;
54 int columnRegisteredWidth = 80;
55 int columnLastPaidWidth = 80;
56 int columnNextPaymentWidth = 100;
57 int columnPayeeWidth = 130;
58 int columnOperatorRewardWidth = 130;
59 int columnCollateralWidth = 130;
60 int columnOwnerWidth = 130;
61 int columnVotingWidth = 130;
63 ui->tableWidgetMasternodesDIP3->setColumnWidth(0, columnAddressWidth);
64 ui->tableWidgetMasternodesDIP3->setColumnWidth(1, columnStatusWidth);
65 ui->tableWidgetMasternodesDIP3->setColumnWidth(2, columnPoSeScoreWidth);
66 ui->tableWidgetMasternodesDIP3->setColumnWidth(3, columnRegisteredWidth);
67 ui->tableWidgetMasternodesDIP3->setColumnWidth(4, columnLastPaidWidth);
68 ui->tableWidgetMasternodesDIP3->setColumnWidth(5, columnNextPaymentWidth);
69 ui->tableWidgetMasternodesDIP3->setColumnWidth(6, columnPayeeWidth);
70 ui->tableWidgetMasternodesDIP3->setColumnWidth(7, columnOperatorRewardWidth);
71 ui->tableWidgetMasternodesDIP3->setColumnWidth(8, columnCollateralWidth);
72 ui->tableWidgetMasternodesDIP3->setColumnWidth(9, columnOwnerWidth);
73 ui->tableWidgetMasternodesDIP3->setColumnWidth(10, columnVotingWidth);
77 ui->tableWidgetMasternodesDIP3->insertColumn(11);
78 ui->tableWidgetMasternodesDIP3->setColumnHidden(11,
true);
80 ui->tableWidgetMasternodesDIP3->setContextMenuPolicy(Qt::CustomContextMenu);
82 #if QT_VERSION >= 0x040700 83 ui->filterLineEditDIP3->setPlaceholderText(tr(
"Filter by any property (e.g. address or protx hash)"));
86 QAction* copyProTxHashAction =
new QAction(tr(
"Copy ProTx Hash"),
this);
87 QAction* copyCollateralOutpointAction =
new QAction(tr(
"Copy Collateral Outpoint"),
this);
91 connect(
ui->tableWidgetMasternodesDIP3, SIGNAL(customContextMenuRequested(
const QPoint&)),
this, SLOT(
showContextMenuDIP3(
const QPoint&)));
96 timer =
new QTimer(
this);
124 QTableWidgetItem* item =
ui->tableWidgetMasternodesDIP3->itemAt(point);
137 if (!fLockAcquired)
return;
147 ui->countLabelDIP3->setText(tr(
"Please wait...") +
" " + QString::number(nSecondsToWait));
149 if (nSecondsToWait <= 0) {
157 if (nSecondsToWait <= 0) {
171 std::map<uint256, CTxDestination> mapCollateralDests;
181 mapCollateralDests.emplace(dmn->proTxHash, collateralDest);
189 ui->countLabelDIP3->setText(tr(
"Updating..."));
190 ui->tableWidgetMasternodesDIP3->setSortingEnabled(
false);
191 ui->tableWidgetMasternodesDIP3->clearContents();
192 ui->tableWidgetMasternodesDIP3->setRowCount(0);
196 auto projectedPayees = mnList.GetProjectedMNPayees(mnList.GetValidMNsCount());
197 std::map<uint256, int> nextPayments;
198 for (
size_t i = 0; i < projectedPayees.size(); i++) {
199 const auto& dmn = projectedPayees[i];
200 nextPayments.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1);
203 std::set<COutPoint> setOutpts;
204 if (
walletModel &&
ui->checkBoxMyMasternodesOnly->isChecked()) {
205 std::vector<COutPoint> vOutpts;
207 for (
const auto& outpt : vOutpts) {
208 setOutpts.emplace(outpt);
213 if (
walletModel &&
ui->checkBoxMyMasternodesOnly->isChecked()) {
214 bool fMyMasternode = setOutpts.count(dmn->collateralOutpoint) ||
219 if (!fMyMasternode)
return;
223 QTableWidgetItem* addressItem =
new QTableWidgetItem(QString::fromStdString(dmn->pdmnState->addr.ToString()));
224 QTableWidgetItem* statusItem =
new QTableWidgetItem(mnList.IsMNValid(dmn) ? tr(
"ENABLED") : (mnList.IsMNPoSeBanned(dmn) ? tr(
"POSE_BANNED") : tr(
"UNKNOWN")));
225 QTableWidgetItem* PoSeScoreItem =
new QTableWidgetItem(QString::number(dmn->pdmnState->nPoSePenalty));
226 QTableWidgetItem* registeredItem =
new QTableWidgetItem(QString::number(dmn->pdmnState->nRegisteredHeight));
227 QTableWidgetItem* lastPaidItem =
new QTableWidgetItem(QString::number(dmn->pdmnState->nLastPaidHeight));
228 QTableWidgetItem* nextPaymentItem =
new QTableWidgetItem(nextPayments.count(dmn->proTxHash) ? QString::number(nextPayments[dmn->proTxHash]) : tr(
"UNKNOWN"));
231 QString payeeStr = tr(
"UNKNOWN");
235 QTableWidgetItem* payeeItem =
new QTableWidgetItem(payeeStr);
237 QString operatorRewardStr = tr(
"NONE");
238 if (dmn->nOperatorReward) {
239 operatorRewardStr = QString::number(dmn->nOperatorReward / 100.0,
'f', 2) +
"% ";
241 if (dmn->pdmnState->scriptOperatorPayout !=
CScript()) {
244 operatorRewardStr += tr(
"to %1").arg(QString::fromStdString(
EncodeDestination(operatorDest)));
246 operatorRewardStr += tr(
"to UNKNOWN");
249 operatorRewardStr += tr(
"but not claimed");
252 QTableWidgetItem* operatorRewardItem =
new QTableWidgetItem(operatorRewardStr);
254 QString collateralStr = tr(
"UNKNOWN");
255 auto collateralDestIt = mapCollateralDests.find(dmn->proTxHash);
256 if (collateralDestIt != mapCollateralDests.end()) {
257 collateralStr = QString::fromStdString(
EncodeDestination(collateralDestIt->second));
259 QTableWidgetItem* collateralItem =
new QTableWidgetItem(collateralStr);
261 QString ownerStr = QString::fromStdString(
EncodeDestination(dmn->pdmnState->keyIDOwner));
262 QTableWidgetItem* ownerItem =
new QTableWidgetItem(ownerStr);
264 QString votingStr = QString::fromStdString(
EncodeDestination(dmn->pdmnState->keyIDVoting));
265 QTableWidgetItem* votingItem =
new QTableWidgetItem(votingStr);
267 QTableWidgetItem* proTxHashItem =
new QTableWidgetItem(QString::fromStdString(dmn->proTxHash.ToString()));
270 strToFilter = addressItem->text() +
" " +
271 statusItem->text() +
" " +
272 PoSeScoreItem->text() +
" " +
273 registeredItem->text() +
" " +
274 lastPaidItem->text() +
" " +
275 nextPaymentItem->text() +
" " +
276 payeeItem->text() +
" " +
277 operatorRewardItem->text() +
" " +
278 collateralItem->text() +
" " +
279 ownerItem->text() +
" " +
280 votingItem->text() +
" " +
281 proTxHashItem->text();
285 ui->tableWidgetMasternodesDIP3->insertRow(0);
286 ui->tableWidgetMasternodesDIP3->setItem(0, 0, addressItem);
287 ui->tableWidgetMasternodesDIP3->setItem(0, 1, statusItem);
288 ui->tableWidgetMasternodesDIP3->setItem(0, 2, PoSeScoreItem);
289 ui->tableWidgetMasternodesDIP3->setItem(0, 3, registeredItem);
290 ui->tableWidgetMasternodesDIP3->setItem(0, 4, lastPaidItem);
291 ui->tableWidgetMasternodesDIP3->setItem(0, 5, nextPaymentItem);
292 ui->tableWidgetMasternodesDIP3->setItem(0, 6, payeeItem);
293 ui->tableWidgetMasternodesDIP3->setItem(0, 7, operatorRewardItem);
294 ui->tableWidgetMasternodesDIP3->setItem(0, 8, collateralItem);
295 ui->tableWidgetMasternodesDIP3->setItem(0, 9, ownerItem);
296 ui->tableWidgetMasternodesDIP3->setItem(0, 10, votingItem);
297 ui->tableWidgetMasternodesDIP3->setItem(0, 11, proTxHashItem);
300 ui->countLabelDIP3->setText(QString::number(
ui->tableWidgetMasternodesDIP3->rowCount()));
301 ui->tableWidgetMasternodesDIP3->setSortingEnabled(
true);
325 std::string strProTxHash;
329 QItemSelectionModel* selectionModel =
ui->tableWidgetMasternodesDIP3->selectionModel();
330 QModelIndexList selected = selectionModel->selectedRows();
332 if (selected.count() == 0)
return nullptr;
334 QModelIndex index = selected.at(0);
335 int nSelectedRow = index.row();
336 strProTxHash =
ui->tableWidgetMasternodesDIP3->item(nSelectedRow, 11)->text().toStdString();
340 proTxHash.
SetHex(strProTxHash);
343 return mnList.
GetMN(proTxHash);
357 QString strWindowtitle = tr(
"Additional information for DIP3 Masternode %1").arg(QString::fromStdString(dmn->proTxHash.ToString()));
358 QString strText = QString::fromStdString(json.
write(2));
360 QMessageBox::information(
this, strWindowtitle, strText);
370 QApplication::clipboard()->setText(QString::fromStdString(dmn->proTxHash.ToString()));
380 QApplication::clipboard()->setText(QString::fromStdString(dmn->collateralOutpoint.ToStringShort()));
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
CMasternodeSync masternodeSync
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
#define TRY_LOCK(cs, name)
void setFont(const std::vector< QWidget *> &vecWidgets, FontWeight weight, int nPointSize, bool fItalic)
Workaround to set correct font styles in all themes since there is a bug in macOS which leads to issu...
CCriticalSection cs_dip3list
CDeterministicMNCPtr GetMN(const uint256 &proTxHash) const
CDeterministicMNCPtr GetSelectedDIP3MN()
void updateDIP3ListScheduled()
void setWalletModel(WalletModel *walletModel)
int64_t nTimeFilterUpdatedDIP3
CTxOut out
unspent transaction output
void extraInfoDIP3_clicked()
void handleMasternodeListChanged()
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
QString strCurrentFilterDIP3
std::shared_ptr< const CDeterministicMN > CDeterministicMNCPtr
bool IsBlockchainSynced()
ClientModel * clientModel
MasternodeList(QWidget *parent=0)
int64_t GetTime()
Return system time (or mocked time, if set)
void updateFonts()
Update the font of all widgets where a custom font has been set with GUIUtil::setFont.
bool GetUTXOCoin(const COutPoint &outpoint, Coin &coin)
void copyCollateralOutpoint_clicked()
void showContextMenuDIP3(const QPoint &)
void listProTxCoins(std::vector< COutPoint > &vOutpts)
CDeterministicMNList getMasternodeList() const
Model for Dash network client.
#define MASTERNODELIST_FILTER_COOLDOWN_SECONDS
Masternode Manager page widget.
#define MASTERNODELIST_UPDATE_SECONDS
void on_checkBoxMyMasternodesOnly_stateChanged(int state)
std::string EncodeDestination(const CTxDestination &dest)
Serialized script, used inside transaction inputs and outputs.
Interface to Bitcoin wallet from Qt view code.
void doubleClicked(const QModelIndex &)
WalletModel * walletModel
void SetHex(const char *psz)
void setClientModel(ClientModel *clientModel)
void copyProTxHash_clicked()
void on_filterLineEditDIP3_textChanged(const QString &strFilterIn)
bool IsSpendable(const CTxDestination &dest) const