diff --git a/src/masternode.cpp b/src/masternode.cpp index d281593e7..e17cf90fd 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -370,9 +370,16 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) if(lastPing == CMasternodePing() || !lastPing.CheckAndUpdate(nDos, false, true)) return false; - std::string vchPubKey(pubkey.begin(), pubkey.end()); - std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); - std::string strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + std::string strMessage; + if(protocolVersion < 70201) { + std::string vchPubKey(pubkey.begin(), pubkey.end()); + std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + } else { + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + + pubkey.GetID().ToString() + pubkey2.GetID().ToString() + + boost::lexical_cast(protocolVersion); + } if(protocolVersion < mnpayments.GetMinMasternodePaymentsProto()) { LogPrintf("CMasternodeBroadcast::CheckAndUpdate - ignoring outdated Masternode %s protocol version %d\n", vin.ToString(), protocolVersion); @@ -405,7 +412,8 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) std::string errorMessage = ""; if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ LogPrintf("CMasternodeBroadcast::CheckAndUpdate - Got bad Masternode address signature\n"); - nDos = 100; + // don't ban for old masternodes, their sigs could be broken because of the bug + nDos = protocolVersion < 70201 ? 0 : 100; return false; } @@ -567,12 +575,18 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress) { std::string errorMessage; - std::string vchPubKey(pubkey.begin(), pubkey.end()); - std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); - sigTime = GetAdjustedTime(); - std::string strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + std::string strMessage; + if(protocolVersion < 70201) { + std::string vchPubKey(pubkey.begin(), pubkey.end()); + std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + } else { + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + + pubkey.GetID().ToString() + pubkey2.GetID().ToString() + + boost::lexical_cast(protocolVersion); + } if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyCollateralAddress)) { LogPrintf("CMasternodeBroadcast::Sign() - Error: %s\n", errorMessage); @@ -586,10 +600,16 @@ bool CMasternodeBroadcast::VerifySignature() { std::string errorMessage; - std::string vchPubKey(pubkey.begin(), pubkey.end()); - std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); - - std::string strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + std::string strMessage; + if(protocolVersion < 70201) { + std::string vchPubKey(pubkey.begin(), pubkey.end()); + std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + } else { + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + + pubkey.GetID().ToString() + pubkey2.GetID().ToString() + + boost::lexical_cast(protocolVersion); + } if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)) { LogPrintf("CMasternodeBroadcast::VerifySignature() - Error: %s\n", errorMessage); diff --git a/src/version.h b/src/version.h index 266b0f6d6..99cfee0d8 100644 --- a/src/version.h +++ b/src/version.h @@ -10,7 +10,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70200; +static const int PROTOCOL_VERSION = 70201; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209;