refactor: use signing helper function instead of passing blsKeyOperator

This commit is contained in:
Kittywhiskers Van Gogh 2024-03-17 16:39:29 +00:00
parent 33702aca39
commit 1b516ce4ed
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
6 changed files with 14 additions and 12 deletions

View File

@ -698,8 +698,8 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg
return std::nullopt;
}
gov_sb.SetMasternodeOutpoint(::activeMasternodeManager->m_info.outpoint);
gov_sb.Sign( *::activeMasternodeManager->m_info.blsKeyOperator);
} // ::activeMasternodeManager->cs
gov_sb.Sign(*::activeMasternodeManager);
if (std::string strError; !gov_sb.IsValidLocally(m_dmnman->GetListAtChainTip(), strError, true)) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Created trigger is invalid:%s\n", __func__, strError);
@ -765,7 +765,7 @@ bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_out
{
CGovernanceVote vote(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint), nHash, VOTE_SIGNAL_FUNDING, outcome);
vote.SetTime(GetAdjustedTime());
vote.Sign(WITH_LOCK(::activeMasternodeManager->cs, return *::activeMasternodeManager->m_info.blsKeyOperator));
vote.Sign(*::activeMasternodeManager);
CGovernanceException exception;
if (!ProcessVoteAndRelay(vote, exception, connman)) {

View File

@ -11,6 +11,7 @@
#include <governance/governance.h>
#include <governance/validators.h>
#include <masternode/meta.h>
#include <masternode/node.h>
#include <masternode/sync.h>
#include <messagesigner.h>
#include <net.h>
@ -273,9 +274,9 @@ void CGovernanceObject::SetMasternodeOutpoint(const COutPoint& outpoint)
m_obj.masternodeOutpoint = outpoint;
}
bool CGovernanceObject::Sign(const CBLSSecretKey& key)
bool CGovernanceObject::Sign(const CActiveMasternodeManager& mn_activeman)
{
CBLSSignature sig = key.Sign(GetSignatureHash(), false);
CBLSSignature sig = mn_activeman.Sign(GetSignatureHash(), false);
if (!sig.IsValid()) {
return false;
}

View File

@ -13,7 +13,7 @@
#include <univalue.h>
class CBLSSecretKey;
class CActiveMasternodeManager;
class CBLSPublicKey;
class CDeterministicMNList;
class CGovernanceManager;
@ -217,7 +217,7 @@ public:
// Signature related functions
void SetMasternodeOutpoint(const COutPoint& outpoint);
bool Sign(const CBLSSecretKey& key);
bool Sign(const CActiveMasternodeManager& mn_activeman);
bool CheckSignature(const CBLSPublicKey& pubKey) const;
uint256 GetSignatureHash() const;

View File

@ -8,6 +8,7 @@
#include <bls/bls.h>
#include <chainparams.h>
#include <key.h>
#include <masternode/node.h>
#include <masternode/sync.h>
#include <messagesigner.h>
#include <net.h>
@ -221,9 +222,9 @@ bool CGovernanceVote::CheckSignature(const CKeyID& keyID) const
return true;
}
bool CGovernanceVote::Sign(const CBLSSecretKey& key)
bool CGovernanceVote::Sign(const CActiveMasternodeManager& mn_activeman)
{
CBLSSignature sig = key.Sign(GetSignatureHash(), false);
CBLSSignature sig = mn_activeman.Sign(GetSignatureHash(), false);
if (!sig.IsValid()) {
return false;
}

View File

@ -8,11 +8,11 @@
#include <primitives/transaction.h>
#include <uint256.h>
class CGovernanceVote;
class CActiveMasternodeManager;
class CBLSPublicKey;
class CBLSSecretKey;
class CConnman;
class CDeterministicMNList;
class CGovernanceVote;
class CKey;
class CKeyID;
@ -101,7 +101,7 @@ public:
bool Sign(const CKey& key, const CKeyID& keyID);
bool CheckSignature(const CKeyID& keyID) const;
bool Sign(const CBLSSecretKey& key);
bool Sign(const CActiveMasternodeManager& mn_activeman);
bool CheckSignature(const CBLSPublicKey& pubKey) const;
bool IsValid(const CDeterministicMNList& tip_mn_list, bool useVotingKey) const;
void Relay(CConnman& connman, const CDeterministicMNList& tip_mn_list) const;

View File

@ -93,7 +93,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"spork -> validation -> spork"
"governance/governance -> validation -> governance/governance"
"evo/deterministicmns -> validationinterface -> governance/vote -> evo/deterministicmns"
"governance/vote -> validation -> validationinterface -> governance/vote"
"governance/vote -> masternode/node -> validationinterface -> governance/vote"
"llmq/signing -> masternode/node -> validationinterface -> llmq/signing"
"evo/mnhftx -> validation -> evo/mnhftx"
"evo/deterministicmns -> validation -> evo/deterministicmns"