diff --git a/src/instantx.cpp b/src/instantx.cpp index 0f7ddba7dd2fa..30a8ca20c698c 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -292,7 +292,7 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight) LogPrintf("DoConsensusVote -- Failed to sign consensus vote\n"); return; } - if(!vote.SignatureValid()) { + if(!vote.CheckSignature()) { LogPrintf("DoConsensusVote -- Signature invalid\n"); return; } @@ -327,7 +327,7 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& vote) return false; } - if(!vote.SignatureValid()) { + if(!vote.CheckSignature()) { LogPrintf("ProcessConsensusVote -- Signature invalid\n"); // don't ban, it could just be a non-synced masternode mnodeman.AskForMN(pnode, vote.vinMasternode); @@ -546,21 +546,21 @@ uint256 CConsensusVote::GetHash() const } -bool CConsensusVote::SignatureValid() +bool CConsensusVote::CheckSignature() { - std::string errorMessage; + std::string strError; std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast(nBlockHeight); //LogPrintf("verify strMessage %s \n", strMessage); CMasternode* pmn = mnodeman.Find(vinMasternode); if(pmn == NULL) { - LogPrintf("CConsensusVote::SignatureValid -- Unknown Masternode: txin=%s\n", vinMasternode.ToString()); + LogPrintf("CConsensusVote::CheckSignature -- Unknown Masternode: txin=%s\n", vinMasternode.ToString()); return false; } - if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) { - LogPrintf("CConsensusVote::SignatureValid -- VerifyMessage() failed\n"); + if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchMasterNodeSignature, strMessage, strError)) { + LogPrintf("CConsensusVote::CheckSignature -- VerifyMessage() failed\n"); return false; } @@ -569,16 +569,16 @@ bool CConsensusVote::SignatureValid() bool CConsensusVote::Sign() { - std::string errorMessage; + std::string strError; std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast(nBlockHeight); - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, activeMasternode.keyMasternode)) { + if(!darkSendSigner.SignMessage(strMessage, strError, vchMasterNodeSignature, activeMasternode.keyMasternode)) { LogPrintf("CConsensusVote::Sign -- SignMessage() failed"); return false; } - if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, errorMessage)) { + if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) { LogPrintf("CConsensusVote::Sign -- VerifyMessage() failed"); return false; } @@ -587,7 +587,7 @@ bool CConsensusVote::Sign() } -bool CTransactionLock::VotesValid() +bool CTransactionLock::IsAllVotesValid() { BOOST_FOREACH(CConsensusVote vote, vecConsensusVotes) @@ -595,17 +595,17 @@ bool CTransactionLock::VotesValid() int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION); if(n == -1) { - LogPrintf("CTransactionLock::VotesValid -- Unknown Masternode, txin=%s\n", vote.vinMasternode.ToString()); + LogPrintf("CTransactionLock::IsAllVotesValid -- Unknown Masternode, txin=%s\n", vote.vinMasternode.ToString()); return false; } if(n > INSTANTSEND_SIGNATURES_TOTAL) { - LogPrintf("CTransactionLock::VotesValid -- Masternode not in the top %s\n", INSTANTSEND_SIGNATURES_TOTAL); + LogPrintf("CTransactionLock::IsAllVotesValid -- Masternode not in the top %s\n", INSTANTSEND_SIGNATURES_TOTAL); return false; } - if(!vote.SignatureValid()) { - LogPrintf("CTransactionLock::VotesValid -- Signature not valid\n"); + if(!vote.CheckSignature()) { + LogPrintf("CTransactionLock::IsAllVotesValid -- Signature not valid\n"); return false; } } diff --git a/src/instantx.h b/src/instantx.h index 2ff92446e8f66..b2bf9926f3ab1 100644 --- a/src/instantx.h +++ b/src/instantx.h @@ -86,11 +86,6 @@ class CConsensusVote int nBlockHeight; std::vector vchMasterNodeSignature; - uint256 GetHash() const; - - bool SignatureValid(); - bool Sign(); - ADD_SERIALIZE_METHODS; template @@ -100,6 +95,11 @@ class CConsensusVote READWRITE(vchMasterNodeSignature); READWRITE(nBlockHeight); } + + uint256 GetHash() const; + + bool Sign(); + bool CheckSignature(); }; class CTransactionLock @@ -111,14 +111,11 @@ class CTransactionLock int nLockExpirationBlock; int nTimeout; - bool VotesValid(); - int CountVotes(); - void AddVote(CConsensusVote& vote); + uint256 GetHash() const { return txHash; } - uint256 GetHash() - { - return txHash; - } + bool IsAllVotesValid(); + void AddVote(CConsensusVote& vote); + int CountVotes(); };