@@ -282,7 +282,7 @@ int64_t CMasternode::GetLastPaid()
282282
283283 if (masternodePayments.mapMasternodeBlocks .count (BlockReading->nHeight )) {
284284 /*
285- Search for this payee, with at least 2 votes. This will aid in consensus allowing the network
285+ Search for this payee, with at least 2 votes. This will aid in consensus allowing the network
286286 to converge on the same payees quickly, then keep the same schedule.
287287 */
288288 if (masternodePayments.mapMasternodeBlocks [BlockReading->nHeight ].HasPayeeWithVotes (mnpayee, 2 )) {
@@ -465,14 +465,14 @@ bool CMasternodeBroadcast::CheckDefaultPort(std::string strService, std::string&
465465{
466466 CService service = CService (strService);
467467 int nDefaultPort = Params ().GetDefaultPort ();
468-
468+
469469 if (service.GetPort () != nDefaultPort) {
470- strErrorRet = strprintf (" Invalid port %u for masternode %s, only %d is supported on %s-net." ,
470+ strErrorRet = strprintf (" Invalid port %u for masternode %s, only %d is supported on %s-net." ,
471471 service.GetPort (), strService, nDefaultPort, Params ().NetworkIDString ());
472472 LogPrint (" masternode" , " %s - %s\n " , strContext, strErrorRet);
473473 return false ;
474474 }
475-
475+
476476 return true ;
477477}
478478
@@ -520,7 +520,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
520520 std::string errorMessage = " " ;
521521 if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetNewStrMessage (), errorMessage)
522522 && !obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetOldStrMessage (), errorMessage)) {
523- LogPrint ( " masternode " , " mnb - Got bad Masternode address signature\n " );
523+ LogPrintf ( " CMasternodeBroadcast::CheckAndUpdate - Got bad Masternode address signature\n " );
524524 // don't ban for old masternodes, their sigs could be broken because of the bug
525525 nDos = protocolVersion < MIN_PEER_MNANNOUNCE ? 0 : 100 ;
526526 return false ;
@@ -659,27 +659,30 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
659659{
660660 std::string errorMessage;
661661 sigTime = GetAdjustedTime ();
662- std::string strMessage = GetNewStrMessage ();
663662
664- if (!obfuScationSigner.SignMessage (strMessage, errorMessage, sig, keyCollateralAddress)) {
665- return error (" CMasternodeBroadcast::Sign() - Error: %s" , errorMessage);
666- }
663+ std::string strMessage;
664+ if (chainActive.Height () < Params ().Zerocoin_Block_V2_Start ())
665+ strMessage = GetOldStrMessage ();
666+ else
667+ strMessage = GetNewStrMessage ();
667668
668- if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, strMessage, errorMessage)) {
669- return error (" CMasternodeBroadcast::Sign() - Error: %s" , errorMessage);
670- }
669+ if (!obfuScationSigner.SignMessage (strMessage, errorMessage, sig, keyCollateralAddress))
670+ return error (" CMasternodeBroadcast::Sign() - Error: %s" , errorMessage);
671+
672+ if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, strMessage, errorMessage))
673+ return error (" CMasternodeBroadcast::Sign() - Error: %s" , errorMessage);
671674
672675 return true ;
673676}
674677
678+
675679bool CMasternodeBroadcast::VerifySignature ()
676680{
677681 std::string errorMessage;
678682
679683 if (!obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetNewStrMessage (), errorMessage)
680- && !obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetOldStrMessage (), errorMessage)) {
684+ && !obfuScationSigner.VerifyMessage (pubKeyCollateralAddress, sig, GetOldStrMessage (), errorMessage))
681685 return error (" CMasternodeBroadcast::VerifySignature() - Error: %s" , errorMessage);
682- }
683686
684687 return true ;
685688}
@@ -688,20 +691,20 @@ std::string CMasternodeBroadcast::GetOldStrMessage()
688691{
689692 std::string strMessage;
690693
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+ std::string vchPubKey (pubKeyCollateralAddress.begin (), pubKeyCollateralAddress.end ());
695+ std::string vchPubKey2 (pubKeyMasternode.begin (), pubKeyMasternode.end ());
696+ strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
694697
695698 return strMessage;
696699}
697700
698701std:: string CMasternodeBroadcast::GetNewStrMessage ()
699702{
700- std::string strMessage;
703+ std::string strMessage;
701704
702- strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + pubKeyCollateralAddress.GetID ().ToString () + pubKeyMasternode.GetID ().ToString () + boost::lexical_cast<std::string>(protocolVersion);
705+ strMessage = addr.ToString () + boost::lexical_cast<std::string>(sigTime) + pubKeyCollateralAddress.GetID ().ToString () + pubKeyMasternode.GetID ().ToString () + boost::lexical_cast<std::string>(protocolVersion);
703706
704- return strMessage;
707+ return strMessage;
705708}
706709
707710CMasternodePing::CMasternodePing ()
0 commit comments