@@ -26,6 +26,8 @@ std::string CActiveMasternodeManager::GetStateString() const
2626 return " REMOVED" ;
2727 case MASTERNODE_OPERATOR_KEY_CHANGED:
2828 return " OPERATOR_KEY_CHANGED" ;
29+ case MASTERNODE_PROTX_IP_CHANGED:
30+ return " PROTX_IP_CHANGED" ;
2931 case MASTERNODE_READY:
3032 return " READY" ;
3133 case MASTERNODE_ERROR:
@@ -46,6 +48,8 @@ std::string CActiveMasternodeManager::GetStatus() const
4648 return " Masternode removed from list" ;
4749 case MASTERNODE_OPERATOR_KEY_CHANGED:
4850 return " Operator key changed or revoked" ;
51+ case MASTERNODE_PROTX_IP_CHANGED:
52+ return " IP address specified in ProTx changed" ;
4953 case MASTERNODE_READY:
5054 return " Ready" ;
5155 case MASTERNODE_ERROR:
@@ -94,11 +98,9 @@ void CActiveMasternodeManager::Init()
9498 return ;
9599 }
96100
97- mnListEntry = dmn;
101+ LogPrintf ( " CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s \n " , dmn-> proTxHash . ToString (), dmn-> ToString ()) ;
98102
99- LogPrintf (" CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s\n " , mnListEntry->proTxHash .ToString (), mnListEntry->ToString ());
100-
101- if (activeMasternodeInfo.service != mnListEntry->pdmnState ->addr ) {
103+ if (activeMasternodeInfo.service != dmn->pdmnState ->addr ) {
102104 state = MASTERNODE_ERROR;
103105 strError = " Local address does not match the address from ProTx" ;
104106 LogPrintf (" CActiveMasternodeManager::Init -- ERROR: %s" , strError);
@@ -120,8 +122,8 @@ void CActiveMasternodeManager::Init()
120122 }
121123 }
122124
123- activeMasternodeInfo.proTxHash = mnListEntry ->proTxHash ;
124- activeMasternodeInfo.outpoint = mnListEntry ->collateralOutpoint ;
125+ activeMasternodeInfo.proTxHash = dmn ->proTxHash ;
126+ activeMasternodeInfo.outpoint = dmn ->collateralOutpoint ;
125127 state = MASTERNODE_READY;
126128}
127129
@@ -134,24 +136,41 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
134136 if (!deterministicMNManager->IsDIP3Enforced (pindexNew->nHeight )) return ;
135137
136138 if (state == MASTERNODE_READY) {
137- auto mnList = deterministicMNManager->GetListForBlock (pindexNew);
138- if (!mnList.IsMNValid (mnListEntry->proTxHash )) {
139+ auto oldMNList = deterministicMNManager->GetListForBlock (pindexNew->pprev );
140+ auto newMNList = deterministicMNManager->GetListForBlock (pindexNew);
141+ if (!newMNList.IsMNValid (activeMasternodeInfo.proTxHash )) {
139142 // MN disappeared from MN list
140143 state = MASTERNODE_REMOVED;
141144 activeMasternodeInfo.proTxHash = uint256 ();
142145 activeMasternodeInfo.outpoint .SetNull ();
143146 // MN might have reappeared in same block with a new ProTx
144147 Init ();
145- } else if (mnList.GetMN (mnListEntry->proTxHash )->pdmnState ->pubKeyOperator != mnListEntry->pdmnState ->pubKeyOperator ) {
148+ return ;
149+ }
150+
151+ auto oldDmn = oldMNList.GetMN (activeMasternodeInfo.proTxHash );
152+ auto newDmn = newMNList.GetMN (activeMasternodeInfo.proTxHash );
153+ if (newDmn->pdmnState ->pubKeyOperator != oldDmn->pdmnState ->pubKeyOperator ) {
146154 // MN operator key changed or revoked
147155 state = MASTERNODE_OPERATOR_KEY_CHANGED;
148156 activeMasternodeInfo.proTxHash = uint256 ();
149157 activeMasternodeInfo.outpoint .SetNull ();
150158 // MN might have reappeared in same block with a new ProTx
151159 Init ();
160+ return ;
161+ }
162+
163+ if (newDmn->pdmnState ->addr != oldDmn->pdmnState ->addr ) {
164+ // MN IP changed
165+ state = MASTERNODE_PROTX_IP_CHANGED;
166+ activeMasternodeInfo.proTxHash = uint256 ();
167+ activeMasternodeInfo.outpoint .SetNull ();
168+ Init ();
169+ return ;
152170 }
153171 } else {
154- // MN might have (re)appeared with a new ProTx or we've found some peers and figured out our local address
172+ // MN might have (re)appeared with a new ProTx or we've found some peers
173+ // and figured out our local address
155174 Init ();
156175 }
157176}
0 commit comments