Skip to content

Commit

Permalink
[GUI] MasternodeWidget: unlock collateral output coin after MN deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Mar 9, 2020
1 parent bdb13c8 commit 68a92f9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/pivx/masternodeswidget.cpp
Expand Up @@ -354,6 +354,8 @@ void MasterNodesWidget::onInfoMNClicked()

void MasterNodesWidget::onDeleteMNClicked()
{
QString txId = index.sibling(index.row(), MNModel::COLLATERAL_ID).data(Qt::DisplayRole).toString();
QString outIndex = index.sibling(index.row(), MNModel::COLLATERAL_OUT_INDEX).data(Qt::DisplayRole).toString();
QString qAliasString = index.data(Qt::DisplayRole).toString();
std::string aliasToRemove = qAliasString.toStdString();

Expand Down Expand Up @@ -434,6 +436,14 @@ void MasterNodesWidget::onDeleteMNClicked()
if (!pathNewConfFile.is_complete()) pathNewConfFile = GetDataDir() / pathNewConfFile;
rename(pathConfigFile, pathNewConfFile);

// Unlock collateral
bool convertOK = false;
unsigned int indexOut = outIndex.toUInt(&convertOK);
if(convertOK) {
COutPoint collateralOut(uint256(txId.toStdString()), indexOut);
walletModel->unlockCoin(collateralOut);
}

// Remove alias
masternodeConfig.remove(aliasToRemove);
// Update list
Expand Down

0 comments on commit 68a92f9

Please sign in to comment.