41 int nOurNodeVersion{PROTOCOL_VERSION};
43 nOurNodeVersion = (int)
gArgs.
GetArg(
"-pushversion", PROTOCOL_VERSION);
45 if (pnode->
nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
54 mnauth.
sig = activeMnInfo->keyOperator.Sign(signHash);
72 if (fAlreadyHaveMNAUTH) {
73 return state.
DoS(100,
false, REJECT_INVALID,
"duplicate mnauth");
78 return state.
DoS(100,
false, REJECT_INVALID,
"mnauth from a node with invalid services");
82 return state.
DoS(100,
false, REJECT_INVALID,
"empty mnauth proRegTxHash");
86 return state.
DoS(100,
false, REJECT_INVALID,
"invalid mnauth signature");
95 return state.
DoS(10,
false, REJECT_INVALID,
"missing mnauth masternode");
101 int nOurNodeVersion{PROTOCOL_VERSION};
103 nOurNodeVersion =
gArgs.
GetArg(
"-pushversion", PROTOCOL_VERSION);
106 if (pnode->
nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
114 if (!mnauth.
sig.
VerifyInsecure(dmn->pdmnState->pubKeyOperator.Get(), signHash)) {
117 return state.
DoS(10,
false, REJECT_INVALID,
"mnauth signature verification failed");
145 auto deterministicOutbound = llmq::DeterministicOutboundConnection(activeMnInfo->proTxHash, mnauth.proRegTxHash);
146 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- Masternode %s has already verified as peer %d, deterministicOutbound=%s. peer=%d\n",
147 mnauth.proRegTxHash.ToString(), pnode2->GetId(), deterministicOutbound.ToString(), pnode->GetId());
148 if (deterministicOutbound == activeMnInfo->proTxHash) {
149 if (pnode2->fInbound) {
150 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- dropping old inbound, peer=%d\n", pnode2->GetId());
151 pnode2->fDisconnect = true;
152 } else if (pnode->fInbound) {
153 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- dropping new inbound, peer=%d\n", pnode->GetId());
154 pnode->fDisconnect = true;
157 if (!pnode2->fInbound) {
158 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- dropping old outbound, peer=%d\n", pnode2->GetId());
159 pnode2->fDisconnect = true;
160 } else if (!pnode->fInbound) {
161 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- dropping new outbound, peer=%d\n", pnode->GetId());
162 pnode->fDisconnect = true;
166 LogPrint(BCLog::NET_MN,
"CMNAuth::ProcessMessage -- Masternode %s has already verified as peer %d, dropping new connection. peer=%d\n",
167 mnauth.proRegTxHash.ToString(), pnode2->GetId(), pnode->GetId());
168 pnode->fDisconnect = true;
193 LogPrint(
BCLog::NET_MN,
"CMNAuth::%s -- Valid MNAUTH for %s, peer=%d\n", __func__, mnauth.proRegTxHash.ToString(), pnode->
GetId());
214 bool doRemove =
false;
215 if (diff.
removedMns.count(verifiedDmn->GetInternalId())) {
218 auto it = diff.
updatedMNs.find(verifiedDmn->GetInternalId());
227 LogPrint(
BCLog::NET_MN,
"CMNAuth::NotifyMasternodeListChanged -- Disconnecting MN %s due to key changed/removed, peer=%d\n",
CActiveDeterministicMasternodeManager * activeMasternodeManager
const CChainParams & Params()
Return the currently selected parameters.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
const CActiveMasternodeInfo * GetInfo() const
bool VerifyInsecure(const CBLSPublicKey &pubKey, const uint256 &hash) const
static const std::string MAIN
Chain name strings.
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg, bool allowOptimisticSend=DEFAULT_ALLOW_OPTIMISTIC_SEND)
TierTwoConnMan * GetTierTwoConnMan()
Unique tier two connections manager.
void ForEachNode(Callable &&func)
std::set< uint64_t > removedMns
std::map< uint64_t, CDeterministicMNStateDiff > updatedMNs
CDeterministicMNCPtr GetMN(const uint256 &proTxHash) const
This class handles the p2p message MNAUTH.
static void PushMNAUTH(CNode *pnode, CConnman &connman)
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList &oldMNList, const CDeterministicMNListDiff &diff)
static bool ProcessMessage(CNode *pnode, const std::string &strCommand, CDataStream &vRecv, CConnman &connman, CValidationState &state)
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args &&... args)
Information about a peer.
std::atomic< int > nVersion
int GetSendVersion() const
std::atomic< ServiceFlags > nServices
uint256 verifiedProRegTxHash
uint256 verifiedPubKeyHash
uint256 sentMNAuthChallenge
uint256 receivedMNAuthChallenge
std::atomic< bool > m_masternode_probe_connection
std::atomic< bool > m_masternode_iqr_connection
std::atomic_bool fDisconnect
Capture information about block/transaction validation.
bool DoS(int level, bool ret=false, unsigned int chRejectCodeIn=0, std::string strRejectReasonIn="", bool corruptionIn=false, const std::string &strDebugMessageIn="")
bool isMasternodeQuorumRelayMember(const uint256 &protxHash)
bool IsBlockchainSynced() const
std::string ToString() const
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
std::unique_ptr< CConnman > g_connman
#define LogPrint(category,...)
const char * QSENDRECSIGS
The qsendrecsigs message is used to propagate LLMQ intra-quorum partial recovered signatures.
const char * MNAUTH
The mnauth message is used authenticate MN connections.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::atomic< bool > fMasterNode
TierTwoSyncState g_tiertwo_sync_state
int64_t GetAdjustedTime()