Skip to content

Commit 7830c17

Browse files
committed
[BUG] Prevent StartAll from starting mns with immature collateral
1 parent 3dddd25 commit 7830c17

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/qt/pivx/masternodeswidget.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void MasterNodesWidget::onStartAllClicked(int type)
269269
inform(tr("Cannot perform Mastenodes start, wallet locked"));
270270
return;
271271
}
272-
if (!checkMNsNetwork()) return;
272+
if (!Params().IsRegTestNet() && !checkMNsNetwork()) return; // skip on RegNet: so we can test even if tier two not synced
273+
273274
if (isLoading) {
274275
inform(tr("Background task is being executed, please wait"));
275276
} else {
@@ -294,6 +295,11 @@ bool MasterNodesWidget::startAll(QString& failText, bool onlyMissing)
294295
continue;
295296
}
296297

298+
if(!mnModel->isMNCollateralMature(mnAlias)) {
299+
amountOfMnFailed++;
300+
continue;
301+
}
302+
297303
std::string strError;
298304
if (!startMN(mne, strError)) {
299305
amountOfMnFailed++;

src/qt/pivx/mnmodel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ bool MNModel::isMNActive(QString mnAlias)
174174
return activeState == CMasternode::MASTERNODE_PRE_ENABLED || activeState == CMasternode::MASTERNODE_ENABLED;
175175
}
176176

177+
bool MNModel::isMNCollateralMature(QString mnAlias)
178+
{
179+
QMap<QString, std::pair<QString, CMasternode*>>::const_iterator it = nodes.find(mnAlias);
180+
if (it != nodes.end()) return collateralTxAccepted.value(it.value().second->vin.prevout.hash.GetHex());
181+
throw std::runtime_error(std::string("Masternode alias not found"));
182+
}
183+
177184
bool MNModel::isMNsNetworkSynced()
178185
{
179186
return masternodeSync.IsSynced();

src/qt/pivx/mnmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class MNModel : public QAbstractTableModel
4949
bool isMNInactive(QString mnAlias);
5050
// Masternode is active if it's in PRE_ENABLED OR ENABLED state
5151
bool isMNActive(QString mnAlias);
52+
// Masternode collateral has enough confirmations
53+
bool isMNCollateralMature(QString mnAlias);
5254

5355

5456
private:

0 commit comments

Comments
 (0)