1919void CMNAuth::PushMNAUTH (CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman)
2020{
2121 CMNAuth mnauth;
22- if (mn_activeman.GetProTxHash ().IsNull ()) {
22+ const uint256 pro_tx_hash{mn_activeman.GetProTxHash ()};
23+ if (pro_tx_hash.IsNull ()) {
2324 return ;
2425 }
26+ if (peer.IsInboundConn ()) {
27+ const CService expected_service{mn_activeman.GetService ()};
28+ const CService connected_service{static_cast <const CService&>(peer.addrBind )};
29+ if (expected_service != connected_service) {
30+ LogPrint (BCLog::NET_NETCONN, /* Continued */
31+ " CMNAuth::%s -- Not sending MNAUTH on unexpected local service, expected=%s, connected=%s, "
32+ " peer=%d\n " ,
33+ __func__, expected_service.ToStringAddrPort (), connected_service.ToStringAddrPort (), peer.GetId ());
34+ return ;
35+ }
36+ }
2537
2638 const auto receivedMNAuthChallenge = peer.GetReceivedMNAuthChallenge ();
2739 if (receivedMNAuthChallenge.IsNull ()) {
@@ -39,7 +51,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
3951 }
4052 const uint256 signHash{::SerializeHash (std::make_tuple (mn_activeman.GetPubKey (), receivedMNAuthChallenge, peer.IsInboundConn (), nOurNodeVersion))};
4153
42- mnauth.proRegTxHash = mn_activeman. GetProTxHash () ;
54+ mnauth.proRegTxHash = pro_tx_hash ;
4355
4456 // all clients uses basic BLS
4557 mnauth.sig = mn_activeman.Sign (signHash, false );
0 commit comments