Skip to content

Commit 626170e

Browse files
furszyFuzzbawls
authored andcommitted
[Masternde] Refactor activeMasternode.GetKeys callers to not expect a bool.
Github-Pull: #2056 Rebased-From: 89cc583
1 parent 545ca77 commit 626170e

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

src/activemasternode.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,11 @@ bool CActiveMasternode::EnableHotColdMasterNode(CTxIn& newVin, CService& newServ
232232
return true;
233233
}
234234

235-
bool CActiveMasternode::GetKeys(CKey& _privKeyMasternode, CPubKey& _pubKeyMasternode)
235+
void CActiveMasternode::GetKeys(CKey& _privKeyMasternode, CPubKey& _pubKeyMasternode)
236236
{
237237
if (!privKeyMasternode.IsValid() || !pubKeyMasternode.IsValid()) {
238-
return error("Error trying to get masternode keys");
238+
throw std::runtime_error("Error trying to get masternode keys");
239239
}
240240
_privKeyMasternode = privKeyMasternode;
241241
_pubKeyMasternode = pubKeyMasternode;
242-
return true;
243242
}

src/activemasternode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CActiveMasternode
5757
/// Enable cold wallet mode (run a Masternode with no funds)
5858
bool EnableHotColdMasterNode(CTxIn& vin, CService& addr);
5959

60-
bool GetKeys(CKey& privKeyMasternode, CPubKey& pubKeyMasternode);
60+
void GetKeys(CKey& privKeyMasternode, CPubKey& pubKeyMasternode);
6161
};
6262

6363
#endif

src/budget/budgetmanager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,8 @@ void CBudgetManager::VoteOnFinalizedBudgets()
500500
// Get masternode keys
501501
CPubKey pubKeyMasternode;
502502
CKey keyMasternode;
503-
if (!activeMasternode.GetKeys(keyMasternode, pubKeyMasternode)) {
504-
return;
505-
}
503+
activeMasternode.GetKeys(keyMasternode, pubKeyMasternode);
504+
506505
// Sign finalized budgets
507506
for (const uint256& budgetHash: vBudgetHashes) {
508507
CFinalizedBudgetVote vote(*(activeMasternode.vin), budgetHash);

src/masternode-payments.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
681681
}
682682

683683
CPubKey pubKeyMasternode; CKey keyMasternode;
684-
if (!activeMasternode.GetKeys(keyMasternode, pubKeyMasternode)) {
685-
LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() - Error upon calling GetKeysFromSecret.\n");
686-
return false;
687-
}
684+
activeMasternode.GetKeys(keyMasternode, pubKeyMasternode);
688685

689686
LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() - Signing Winner\n");
690687
if (newWinner.Sign(keyMasternode, pubKeyMasternode)) {

src/rpc/budget.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,8 @@ UniValue mnbudgetvote(const JSONRPCRequest& request)
273273
UniValue statusObj(UniValue::VOBJ);
274274

275275
while (true) {
276-
if (!activeMasternode.GetKeys(keyMasternode, pubKeyMasternode)) {
277-
failed++;
278-
statusObj.pushKV("node", "local");
279-
statusObj.pushKV("result", "failed");
280-
statusObj.pushKV("error", "Masternode signing error, GetKeysFromSecret failed.");
281-
resultsObj.push_back(statusObj);
282-
break;
283-
}
276+
// Get MN keys
277+
activeMasternode.GetKeys(keyMasternode, pubKeyMasternode);
284278

285279
CMasternode* pmn = mnodeman.Find(activeMasternode.vin->prevout);
286280
if (pmn == NULL) {
@@ -817,9 +811,7 @@ UniValue mnfinalbudget(const JSONRPCRequest& request)
817811
uint256 hash(uint256S(strHash));
818812

819813
CPubKey pubKeyMasternode; CKey keyMasternode;
820-
if (!activeMasternode.GetKeys(keyMasternode, pubKeyMasternode)) {
821-
return "Error upon calling GetKeysFromSecret";
822-
}
814+
activeMasternode.GetKeys(keyMasternode, pubKeyMasternode);
823815

824816
CMasternode* pmn = mnodeman.Find(activeMasternode.vin->prevout);
825817
if (pmn == NULL) {

0 commit comments

Comments
 (0)