From d81e729b0af77a66844e87858ccc7f109f19fdc6 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Fri, 9 Sep 2016 11:52:10 -0400 Subject: [PATCH] Governance bug fix (#998) * Added more specific error message about attempts to submit superblocks by non-masternodes * Fixed governance object validation bug * Fixed logic bug in governance object submission --- src/governance.cpp | 2 +- src/rpcgovernance.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/governance.cpp b/src/governance.cpp index 04dba2445..fe4f59c76 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -956,7 +956,7 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s if(fCheckCollateral) { if(nObjectType == GOVERNANCE_OBJECT_TRIGGER) { CMasternode mn; - if(mnodeman.Get(pubkeyMasternode, mn)) { + if(!mnodeman.Get(pubkeyMasternode, mn)) { strError = "Masternode not found"; return false; } diff --git a/src/rpcgovernance.cpp b/src/rpcgovernance.cpp index 2a6d8463b..5b39ec2f5 100644 --- a/src/rpcgovernance.cpp +++ b/src/rpcgovernance.cpp @@ -186,9 +186,14 @@ UniValue gobject(const UniValue& params, bool fHelp) << endl; ); // Attempt to sign triggers if we are a MN - if((govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) && mnFound) { - govobj.SetMasternodeInfo(mn.vin, activeMasternode.pubKeyMasternode); - govobj.Sign(activeMasternode.keyMasternode); + if(govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) { + if(mnFound) { + govobj.SetMasternodeInfo(mn.vin, activeMasternode.pubKeyMasternode); + govobj.Sign(activeMasternode.keyMasternode); + } + else { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Only valid masternodes can submit this type of object"); + } } std::string strError = "";