Skip to content

Commit

Permalink
Merge #1508: [BUG] Prevent StartAll from starting mns with immature c…
Browse files Browse the repository at this point in the history
…ollateral

7830c17 [BUG] Prevent StartAll from starting mns with immature collateral (random-zebra)

Pull request description:

  Extends the fix of #1389 (point 2) also to `startAll` (not only `startAlias`).

  Additional ref: #1226

ACKs for top commit:
  Fuzzbawls:
    utACK 7830c17
  furszy:
    utACK 7830c17

Tree-SHA512: 74798a075aab71d27b3e65827e625eb876ddc7d0a0a6a641864aa5bfa8bc720ee8200020dc497b03e436b6e4df25bef09955397dbdc7f267cdbd3f5781b08223
  • Loading branch information
furszy committed Apr 11, 2020
2 parents 172387a + 7830c17 commit 104db7d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/qt/pivx/masternodeswidget.cpp
Expand Up @@ -269,7 +269,8 @@ void MasterNodesWidget::onStartAllClicked(int type)
inform(tr("Cannot perform Mastenodes start, wallet locked"));
return;
}
if (!checkMNsNetwork()) return;
if (!Params().IsRegTestNet() && !checkMNsNetwork()) return; // skip on RegNet: so we can test even if tier two not synced

if (isLoading) {
inform(tr("Background task is being executed, please wait"));
} else {
Expand All @@ -294,6 +295,11 @@ bool MasterNodesWidget::startAll(QString& failText, bool onlyMissing)
continue;
}

if(!mnModel->isMNCollateralMature(mnAlias)) {
amountOfMnFailed++;
continue;
}

std::string strError;
if (!startMN(mne, strError)) {
amountOfMnFailed++;
Expand Down
7 changes: 7 additions & 0 deletions src/qt/pivx/mnmodel.cpp
Expand Up @@ -174,6 +174,13 @@ bool MNModel::isMNActive(QString mnAlias)
return activeState == CMasternode::MASTERNODE_PRE_ENABLED || activeState == CMasternode::MASTERNODE_ENABLED;
}

bool MNModel::isMNCollateralMature(QString mnAlias)
{
QMap<QString, std::pair<QString, CMasternode*>>::const_iterator it = nodes.find(mnAlias);
if (it != nodes.end()) return collateralTxAccepted.value(it.value().second->vin.prevout.hash.GetHex());
throw std::runtime_error(std::string("Masternode alias not found"));
}

bool MNModel::isMNsNetworkSynced()
{
return masternodeSync.IsSynced();
Expand Down
2 changes: 2 additions & 0 deletions src/qt/pivx/mnmodel.h
Expand Up @@ -49,6 +49,8 @@ class MNModel : public QAbstractTableModel
bool isMNInactive(QString mnAlias);
// Masternode is active if it's in PRE_ENABLED OR ENABLED state
bool isMNActive(QString mnAlias);
// Masternode collateral has enough confirmations
bool isMNCollateralMature(QString mnAlias);


private:
Expand Down

0 comments on commit 104db7d

Please sign in to comment.