Split keyIDMasternode into keyIDOwner/keyIDOperator/keyIDVoting (#2248)
* Split keyIDMasternode into keyIDOwner/keyIDOperator/keyIDVoting keyIDOwner is the key used for things which should stay in control of the collateral owner, like proposal voting. keyIDOperator is the key used for operational things, like signing network messages, signing trigger/watchdog objects and trigger votes. keyIDVoting is the key used for proposal voting Legacy masternodes will always have the same key for all 3 to keep compatibility. Using different keys is only allowed after spork15 activation. * Forbid reusing collateral keys for operator/owner keys and vice versa * Bump SERIALIZATION_VERSION_STRING in CMasternodeMan
This commit is contained in:
parent
5295c78cca
commit
25545fc1e7
@ -100,7 +100,7 @@ bool CActiveLegacyMasternodeManager::SendMasternodePing(CConnman& connman)
|
||||
mnp.nSentinelVersion = nSentinelVersion;
|
||||
mnp.fSentinelIsCurrent =
|
||||
(abs(GetAdjustedTime() - nSentinelPingTime) < MASTERNODE_SENTINEL_PING_MAX_SECONDS);
|
||||
if(!mnp.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode)) {
|
||||
if(!mnp.Sign(activeMasternodeInfo.keyOperator, activeMasternodeInfo.keyIDOperator)) {
|
||||
LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- ERROR: Couldn't sign Masternode Ping\n");
|
||||
return false;
|
||||
}
|
||||
@ -210,12 +210,12 @@ void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman)
|
||||
|
||||
void CActiveLegacyMasternodeManager::ManageStateRemote()
|
||||
{
|
||||
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, keyIDMasternode = %s\n",
|
||||
GetStatus(), GetTypeString(), fPingerEnabled, activeMasternodeInfo.keyIDMasternode.ToString());
|
||||
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, keyIDOperator = %s\n",
|
||||
GetStatus(), GetTypeString(), fPingerEnabled, activeMasternodeInfo.keyIDOperator.ToString());
|
||||
|
||||
mnodeman.CheckMasternode(activeMasternodeInfo.keyIDMasternode, true);
|
||||
mnodeman.CheckMasternode(activeMasternodeInfo.keyIDOperator, true);
|
||||
masternode_info_t infoMn;
|
||||
if(mnodeman.GetMasternodeInfo(activeMasternodeInfo.keyIDMasternode, infoMn)) {
|
||||
if(mnodeman.GetMasternodeInfo(activeMasternodeInfo.keyIDOperator, infoMn)) {
|
||||
if(infoMn.nProtocolVersion != PROTOCOL_VERSION) {
|
||||
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
|
||||
strNotCapableReason = "Invalid protocol version";
|
||||
|
@ -24,8 +24,8 @@ extern CActiveLegacyMasternodeManager legacyActiveMasternodeManager;
|
||||
|
||||
struct CActiveMasternodeInfo {
|
||||
// Keys for the active Masternode
|
||||
CKeyID keyIDMasternode;
|
||||
CKey keyMasternode;
|
||||
CKeyID keyIDOperator;
|
||||
CKey keyOperator;
|
||||
|
||||
// Initialized while registering Masternode
|
||||
COutPoint outpoint;
|
||||
|
@ -76,6 +76,16 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid
|
||||
if (!ptx.scriptPayout.IsPayToPublicKeyHash())
|
||||
return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee");
|
||||
|
||||
CTxDestination payoutDest;
|
||||
if (!ExtractDestination(ptx.scriptPayout, payoutDest)) {
|
||||
// should not happen as we checked script types before
|
||||
return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-dest");
|
||||
}
|
||||
// don't allow reuse of collateral key for other keys (don't allow people to put the collateral key onto an online server)
|
||||
if (payoutDest == CTxDestination(ptx.keyIDOwner) || payoutDest == CTxDestination(ptx.keyIDOperator) || payoutDest == CTxDestination(ptx.keyIDVoting)) {
|
||||
return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-reuse");
|
||||
}
|
||||
|
||||
// This is a temporary restriction that will be lifted later
|
||||
// It is required while we are transitioning from the old MN list to the deterministic list
|
||||
if (tx.vout[ptx.nCollateralIndex].scriptPubKey != ptx.scriptPayout)
|
||||
|
@ -177,8 +177,10 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom,
|
||||
}
|
||||
}
|
||||
|
||||
bool onlyOwnerAllowed = nObjectType == GOVERNANCE_OBJECT_PROPOSAL;
|
||||
|
||||
// Finally check that the vote is actually valid (done last because of cost of signature verification)
|
||||
if(!vote.IsValid(true)) {
|
||||
if(!vote.IsValid(onlyOwnerAllowed)) {
|
||||
std::ostringstream ostr;
|
||||
ostr << "CGovernanceObject::ProcessVote -- Invalid vote"
|
||||
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
|
||||
@ -265,53 +267,53 @@ void CGovernanceObject::SetMasternodeOutpoint(const COutPoint& outpoint)
|
||||
masternodeOutpoint = outpoint;
|
||||
}
|
||||
|
||||
bool CGovernanceObject::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
|
||||
bool CGovernanceObject::Sign(const CKey& key, const CKeyID& keyID)
|
||||
{
|
||||
std::string strError;
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::SignHash(hash, keyMasternode, vchSig)) {
|
||||
if (!CHashSigner::SignHash(hash, key, vchSig)) {
|
||||
LogPrintf("CGovernanceObject::Sign -- SignHash() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyID, vchSig, strError)) {
|
||||
LogPrintf("CGovernanceObject::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = GetSignatureMessage();
|
||||
if (!CMessageSigner::SignMessage(strMessage, vchSig, keyMasternode)) {
|
||||
if (!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
|
||||
LogPrintf("CGovernanceObject::Sign -- SignMessage() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CGovernanceObject::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LogPrint("gobject", "CGovernanceObject::Sign -- pubkey id = %s, masternode = %s\n",
|
||||
keyIDMasternode.ToString(), masternodeOutpoint.ToStringShort());
|
||||
keyID.ToString(), masternodeOutpoint.ToStringShort());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGovernanceObject::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
bool CGovernanceObject::CheckSignature(const CKeyID& keyID) const
|
||||
{
|
||||
std::string strError;
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyID, vchSig, strError)) {
|
||||
// could be an old object
|
||||
std::string strMessage = GetSignatureMessage();
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
// nope, not in old format either
|
||||
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
@ -320,7 +322,7 @@ bool CGovernanceObject::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
} else {
|
||||
std::string strMessage = GetSignatureMessage();
|
||||
|
||||
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if (!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -509,8 +511,8 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
|
||||
}
|
||||
|
||||
// Check that we have a valid MN signature
|
||||
if (!CheckSignature(infoMn.keyIDMasternode)) {
|
||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.keyIDMasternode.ToString();
|
||||
if (!CheckSignature(infoMn.keyIDOperator)) {
|
||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.keyIDOperator.ToString();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -251,8 +251,8 @@ public:
|
||||
// Signature related functions
|
||||
|
||||
void SetMasternodeOutpoint(const COutPoint& outpoint);
|
||||
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
|
||||
bool CheckSignature(const CKeyID& keyIDMasternode) const;
|
||||
bool Sign(const CKey& key, const CKeyID& keyID);
|
||||
bool CheckSignature(const CKeyID& keyID) const;
|
||||
|
||||
std::string GetSignatureMessage() const;
|
||||
uint256 GetSignatureHash() const;
|
||||
|
@ -152,19 +152,19 @@ uint256 CGovernanceVote::GetSignatureHash() const
|
||||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
bool CGovernanceVote::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
|
||||
bool CGovernanceVote::Sign(const CKey& key, const CKeyID& keyID)
|
||||
{
|
||||
std::string strError;
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if(!CHashSigner::SignHash(hash, keyMasternode, vchSig)) {
|
||||
if(!CHashSigner::SignHash(hash, key, vchSig)) {
|
||||
LogPrintf("CGovernanceVote::Sign -- SignHash() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyID, vchSig, strError)) {
|
||||
LogPrintf("CGovernanceVote::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -173,12 +173,12 @@ bool CGovernanceVote::Sign(const CKey& keyMasternode, const CKeyID& keyIDMastern
|
||||
std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
|
||||
std::to_string(nVoteSignal) + "|" + std::to_string(nVoteOutcome) + "|" + std::to_string(nTime);
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
|
||||
LogPrintf("CGovernanceVote::Sign -- SignMessage() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CGovernanceVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -187,21 +187,21 @@ bool CGovernanceVote::Sign(const CKey& keyMasternode, const CKeyID& keyIDMastern
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGovernanceVote::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
bool CGovernanceVote::CheckSignature(const CKeyID& keyID) const
|
||||
{
|
||||
std::string strError;
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyID, vchSig, strError)) {
|
||||
// could be a signature in old format
|
||||
std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
|
||||
std::to_string(nVoteSignal) + "|" +
|
||||
std::to_string(nVoteOutcome) + "|" +
|
||||
std::to_string(nTime);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
// nope, not in old format either
|
||||
LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
@ -213,7 +213,7 @@ bool CGovernanceVote::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
std::to_string(nVoteOutcome) + "|" +
|
||||
std::to_string(nTime);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
|
||||
LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -222,7 +222,7 @@ bool CGovernanceVote::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGovernanceVote::IsValid(bool fSignatureCheck) const
|
||||
bool CGovernanceVote::IsValid(bool useVotingKey) const
|
||||
{
|
||||
if(nTime > GetAdjustedTime() + (60*60)) {
|
||||
LogPrint("gobject", "CGovernanceVote::IsValid -- vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, GetAdjustedTime() + (60*60));
|
||||
@ -249,9 +249,7 @@ bool CGovernanceVote::IsValid(bool fSignatureCheck) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!fSignatureCheck) return true;
|
||||
|
||||
return CheckSignature(infoMn.keyIDMasternode);
|
||||
return CheckSignature(useVotingKey ? infoMn.keyIDVoting : infoMn.keyIDOperator);
|
||||
}
|
||||
|
||||
bool operator==(const CGovernanceVote& vote1, const CGovernanceVote& vote2)
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
};
|
||||
|
||||
//
|
||||
// CGovernanceVote - Allow a masternode node to vote and broadcast throughout the network
|
||||
// CGovernanceVote - Allow a masternode to vote and broadcast throughout the network
|
||||
//
|
||||
|
||||
class CGovernanceVote
|
||||
@ -90,9 +90,9 @@ public:
|
||||
|
||||
void SetSignature(const std::vector<unsigned char>& vchSigIn) { vchSig = vchSigIn; }
|
||||
|
||||
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
|
||||
bool CheckSignature(const CKeyID& keyIDMasternode) const;
|
||||
bool IsValid(bool fSignatureCheck) const;
|
||||
bool Sign(const CKey& key, const CKeyID& keyID);
|
||||
bool CheckSignature(const CKeyID& keyID) const;
|
||||
bool IsValid(bool useVotingKey) const;
|
||||
void Relay(CConnman& connman) const;
|
||||
|
||||
std::string GetVoteString() const {
|
||||
|
@ -684,7 +684,10 @@ void CGovernanceManager::SyncSingleObjAndItsVotes(CNode* pnode, const uint256& n
|
||||
|
||||
for (const auto& vote : fileVotes.GetVotes()) {
|
||||
uint256 nVoteHash = vote.GetHash();
|
||||
if(filter.contains(nVoteHash) || !vote.IsValid(true)) {
|
||||
|
||||
bool onlyOwnerAllowed = govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL;
|
||||
|
||||
if(filter.contains(nVoteHash) || !vote.IsValid(onlyOwnerAllowed)) {
|
||||
continue;
|
||||
}
|
||||
pnode->PushInventory(CInv(MSG_GOVERNANCE_OBJECT_VOTE, nVoteHash));
|
||||
|
@ -1871,12 +1871,12 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
std::string strMasterNodePrivKey = GetArg("-masternodeprivkey", "");
|
||||
if(!strMasterNodePrivKey.empty()) {
|
||||
CPubKey pubKeyMasternode;
|
||||
if(!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, activeMasternodeInfo.keyMasternode, pubKeyMasternode))
|
||||
if(!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, activeMasternodeInfo.keyOperator, pubKeyMasternode))
|
||||
return InitError(_("Invalid masternodeprivkey. Please see documenation."));
|
||||
|
||||
activeMasternodeInfo.keyIDMasternode = pubKeyMasternode.GetID();
|
||||
activeMasternodeInfo.keyIDOperator = pubKeyMasternode.GetID();
|
||||
|
||||
LogPrintf(" keyIDMasternode: %s\n", CBitcoinAddress(activeMasternodeInfo.keyIDMasternode).ToString());
|
||||
LogPrintf(" keyIDOperator: %s\n", CBitcoinAddress(activeMasternodeInfo.keyIDOperator).ToString());
|
||||
} else {
|
||||
return InitError(_("You must specify a masternodeprivkey in the configuration. Please see documentation for help."));
|
||||
}
|
||||
|
@ -1059,10 +1059,10 @@ bool CTxLockVote::CheckSignature() const
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, infoMn.keyIDMasternode, vchMasternodeSignature, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, infoMn.keyIDOperator, vchMasternodeSignature, strError)) {
|
||||
// could be a signature in old format
|
||||
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
|
||||
if(!CMessageSigner::VerifyMessage(infoMn.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(infoMn.keyIDOperator, vchMasternodeSignature, strMessage, strError)) {
|
||||
// nope, not in old format either
|
||||
LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
@ -1070,7 +1070,7 @@ bool CTxLockVote::CheckSignature() const
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
|
||||
if(!CMessageSigner::VerifyMessage(infoMn.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(infoMn.keyIDOperator, vchMasternodeSignature, strMessage, strError)) {
|
||||
LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -1086,24 +1086,24 @@ bool CTxLockVote::Sign()
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchMasternodeSignature)) {
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyOperator, vchMasternodeSignature)) {
|
||||
LogPrintf("CTxLockVote::Sign -- SignHash() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchMasternodeSignature, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDOperator, vchMasternodeSignature, strError)) {
|
||||
LogPrintf("CTxLockVote::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchMasternodeSignature, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchMasternodeSignature, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("CTxLockVote::Sign -- SignMessage() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, vchMasternodeSignature, strMessage, strError)) {
|
||||
LogPrintf("CTxLockVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom
|
||||
}
|
||||
|
||||
int nDos = 0;
|
||||
if(!vote.CheckSignature(mnInfo.keyIDMasternode, nCachedBlockHeight, nDos)) {
|
||||
if(!vote.CheckSignature(mnInfo.keyIDOperator, nCachedBlockHeight, nDos)) {
|
||||
if(nDos) {
|
||||
LOCK(cs_main);
|
||||
LogPrintf("MASTERNODEPAYMENTVOTE -- ERROR: invalid signature\n");
|
||||
@ -480,12 +480,12 @@ bool CMasternodePaymentVote::Sign()
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyOperator, vchSig)) {
|
||||
LogPrintf("CMasternodePaymentVote::%s -- SignHash() failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDOperator, vchSig, strError)) {
|
||||
LogPrintf("CMasternodePaymentVote::%s -- VerifyHash() failed, error: %s\n", __func__, strError);
|
||||
return false;
|
||||
}
|
||||
@ -494,12 +494,12 @@ bool CMasternodePaymentVote::Sign()
|
||||
std::to_string(nBlockHeight) +
|
||||
ScriptToAsmStr(payee);
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("CMasternodePaymentVote::%s -- SignMessage() failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CMasternodePaymentVote::%s -- VerifyMessage() failed, error: %s\n", __func__, strError);
|
||||
return false;
|
||||
}
|
||||
@ -939,7 +939,7 @@ void CMasternodePaymentVote::Relay(CConnman& connman) const
|
||||
connman.RelayInv(inv);
|
||||
}
|
||||
|
||||
bool CMasternodePaymentVote::CheckSignature(const CKeyID& keyIDMasternode, int nValidationHeight, int &nDos) const
|
||||
bool CMasternodePaymentVote::CheckSignature(const CKeyID& keyIDOperator, int nValidationHeight, int &nDos) const
|
||||
{
|
||||
// do not ban by default
|
||||
nDos = 0;
|
||||
@ -948,12 +948,12 @@ bool CMasternodePaymentVote::CheckSignature(const CKeyID& keyIDMasternode, int n
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
|
||||
// could be a signature in old format
|
||||
std::string strMessage = masternodeOutpoint.ToStringShort() +
|
||||
std::to_string(nBlockHeight) +
|
||||
ScriptToAsmStr(payee);
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
// nope, not in old format either
|
||||
// Only ban for future block vote when we are already synced.
|
||||
// Otherwise it could be the case when MN which signed this vote is using another key now
|
||||
@ -970,7 +970,7 @@ bool CMasternodePaymentVote::CheckSignature(const CKeyID& keyIDMasternode, int n
|
||||
std::to_string(nBlockHeight) +
|
||||
ScriptToAsmStr(payee);
|
||||
|
||||
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if (!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
// Only ban for future block vote when we are already synced.
|
||||
// Otherwise it could be the case when MN which signed this vote is using another key now
|
||||
// and we have no idea about the old one.
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
uint256 GetSignatureHash() const;
|
||||
|
||||
bool Sign();
|
||||
bool CheckSignature(const CKeyID& keyIDMasternode, int nValidationHeight, int &nDos) const;
|
||||
bool CheckSignature(const CKeyID& keyIDOperator, int nValidationHeight, int &nDos) const;
|
||||
|
||||
bool IsValid(CNode* pnode, int nValidationHeight, std::string& strError, CConnman& connman) const;
|
||||
void Relay(CConnman& connman) const;
|
||||
|
@ -60,7 +60,9 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co
|
||||
if(mnb.sigTime <= sigTime && !mnb.fRecovery) return false;
|
||||
|
||||
pubKeyMasternode = mnb.pubKeyMasternode;
|
||||
keyIDMasternode = mnb.pubKeyMasternode.GetID();
|
||||
keyIDOwner = mnb.pubKeyMasternode.GetID();
|
||||
keyIDOperator = mnb.pubKeyMasternode.GetID();
|
||||
keyIDVoting = mnb.pubKeyMasternode.GetID();
|
||||
sigTime = mnb.sigTime;
|
||||
vchSig = mnb.vchSig;
|
||||
nProtocolVersion = mnb.nProtocolVersion;
|
||||
@ -74,7 +76,7 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co
|
||||
mnodeman.mapSeenMasternodePing.insert(std::make_pair(lastPing.GetHash(), lastPing));
|
||||
}
|
||||
// if it matches our Masternode privkey...
|
||||
if(fMasternodeMode && keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
|
||||
if(fMasternodeMode && keyIDOperator == activeMasternodeInfo.keyIDOperator) {
|
||||
nPoSeBanScore = -MASTERNODE_POSE_BAN_MAX_SCORE;
|
||||
if(nProtocolVersion == PROTOCOL_VERSION) {
|
||||
// ... and PROTOCOL_VERSION, then we've been remotely activated ...
|
||||
@ -188,7 +190,7 @@ void CMasternode::Check(bool fForce)
|
||||
}
|
||||
|
||||
int nActiveStatePrev = nActiveState;
|
||||
bool fOurMasternode = fMasternodeMode && activeMasternodeInfo.keyIDMasternode == keyIDMasternode;
|
||||
bool fOurMasternode = fMasternodeMode && activeMasternodeInfo.keyIDOperator == keyIDOperator;
|
||||
|
||||
// masternode doesn't meet payment protocol requirements ...
|
||||
bool fRequireUpdate = nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto() ||
|
||||
@ -413,7 +415,7 @@ bool CMasternodeBroadcast::Create(const COutPoint& outpoint, const CService& ser
|
||||
// wait for reindex and/or import to finish
|
||||
if (fImporting || fReindex) return false;
|
||||
|
||||
LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, keyIDMasternode = %s\n",
|
||||
LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, keyIDOperator = %s\n",
|
||||
CBitcoinAddress(pubKeyCollateralAddressNew.GetID()).ToString(),
|
||||
pubKeyMasternodeNew.GetID().ToString());
|
||||
|
||||
@ -483,10 +485,10 @@ bool CMasternodeBroadcast::SimpleCheck(int& nDos)
|
||||
}
|
||||
|
||||
CScript pubkeyScript2;
|
||||
pubkeyScript2 = GetScriptForDestination(keyIDMasternode);
|
||||
pubkeyScript2 = GetScriptForDestination(keyIDOperator);
|
||||
|
||||
if(pubkeyScript2.size() != 25) {
|
||||
LogPrintf("CMasternodeBroadcast::SimpleCheck -- keyIDMasternode has the wrong size\n");
|
||||
LogPrintf("CMasternodeBroadcast::SimpleCheck -- keyIDOperator has the wrong size\n");
|
||||
nDos = 100;
|
||||
return false;
|
||||
}
|
||||
@ -540,7 +542,7 @@ bool CMasternodeBroadcast::Update(CMasternode* pmn, int& nDos, CConnman& connman
|
||||
}
|
||||
|
||||
// if ther was no masternode broadcast recently or if it matches our Masternode privkey...
|
||||
if(!pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS) || (fMasternodeMode && keyIDMasternode == activeMasternodeInfo.keyIDMasternode)) {
|
||||
if(!pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS) || (fMasternodeMode && keyIDOperator == activeMasternodeInfo.keyIDOperator)) {
|
||||
// take the newest entry
|
||||
LogPrintf("CMasternodeBroadcast::Update -- Got UPDATED Masternode entry: addr=%s\n", addr.ToString());
|
||||
if(pmn->UpdateFromNewBroadcast(*this, connman)) {
|
||||
@ -557,7 +559,7 @@ bool CMasternodeBroadcast::CheckOutpoint(int& nDos)
|
||||
{
|
||||
// we are a masternode with the same outpoint (i.e. already activated) and this mnb is ours (matches our Masternode privkey)
|
||||
// so nothing to do here for us
|
||||
if(fMasternodeMode && outpoint == activeMasternodeInfo.outpoint && keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
|
||||
if(fMasternodeMode && outpoint == activeMasternodeInfo.outpoint && keyIDOperator == activeMasternodeInfo.keyIDOperator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -663,7 +665,7 @@ bool CMasternodeBroadcast::Sign(const CKey& keyCollateralAddress)
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
|
||||
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
|
||||
keyIDCollateralAddress.ToString() + keyIDOperator.ToString() +
|
||||
std::to_string(nProtocolVersion);
|
||||
|
||||
if (!CMessageSigner::SignMessage(strMessage, vchSig, keyCollateralAddress)) {
|
||||
@ -691,7 +693,7 @@ bool CMasternodeBroadcast::CheckSignature(int& nDos) const
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDCollateralAddress, vchSig, strError)) {
|
||||
// maybe it's in old format
|
||||
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
|
||||
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
|
||||
keyIDCollateralAddress.ToString() + keyIDOperator.ToString() +
|
||||
std::to_string(nProtocolVersion);
|
||||
|
||||
if (!CMessageSigner::VerifyMessage(keyIDCollateralAddress, vchSig, strMessage, strError)){
|
||||
@ -703,7 +705,7 @@ bool CMasternodeBroadcast::CheckSignature(int& nDos) const
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
|
||||
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
|
||||
keyIDCollateralAddress.ToString() + keyIDOperator.ToString() +
|
||||
std::to_string(nProtocolVersion);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDCollateralAddress, vchSig, strMessage, strError)){
|
||||
@ -764,7 +766,7 @@ CMasternodePing::CMasternodePing(const COutPoint& outpoint)
|
||||
nDaemonVersion = CLIENT_VERSION;
|
||||
}
|
||||
|
||||
bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
|
||||
bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDOperator)
|
||||
{
|
||||
std::string strError;
|
||||
|
||||
@ -778,7 +780,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDMastern
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
|
||||
LogPrintf("CMasternodePing::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -791,7 +793,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDMastern
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CMasternodePing::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -800,7 +802,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDMastern
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMasternodePing::CheckSignature(CKeyID& keyIDMasternode, int &nDos) const
|
||||
bool CMasternodePing::CheckSignature(CKeyID& keyIDOperator, int &nDos) const
|
||||
{
|
||||
std::string strError = "";
|
||||
nDos = 0;
|
||||
@ -808,11 +810,11 @@ bool CMasternodePing::CheckSignature(CKeyID& keyIDMasternode, int &nDos) const
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
|
||||
std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
|
||||
std::to_string(sigTime);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
|
||||
nDos = 33;
|
||||
return false;
|
||||
@ -822,7 +824,7 @@ bool CMasternodePing::CheckSignature(CKeyID& keyIDMasternode, int &nDos) const
|
||||
std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
|
||||
std::to_string(sigTime);
|
||||
|
||||
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if (!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
|
||||
nDos = 33;
|
||||
return false;
|
||||
@ -906,7 +908,7 @@ bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, i
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckSignature(pmn->keyIDMasternode, nDos)) return false;
|
||||
if (!CheckSignature(pmn->keyIDOperator, nDos)) return false;
|
||||
|
||||
// so, ping seems to be ok
|
||||
|
||||
|
@ -95,8 +95,8 @@ public:
|
||||
|
||||
bool IsExpired() const { return GetAdjustedTime() - sigTime > MASTERNODE_NEW_START_REQUIRED_SECONDS; }
|
||||
|
||||
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
|
||||
bool CheckSignature(CKeyID& keyIDMasternode, int &nDos) const;
|
||||
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDOperator);
|
||||
bool CheckSignature(CKeyID& keyIDOperator, int &nDos) const;
|
||||
bool SimpleCheck(int& nDos);
|
||||
bool CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos, CConnman& connman);
|
||||
void Relay(CConnman& connman);
|
||||
@ -136,15 +136,15 @@ struct masternode_info_t
|
||||
CPubKey const& pkCollAddr, CPubKey const& pkMN) :
|
||||
nActiveState{activeState}, nProtocolVersion{protoVer}, sigTime{sTime},
|
||||
outpoint{outpnt}, addr{addr},
|
||||
pubKeyCollateralAddress{pkCollAddr}, pubKeyMasternode{pkMN}, keyIDCollateralAddress{pkCollAddr.GetID()}, keyIDMasternode{pkMN.GetID()} {}
|
||||
pubKeyCollateralAddress{pkCollAddr}, pubKeyMasternode{pkMN}, keyIDCollateralAddress{pkCollAddr.GetID()}, keyIDOwner{pkMN.GetID()}, keyIDOperator{pkMN.GetID()}, keyIDVoting{pkMN.GetID()} {}
|
||||
|
||||
// only called when the network is in deterministic MN list mode
|
||||
masternode_info_t(int activeState, int protoVer, int64_t sTime,
|
||||
COutPoint const& outpnt, CService const& addr,
|
||||
CKeyID const& pkCollAddr, CKeyID const& pkMN) :
|
||||
CKeyID const& pkCollAddr, CKeyID const& pkOwner, CKeyID const& pkOperator, CKeyID const& pkVoting) :
|
||||
nActiveState{activeState}, nProtocolVersion{protoVer}, sigTime{sTime},
|
||||
outpoint{outpnt}, addr{addr},
|
||||
pubKeyCollateralAddress{}, pubKeyMasternode{}, keyIDCollateralAddress{pkCollAddr}, keyIDMasternode{pkMN} {}
|
||||
pubKeyCollateralAddress{}, pubKeyMasternode{}, keyIDCollateralAddress{pkCollAddr}, keyIDOwner{pkOwner}, keyIDOperator{pkOperator}, keyIDVoting{pkVoting} {}
|
||||
|
||||
int nActiveState = 0;
|
||||
int nProtocolVersion = 0;
|
||||
@ -155,7 +155,9 @@ struct masternode_info_t
|
||||
CPubKey pubKeyCollateralAddress{}; // this will be invalid/unset when the network switches to deterministic MNs (luckely it's only important for the broadcast hash)
|
||||
CPubKey pubKeyMasternode{}; // this will be invalid/unset when the network switches to deterministic MNs (luckely it's only important for the broadcast hash)
|
||||
CKeyID keyIDCollateralAddress{};
|
||||
CKeyID keyIDMasternode{};
|
||||
CKeyID keyIDOwner{};
|
||||
CKeyID keyIDOperator{};
|
||||
CKeyID keyIDVoting{};
|
||||
|
||||
int64_t nLastDsq = 0; //the dsq count from the last dsq broadcast of this node
|
||||
int64_t nTimeLastChecked = 0;
|
||||
@ -237,7 +239,9 @@ public:
|
||||
READWRITE(pubKeyCollateralAddress);
|
||||
READWRITE(pubKeyMasternode);
|
||||
READWRITE(keyIDCollateralAddress);
|
||||
READWRITE(keyIDMasternode);
|
||||
READWRITE(keyIDOwner);
|
||||
READWRITE(keyIDOperator);
|
||||
READWRITE(keyIDVoting);
|
||||
READWRITE(lastPing);
|
||||
READWRITE(vchSig);
|
||||
READWRITE(sigTime);
|
||||
@ -406,7 +410,9 @@ public:
|
||||
|
||||
if (ser_action.ForRead()) {
|
||||
keyIDCollateralAddress = pubKeyCollateralAddress.GetID();
|
||||
keyIDMasternode = pubKeyMasternode.GetID();
|
||||
keyIDOwner = pubKeyMasternode.GetID();
|
||||
keyIDOperator = pubKeyMasternode.GetID();
|
||||
keyIDVoting = pubKeyMasternode.GetID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
/** Masternode manager */
|
||||
CMasternodeMan mnodeman;
|
||||
|
||||
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-9";
|
||||
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-10";
|
||||
const int CMasternodeMan::LAST_PAID_SCAN_BLOCKS = 100;
|
||||
|
||||
struct CompareLastPaidBlock
|
||||
@ -471,10 +471,10 @@ bool CMasternodeMan::GetMasternodeInfo(const COutPoint& outpoint, masternode_inf
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMasternodeMan::GetMasternodeInfo(const CKeyID& keyIDMasternode, masternode_info_t& mnInfoRet) {
|
||||
bool CMasternodeMan::GetMasternodeInfo(const CKeyID& keyIDOperator, masternode_info_t& mnInfoRet) {
|
||||
LOCK(cs);
|
||||
for (const auto& mnpair : mapMasternodes) {
|
||||
if (mnpair.second.keyIDMasternode == keyIDMasternode) {
|
||||
if (mnpair.second.keyIDOperator == keyIDOperator) {
|
||||
mnInfoRet = mnpair.second.GetInfo();
|
||||
return true;
|
||||
}
|
||||
@ -482,9 +482,9 @@ bool CMasternodeMan::GetMasternodeInfo(const CKeyID& keyIDMasternode, masternode
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMasternodeMan::GetMasternodeInfo(const CPubKey& pubKeyMasternode, masternode_info_t& mnInfoRet)
|
||||
bool CMasternodeMan::GetMasternodeInfo(const CPubKey& pubKeyOperator, masternode_info_t& mnInfoRet)
|
||||
{
|
||||
return GetMasternodeInfo(pubKeyMasternode.GetID(), mnInfoRet);
|
||||
return GetMasternodeInfo(pubKeyOperator.GetID(), mnInfoRet);
|
||||
}
|
||||
|
||||
bool CMasternodeMan::GetMasternodeInfo(const CScript& payee, masternode_info_t& mnInfoRet)
|
||||
@ -1206,24 +1206,24 @@ void CMasternodeMan::SendVerifyReply(CNode* pnode, CMasternodeVerification& mnv,
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = mnv.GetSignatureHash1(blockHash);
|
||||
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, mnv.vchSig1)) {
|
||||
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyOperator, mnv.vchSig1)) {
|
||||
LogPrintf("CMasternodeMan::SendVerifyReply -- SignHash() failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, mnv.vchSig1, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDOperator, mnv.vchSig1, strError)) {
|
||||
LogPrintf("CMasternodeMan::SendVerifyReply -- VerifyHash() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = strprintf("%s%d%s", activeMasternodeInfo.service.ToString(false), mnv.nonce, blockHash.ToString());
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, mnv.vchSig1, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, mnv.vchSig1, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("MasternodeMan::SendVerifyReply -- SignMessage() failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, mnv.vchSig1, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, mnv.vchSig1, strMessage, strError)) {
|
||||
LogPrintf("MasternodeMan::SendVerifyReply -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
@ -1290,10 +1290,10 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
|
||||
if(CAddress(mnpair.second.addr, NODE_NETWORK) == pnode->addr) {
|
||||
bool fFound = false;
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
fFound = CHashSigner::VerifyHash(hash1, mnpair.second.keyIDMasternode, mnv.vchSig1, strError);
|
||||
fFound = CHashSigner::VerifyHash(hash1, mnpair.second.keyIDOperator, mnv.vchSig1, strError);
|
||||
// we don't care about mnv with signature in old format
|
||||
} else {
|
||||
fFound = CMessageSigner::VerifyMessage(mnpair.second.keyIDMasternode, mnv.vchSig1, strMessage1, strError);
|
||||
fFound = CMessageSigner::VerifyMessage(mnpair.second.keyIDOperator, mnv.vchSig1, strMessage1, strError);
|
||||
}
|
||||
if (fFound) {
|
||||
// found it!
|
||||
@ -1315,12 +1315,12 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash2 = mnv.GetSignatureHash2(blockHash);
|
||||
|
||||
if(!CHashSigner::SignHash(hash2, activeMasternodeInfo.keyMasternode, mnv.vchSig2)) {
|
||||
if(!CHashSigner::SignHash(hash2, activeMasternodeInfo.keyOperator, mnv.vchSig2)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyReply -- SignHash() failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CHashSigner::VerifyHash(hash2, activeMasternodeInfo.keyIDMasternode, mnv.vchSig2, strError)) {
|
||||
if(!CHashSigner::VerifyHash(hash2, activeMasternodeInfo.keyIDOperator, mnv.vchSig2, strError)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyReply -- VerifyHash() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
@ -1328,12 +1328,12 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
|
||||
std::string strMessage2 = strprintf("%s%d%s%s%s", mnv.addr.ToString(false), mnv.nonce, blockHash.ToString(),
|
||||
mnv.masternodeOutpoint1.ToStringShort(), mnv.masternodeOutpoint2.ToStringShort());
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage2, mnv.vchSig2, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage2, mnv.vchSig2, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyReply -- SignMessage() failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, mnv.vchSig2, strMessage2, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, mnv.vchSig2, strMessage2, strError)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyReply -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
@ -1443,12 +1443,12 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
|
||||
uint256 hash1 = mnv.GetSignatureHash1(blockHash);
|
||||
uint256 hash2 = mnv.GetSignatureHash2(blockHash);
|
||||
|
||||
if(!CHashSigner::VerifyHash(hash1, pmn1->keyIDMasternode, mnv.vchSig1, strError)) {
|
||||
if(!CHashSigner::VerifyHash(hash1, pmn1->keyIDOperator, mnv.vchSig1, strError)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyBroadcast -- VerifyHash() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CHashSigner::VerifyHash(hash2, pmn2->keyIDMasternode, mnv.vchSig2, strError)) {
|
||||
if(!CHashSigner::VerifyHash(hash2, pmn2->keyIDOperator, mnv.vchSig2, strError)) {
|
||||
LogPrintf("MasternodeMan::ProcessVerifyBroadcast -- VerifyHash() failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
@ -1457,12 +1457,12 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
|
||||
std::string strMessage2 = strprintf("%s%d%s%s%s", mnv.addr.ToString(false), mnv.nonce, blockHash.ToString(),
|
||||
mnv.masternodeOutpoint1.ToStringShort(), mnv.masternodeOutpoint2.ToStringShort());
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(pmn1->keyIDMasternode, mnv.vchSig1, strMessage1, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(pmn1->keyIDOperator, mnv.vchSig1, strMessage1, strError)) {
|
||||
LogPrintf("CMasternodeMan::ProcessVerifyBroadcast -- VerifyMessage() for masternode1 failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(pmn2->keyIDMasternode, mnv.vchSig2, strMessage2, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(pmn2->keyIDOperator, mnv.vchSig2, strMessage2, strError)) {
|
||||
LogPrintf("CMasternodeMan::ProcessVerifyBroadcast -- VerifyMessage() for masternode2 failed, error: %s\n", strError);
|
||||
return;
|
||||
}
|
||||
@ -1574,7 +1574,7 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBr
|
||||
Add(mnb);
|
||||
masternodeSync.BumpAssetLastTime("CMasternodeMan::CheckMnbAndUpdateMasternodeList - new");
|
||||
// if it matches our Masternode privkey...
|
||||
if(fMasternodeMode && mnb.keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
|
||||
if(fMasternodeMode && mnb.keyIDOperator == activeMasternodeInfo.keyIDOperator) {
|
||||
mnb.nPoSeBanScore = -MASTERNODE_POSE_BAN_MAX_SCORE;
|
||||
if(mnb.nProtocolVersion == PROTOCOL_VERSION) {
|
||||
// ... and PROTOCOL_VERSION, then we've been remotely activated ...
|
||||
@ -1650,11 +1650,11 @@ void CMasternodeMan::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
|
||||
}
|
||||
}
|
||||
|
||||
void CMasternodeMan::CheckMasternode(const CKeyID& keyIDMasternode, bool fForce)
|
||||
void CMasternodeMan::CheckMasternode(const CKeyID& keyIDOperator, bool fForce)
|
||||
{
|
||||
LOCK2(cs_main, cs);
|
||||
for (auto& mnpair : mapMasternodes) {
|
||||
if (mnpair.second.keyIDMasternode == keyIDMasternode) {
|
||||
if (mnpair.second.keyIDOperator == keyIDOperator) {
|
||||
mnpair.second.Check(fForce);
|
||||
return;
|
||||
}
|
||||
|
@ -169,8 +169,8 @@ public:
|
||||
bool Has(const COutPoint& outpoint);
|
||||
|
||||
bool GetMasternodeInfo(const COutPoint& outpoint, masternode_info_t& mnInfoRet);
|
||||
bool GetMasternodeInfo(const CKeyID& keyIDMasternode, masternode_info_t& mnInfoRet);
|
||||
bool GetMasternodeInfo(const CPubKey& pubKeyMasternode, masternode_info_t& mnInfoRet);
|
||||
bool GetMasternodeInfo(const CKeyID& keyIDOperator, masternode_info_t& mnInfoRet);
|
||||
bool GetMasternodeInfo(const CPubKey& pubKeyOperator, masternode_info_t& mnInfoRet);
|
||||
bool GetMasternodeInfo(const CScript& payee, masternode_info_t& mnInfoRet);
|
||||
|
||||
/// Find an entry in the masternode list that is next to be paid
|
||||
@ -230,7 +230,7 @@ public:
|
||||
bool AddGovernanceVote(const COutPoint& outpoint, uint256 nGovernanceObjectHash);
|
||||
void RemoveGovernanceObject(uint256 nGovernanceObjectHash);
|
||||
|
||||
void CheckMasternode(const CKeyID& keyIDMasternode, bool fForce);
|
||||
void CheckMasternode(const CKeyID& keyIDOperator, bool fForce);
|
||||
|
||||
bool IsMasternodePingedWithin(const COutPoint& outpoint, int nSeconds, int64_t nTimeToCheckAt = -1);
|
||||
void SetMasternodeLastPing(const COutPoint& outpoint, const CMasternodePing& mnp);
|
||||
|
@ -1977,7 +1977,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||
// we have no idea about (e.g we were offline)? How to handle them?
|
||||
}
|
||||
|
||||
if(!dstx.CheckSignature(mn.keyIDMasternode)) {
|
||||
if(!dstx.CheckSignature(mn.keyIDOperator)) {
|
||||
LogPrint("privatesend", "DSTX -- CheckSignature() failed for %s\n", hashTx.ToString());
|
||||
return false;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
masternode_info_t infoMn;
|
||||
if(!mnodeman.GetMasternodeInfo(dsq.masternodeOutpoint, infoMn)) return;
|
||||
|
||||
if(!dsq.CheckSignature(infoMn.keyIDMasternode)) {
|
||||
if(!dsq.CheckSignature(infoMn.keyIDOperator)) {
|
||||
// we probably have outdated info
|
||||
mnodeman.AskForMN(pfrom, dsq.masternodeOutpoint, connman);
|
||||
return;
|
||||
|
@ -105,7 +105,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
masternode_info_t mnInfo;
|
||||
if(!mnodeman.GetMasternodeInfo(dsq.masternodeOutpoint, mnInfo)) return;
|
||||
|
||||
if(!dsq.CheckSignature(mnInfo.keyIDMasternode)) {
|
||||
if(!dsq.CheckSignature(mnInfo.keyIDOperator)) {
|
||||
// we probably have outdated info
|
||||
mnodeman.AskForMN(pfrom, dsq.masternodeOutpoint, connman);
|
||||
return;
|
||||
|
@ -47,12 +47,12 @@ bool CDarksendQueue::Sign()
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
|
||||
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyOperator, vchSig)) {
|
||||
LogPrintf("CDarksendQueue::Sign -- SignHash() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDOperator, vchSig, strError)) {
|
||||
LogPrintf("CDarksendQueue::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -62,12 +62,12 @@ bool CDarksendQueue::Sign()
|
||||
std::to_string(nTime) +
|
||||
std::to_string(fReady);
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("CDarksendQueue::Sign -- SignMessage() failed, %s\n", ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CDarksendQueue::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -76,14 +76,14 @@ bool CDarksendQueue::Sign()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDarksendQueue::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
bool CDarksendQueue::CheckSignature(const CKeyID& keyIDOperator) const
|
||||
{
|
||||
std::string strError = "";
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
|
||||
// we don't care about queues with old signature format
|
||||
LogPrintf("CDarksendQueue::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
@ -94,7 +94,7 @@ bool CDarksendQueue::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
std::to_string(nTime) +
|
||||
std::to_string(fReady);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CDarksendQueue::CheckSignature -- Got bad Masternode queue signature: %s; error: %s\n", ToString(), strError);
|
||||
return false;
|
||||
}
|
||||
@ -127,24 +127,24 @@ bool CDarksendBroadcastTx::Sign()
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
|
||||
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyOperator, vchSig)) {
|
||||
LogPrintf("CDarksendBroadcastTx::Sign -- SignHash() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDOperator, vchSig, strError)) {
|
||||
LogPrintf("CDarksendBroadcastTx::Sign -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);
|
||||
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
|
||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyOperator)) {
|
||||
LogPrintf("CDarksendBroadcastTx::Sign -- SignMessage() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CDarksendBroadcastTx::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
@ -153,14 +153,14 @@ bool CDarksendBroadcastTx::Sign()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDarksendBroadcastTx::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
bool CDarksendBroadcastTx::CheckSignature(const CKeyID& keyIDOperator) const
|
||||
{
|
||||
std::string strError = "";
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
|
||||
uint256 hash = GetSignatureHash();
|
||||
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
|
||||
if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
|
||||
// we don't care about dstxes with old signature format
|
||||
LogPrintf("CDarksendBroadcastTx::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
|
||||
return false;
|
||||
@ -168,7 +168,7 @@ bool CDarksendBroadcastTx::CheckSignature(const CKeyID& keyIDMasternode) const
|
||||
} else {
|
||||
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);
|
||||
|
||||
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
|
||||
if(!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
|
||||
LogPrintf("CDarksendBroadcastTx::CheckSignature -- Got bad dstx signature, error: %s\n", strError);
|
||||
return false;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public:
|
||||
*/
|
||||
bool Sign();
|
||||
/// Check if we have a valid Masternode address
|
||||
bool CheckSignature(const CKeyID& keyIDMasternode) const;
|
||||
bool CheckSignature(const CKeyID& keyIDOperator) const;
|
||||
|
||||
bool Relay(CConnman &connman);
|
||||
|
||||
@ -341,7 +341,7 @@ public:
|
||||
uint256 GetSignatureHash() const;
|
||||
|
||||
bool Sign();
|
||||
bool CheckSignature(const CKeyID& keyIDMasternode) const;
|
||||
bool CheckSignature(const CKeyID& keyIDOperator) const;
|
||||
|
||||
void SetConfirmedHeight(int nConfirmedHeightIn) { nConfirmedHeight = nConfirmedHeightIn; }
|
||||
bool IsExpired(int nHeight);
|
||||
|
@ -236,7 +236,7 @@ UniValue gobject_submit(const JSONRPCRequest& request)
|
||||
|
||||
bool fMnFound = mnodeman.Has(activeMasternodeInfo.outpoint);
|
||||
|
||||
DBG( std::cout << "gobject: submit activeMasternodeInfo.keyIDMasternode = " << activeMasternodeInfo.keyIDMasternode.ToString()
|
||||
DBG( std::cout << "gobject: submit activeMasternodeInfo.keyIDOperator = " << activeMasternodeInfo.keyIDOperator.ToString()
|
||||
<< ", outpoint = " << activeMasternodeInfo.outpoint.ToStringShort()
|
||||
<< ", params.size() = " << request.params.size()
|
||||
<< ", fMnFound = " << fMnFound << std::endl; );
|
||||
@ -286,7 +286,7 @@ UniValue gobject_submit(const JSONRPCRequest& request)
|
||||
if(govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) {
|
||||
if(fMnFound) {
|
||||
govobj.SetMasternodeOutpoint(activeMasternodeInfo.outpoint);
|
||||
govobj.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode);
|
||||
govobj.Sign(activeMasternodeInfo.keyOperator, activeMasternodeInfo.keyIDOperator);
|
||||
}
|
||||
else {
|
||||
LogPrintf("gobject(submit) -- Object submission rejected because node is not a masternode\n");
|
||||
@ -389,7 +389,7 @@ UniValue gobject_vote_conf(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome);
|
||||
if(!vote.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode)) {
|
||||
if(!vote.Sign(activeMasternodeInfo.keyOperator, activeMasternodeInfo.keyIDOperator)) {
|
||||
nFailed++;
|
||||
statusObj.push_back(Pair("result", "failed"));
|
||||
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
|
||||
@ -428,12 +428,12 @@ UniValue VoteWithMasternodeList(const std::vector<CMasternodeConfig::CMasternode
|
||||
UniValue resultsObj(UniValue::VOBJ);
|
||||
|
||||
for (const auto& mne : entries) {
|
||||
CPubKey pubKeyMasternode;
|
||||
CKey keyMasternode;
|
||||
CPubKey pubKeyOperator;
|
||||
CKey keyOperator;
|
||||
|
||||
UniValue statusObj(UniValue::VOBJ);
|
||||
|
||||
if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){
|
||||
if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyOperator, pubKeyOperator)) {
|
||||
nFailed++;
|
||||
statusObj.push_back(Pair("result", "failed"));
|
||||
statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly"));
|
||||
@ -463,7 +463,7 @@ UniValue VoteWithMasternodeList(const std::vector<CMasternodeConfig::CMasternode
|
||||
}
|
||||
|
||||
CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome);
|
||||
if(!vote.Sign(keyMasternode, pubKeyMasternode.GetID())){
|
||||
if(!vote.Sign(keyOperator, pubKeyOperator.GetID())) {
|
||||
nFailed++;
|
||||
statusObj.push_back(Pair("result", "failed"));
|
||||
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
|
||||
@ -981,6 +981,16 @@ UniValue voteraw(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
|
||||
}
|
||||
|
||||
int govObjType;
|
||||
{
|
||||
LOCK(governance.cs);
|
||||
CGovernanceObject *pGovObj = governance.FindGovernanceObject(hashGovObj);
|
||||
if (!pGovObj) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Governance object not found");
|
||||
}
|
||||
govObjType = pGovObj->GetObjectType();
|
||||
}
|
||||
|
||||
int64_t nTime = request.params[5].get_int64();
|
||||
std::string strSig = request.params[6].get_str();
|
||||
bool fInvalid = false;
|
||||
@ -1001,7 +1011,9 @@ UniValue voteraw(const JSONRPCRequest& request)
|
||||
vote.SetTime(nTime);
|
||||
vote.SetSignature(vchSig);
|
||||
|
||||
if(!vote.IsValid(true)) {
|
||||
bool onlyOwnerAllowed = govObjType == GOVERNANCE_OBJECT_PROPOSAL;
|
||||
|
||||
if(!vote.IsValid(onlyOwnerAllowed)) {
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to verify vote.");
|
||||
}
|
||||
|
||||
|
@ -939,9 +939,15 @@ UniValue masternodelist(const JSONRPCRequest& request)
|
||||
if (strFilter !="" && strFilter != strprintf("%d", mn.nProtocolVersion) &&
|
||||
strOutpoint.find(strFilter) == std::string::npos) continue;
|
||||
obj.push_back(Pair(strOutpoint, mn.nProtocolVersion));
|
||||
} else if (strMode == "keyid") {
|
||||
} else if (strMode == "keyIDOwner") {
|
||||
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
|
||||
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDMasternode)));
|
||||
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDOwner)));
|
||||
} else if (strMode == "keyIDOperator") {
|
||||
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
|
||||
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDOperator)));
|
||||
} else if (strMode == "keyIDVoting") {
|
||||
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
|
||||
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDVoting)));
|
||||
} else if (strMode == "status") {
|
||||
std::string strStatus = mn.GetStatus();
|
||||
if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
|
||||
@ -1127,7 +1133,7 @@ UniValue masternodebroadcast(const JSONRPCRequest& request)
|
||||
resultObj.push_back(Pair("outpoint", mnb.outpoint.ToStringShort()));
|
||||
resultObj.push_back(Pair("addr", mnb.addr.ToString()));
|
||||
resultObj.push_back(Pair("keyIDCollateralAddress", CBitcoinAddress(mnb.keyIDCollateralAddress).ToString()));
|
||||
resultObj.push_back(Pair("keyIDMasternode", CBitcoinAddress(mnb.keyIDMasternode).ToString()));
|
||||
resultObj.push_back(Pair("keyIDMasternode", CBitcoinAddress(mnb.keyIDOperator).ToString()));
|
||||
resultObj.push_back(Pair("vchSig", EncodeBase64(&mnb.vchSig[0], mnb.vchSig.size())));
|
||||
resultObj.push_back(Pair("sigTime", mnb.sigTime));
|
||||
resultObj.push_back(Pair("protocolVersion", mnb.nProtocolVersion));
|
||||
|
Loading…
Reference in New Issue
Block a user