mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Add checkbox to show only masternodes the wallet has keys for (#2627)
This commit is contained in:
parent
942838e937
commit
332e0361c7
@ -356,6 +356,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxMyMasternodesOnly">
|
||||
<property name="toolTip">
|
||||
<string>Show only masternodes this wallet has keys for.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>My masternodes only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
@ -148,6 +148,17 @@ void MasternodeList::showContextMenuDIP3(const QPoint& point)
|
||||
if (item) contextMenuDIP3->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
static bool CheckWalletOwnsScript(const CScript& script)
|
||||
{
|
||||
CTxDestination dest;
|
||||
if (ExtractDestination(script, dest)) {
|
||||
if ((boost::get<CKeyID>(&dest) && pwalletMain->HaveKey(*boost::get<CKeyID>(&dest))) || (boost::get<CScriptID>(&dest) && pwalletMain->HaveCScript(*boost::get<CScriptID>(&dest)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MasternodeList::StartAlias(std::string strAlias)
|
||||
{
|
||||
std::string strStatusHtml;
|
||||
@ -442,7 +453,26 @@ void MasternodeList::updateDIP3List()
|
||||
nextPayments.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1);
|
||||
}
|
||||
|
||||
std::set<COutPoint> setOutpts;
|
||||
if (pwalletMain && ui->checkBoxMyMasternodesOnly->isChecked()) {
|
||||
LOCK(pwalletMain->cs_wallet);
|
||||
std::vector<COutPoint> vOutpts;
|
||||
pwalletMain->ListProTxCoins(vOutpts);
|
||||
for (const auto& outpt : vOutpts) {
|
||||
setOutpts.emplace(outpt);
|
||||
}
|
||||
}
|
||||
|
||||
mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) {
|
||||
if (pwalletMain && ui->checkBoxMyMasternodesOnly->isChecked()) {
|
||||
LOCK(pwalletMain->cs_wallet);
|
||||
bool fMyMasternode = setOutpts.count(dmn->collateralOutpoint) ||
|
||||
pwalletMain->HaveKey(dmn->pdmnState->keyIDOwner) ||
|
||||
pwalletMain->HaveKey(dmn->pdmnState->keyIDVoting) ||
|
||||
CheckWalletOwnsScript(dmn->pdmnState->scriptPayout) ||
|
||||
CheckWalletOwnsScript(dmn->pdmnState->scriptOperatorPayout);
|
||||
if (!fMyMasternode) return;
|
||||
}
|
||||
// populate list
|
||||
// Address, Protocol, Status, Active Seconds, Last Seen, Pub Key
|
||||
QTableWidgetItem* addressItem = new QTableWidgetItem(QString::fromStdString(dmn->pdmnState->addr.ToString()));
|
||||
@ -701,6 +731,13 @@ void MasternodeList::ShowQRCode(std::string strAlias)
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MasternodeList::on_checkBoxMyMasternodesOnly_stateChanged(int state)
|
||||
{
|
||||
// no cooldown
|
||||
nTimeFilterUpdatedDIP3 = GetTime() - MASTERNODELIST_FILTER_COOLDOWN_SECONDS;
|
||||
fFilterUpdatedDIP3 = true;
|
||||
}
|
||||
|
||||
CDeterministicMNCPtr MasternodeList::GetSelectedDIP3MN()
|
||||
{
|
||||
std::string strProTxHash;
|
||||
|
@ -90,6 +90,7 @@ private Q_SLOTS:
|
||||
void on_startMissingButton_clicked();
|
||||
void on_tableWidgetMyMasternodes_itemSelectionChanged();
|
||||
void on_UpdateButton_clicked();
|
||||
void on_checkBoxMyMasternodesOnly_stateChanged(int state);
|
||||
|
||||
void extraInfoDIP3_clicked();
|
||||
void copyProTxHash_clicked();
|
||||
|
Loading…
Reference in New Issue
Block a user