@@ -489,8 +489,6 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
489489 if (lastPing == CMasternodePing () || !lastPing.CheckAndUpdate (nDos, false , true ))
490490 return false ;
491491
492- std::string strMessage = GetStrMessage ();
493-
494492 if (protocolVersion < masternodePayments.GetMinMasternodePaymentsProto ()) {
495493 LogPrint (" masternode" ," mnb - ignoring outdated Masternode %s protocol version %d\n " , vin.prevout .hash .ToString (), protocolVersion);
496494 return false ;
@@ -520,7 +518,8 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
520518 }
521519
522520 std::string errorMessage = " " ;
523- if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, strMessage, errorMessage)) {
521+ if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetNewStrMessage (), errorMessage)
522+ && !obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetOldStrMessage (), errorMessage)) {
524523 LogPrint (" masternode" ," mnb - Got bad Masternode address signature\n " );
525524 // don't ban for old masternodes, their sigs could be broken because of the bug
526525 nDos = protocolVersion < MIN_PEER_MNANNOUNCE ? 0 : 100 ;
@@ -660,7 +659,7 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
660659{
661660 std::string errorMessage;
662661 sigTime = GetAdjustedTime ();
663- std::string strMessage = GetStrMessage ();
662+ std::string strMessage = GetNewStrMessage ();
664663
665664 if (!obfuScationSigner.SignMessage (strMessage, errorMessage, sig, keyCollateralAddress)) {
666665 return error (" CMasternodeBroadcast::Sign() - Error: %s" , errorMessage);
@@ -676,28 +675,34 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
676675bool CMasternodeBroadcast::VerifySignature ()
677676{
678677 std::string errorMessage;
679- std::string strMessage = GetStrMessage ();
680678
681- if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, strMessage, errorMessage)) {
679+ if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetNewStrMessage (), errorMessage)
680+ && !obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetOldStrMessage (), errorMessage)) {
682681 return error (" CMasternodeBroadcast::VerifySignature() - Error: %s" , errorMessage);
683682 }
684683
685684 return true ;
686685}
687686
688- std::string CMasternodeBroadcast::GetStrMessage ()
687+ std::string CMasternodeBroadcast::GetOldStrMessage ()
689688{
690689 std::string strMessage;
691- if (protocolVersion < MIN_PEER_MNANNOUNCE) {
692- std::string vchPubKey (pubKeyCollateralAddress.begin (), pubKeyCollateralAddress.end ());
693- std::string vchPubKey2 (pubKeyMasternode.begin (), pubKeyMasternode.end ());
694- strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
695- } else {
696- strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + pubKeyCollateralAddress.GetID ().ToString () + pubKeyMasternode.GetID ().ToString () + boost::lexical_cast<std::string>(protocolVersion);
697- }
690+
691+ std::string vchPubKey (pubKeyCollateralAddress.begin (), pubKeyCollateralAddress.end ());
692+ std::string vchPubKey2 (pubKeyMasternode.begin (), pubKeyMasternode.end ());
693+ strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
694+
698695 return strMessage;
699696}
700697
698+ std:: string CMasternodeBroadcast::GetNewStrMessage ()
699+ {
700+ std::string strMessage;
701+
702+ strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + pubKeyCollateralAddress.GetID ().ToString () + pubKeyMasternode.GetID ().ToString () + boost::lexical_cast<std::string>(protocolVersion);
703+
704+ return strMessage;
705+ }
701706
702707CMasternodePing::CMasternodePing ()
703708{
0 commit comments