|
3 | 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | 4 |
|
5 | 5 | #include "qt/pivx/masternodeswidget.h" |
| 6 | +#include "bls/bls_wrapper.h" |
6 | 7 | #include "qt/pivx/forms/ui_masternodeswidget.h" |
7 | 8 |
|
8 | 9 | #include "qt/pivx/defaultdialog.h" |
|
17 | 18 | #include "qt/pivx/mnmodel.h" |
18 | 19 | #include "qt/pivx/optionbutton.h" |
19 | 20 | #include "qt/walletmodel.h" |
| 21 | +#include "uint256.h" |
20 | 22 |
|
21 | 23 | #define DECORATION_SIZE 65 |
22 | 24 | #define NUM_ITEMS 3 |
@@ -166,7 +168,7 @@ void MasterNodesWidget::onMNClicked(const QModelIndex& _index) |
166 | 168 | if (!menu) { |
167 | 169 | menu = new TooltipMenu(window, this); |
168 | 170 | connect(menu, &TooltipMenu::message, this, &AddressesWidget::message); |
169 | | - menu->addBtn(0, tr("Start"), [this](){onEditMNClicked();}); |
| 171 | + menu->addBtn(0, tr("Start"), [this](){onEditMNClicked();}); //TODO: change to UNBAN once 6.0 is out |
170 | 172 | menu->addBtn(1, tr("Delete"), [this](){onDeleteMNClicked();}); |
171 | 173 | menu->addBtn(2, tr("Info"), [this](){onInfoMNClicked();}); |
172 | 174 | menu->adjustSize(); |
@@ -223,6 +225,32 @@ void MasterNodesWidget::onEditMNClicked() |
223 | 225 | bool isEnabled = index.sibling(index.row(), MNModel::IS_POSE_ENABLED).data(Qt::DisplayRole).toBool(); |
224 | 226 | if (isEnabled) { |
225 | 227 | inform(tr("Cannot start an already started Masternode")); |
| 228 | + }else{ |
| 229 | + uint256 proTxHash =uint256S(index.sibling(index.row(), MNModel::PRO_TX_HASH).data(Qt::DisplayRole).toString().toStdString()); |
| 230 | + Optional<DMNData> opDMN = interfaces::g_tiertwo->getDMNData(proTxHash, |
| 231 | + clientModel->getLastBlockIndexProcessed()); |
| 232 | + if(!opDMN){ |
| 233 | + inform(tr("Masternode not found")); |
| 234 | + }else{ |
| 235 | + std::string operatorKeyS = opDMN->operatorSk; |
| 236 | + if(operatorKeyS.empty()){ |
| 237 | + inform("Operator secret key not found"); |
| 238 | + }else{ |
| 239 | + Optional<CBLSSecretKey> operator_key = bls::DecodeSecret(Params(),operatorKeyS); |
| 240 | + if(operator_key){ |
| 241 | + std::string error_str = ""; |
| 242 | + if(!mnModel->unbanDMN(*operator_key,proTxHash,error_str)){ |
| 243 | + inform(QString::fromStdString(error_str)); |
| 244 | + }else{ |
| 245 | + inform("Masternode successfully unbanned! Wait for the next minted block and it will update"); |
| 246 | + } |
| 247 | + }else{ |
| 248 | + inform("Could not decode operator secret key"); |
| 249 | + } |
| 250 | + } |
| 251 | + |
| 252 | + } |
| 253 | + |
226 | 254 | } |
227 | 255 | } |
228 | 256 | } |
|
0 commit comments