refactor: new method to generate a signing message in CGovernanceVote

This commit is contained in:
Konstantin Akimov 2024-06-27 20:32:11 +07:00
parent 6e5d3f1d1f
commit 490832959d
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 10 additions and 6 deletions

View File

@ -208,12 +208,7 @@ bool CGovernanceVote::CheckSignature(const CKeyID& keyID) const
return false;
}
} else {
std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
::ToString(nVoteSignal) + "|" +
::ToString(nVoteOutcome) + "|" +
::ToString(nTime);
if (!CMessageSigner::VerifyMessage(keyID, vchSig, strMessage, strError)) {
if (!CMessageSigner::VerifyMessage(keyID, vchSig, GetSignatureString(), strError)) {
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -275,6 +270,14 @@ bool CGovernanceVote::IsValid(const CDeterministicMNList& tip_mn_list, bool useV
}
}
std::string CGovernanceVote::GetSignatureString() const
{
return masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
::ToString(nVoteSignal) + "|" +
::ToString(nVoteOutcome) + "|" +
::ToString(nTime);
}
bool operator==(const CGovernanceVote& vote1, const CGovernanceVote& vote2)
{
bool fResult = ((vote1.masternodeOutpoint == vote2.masternodeOutpoint) &&

View File

@ -105,6 +105,7 @@ public:
bool Sign(const CActiveMasternodeManager& mn_activeman);
bool CheckSignature(const CBLSPublicKey& pubKey) const;
bool IsValid(const CDeterministicMNList& tip_mn_list, bool useVotingKey) const;
std::string GetSignatureString() const;
void Relay(PeerManager& peerman, const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list) const;
const COutPoint& GetMasternodeOutpoint() const { return masternodeOutpoint; }