Skip to content

Commit

Permalink
Fix masternode creation on the RPC server
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamdy BS committed Nov 24, 2018
1 parent 0427c2a commit 165d19e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/rpcmasternode.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <boost/tokenizer.hpp>
#include <fstream>

#include "masternode.h"

void SendMoney(const CTxDestination& address, CAmount nValue, CWalletTx& wtxNew, AvailableCoinsType coin_type = ALL_COINS)
{
Expand Down Expand Up @@ -555,6 +556,7 @@ UniValue startmasternode (const UniValue& params, bool fHelp)

BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
std::string errorMessage;
CMasternodeBroadcast mnb;
int nIndex;
if(!mne.castOutputIndex(nIndex))
continue;
Expand All @@ -566,14 +568,16 @@ UniValue startmasternode (const UniValue& params, bool fHelp)
if (strCommand == "disabled" && pmn->IsEnabled()) continue;
}

bool result = activeMasternode.Register(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage);
bool result = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb);

UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", mne.getAlias()));
statusObj.push_back(Pair("result", result ? "success" : "failed"));

if (result) {
successful++;
mnodeman.UpdateMasternodeList(mnb);
mnb.Relay();
statusObj.push_back(Pair("error", ""));
} else {
failed++;
Expand Down Expand Up @@ -610,13 +614,16 @@ UniValue startmasternode (const UniValue& params, bool fHelp)
if (mne.getAlias() == alias) {
found = true;
std::string errorMessage;
CMasternodeBroadcast mnb;

bool result = activeMasternode.Register(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage);
bool result = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb);

statusObj.push_back(Pair("result", result ? "successful" : "failed"));

if (result) {
successful++;
mnodeman.UpdateMasternodeList(mnb);
mnb.Relay();
statusObj.push_back(Pair("error", ""));
} else {
failed++;
Expand Down

0 comments on commit 165d19e

Please sign in to comment.