mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
fix masternode signatures, bump PROTOCOL_VERSION
strMessage for masternode broadcast (which we sign and verify) looks like this currently: [2001:1608:45:3::242:ac11:6]:199991464464536 ?~}&?Q?S?Ǚ?q ?0??????O?I/Y?( ?f?jJF??m??bssknN??9鲜JXVs?ә?5T?8??????~70200 which I believe in some cases leads to "Got bad Masternode ping signature" errors and banning. I propose to change the way strMessage is composed so that it looks like this: [2002:82ff:c04:2:a90f:2261:43c4:2745]:1999514645552319591ec70225aacadfafa4ab5d21e87cdce641fd4030d029485434533c5e481578a9d471089fb5ec170200 Further more nDos for old masternodes is set to 0 to stop false positives (message still gets rejected though).
This commit is contained in:
parent
4d55bc9666
commit
d705da741c
@ -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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
|
||||
} else {
|
||||
strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
|
||||
pubkey.GetID().ToString() + pubkey2.GetID().ToString() +
|
||||
boost::lexical_cast<std::string>(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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
|
||||
} else {
|
||||
strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
|
||||
pubkey.GetID().ToString() + pubkey2.GetID().ToString() +
|
||||
boost::lexical_cast<std::string>(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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(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<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);
|
||||
} else {
|
||||
strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
|
||||
pubkey.GetID().ToString() + pubkey2.GetID().ToString() +
|
||||
boost::lexical_cast<std::string>(protocolVersion);
|
||||
}
|
||||
|
||||
if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)) {
|
||||
LogPrintf("CMasternodeBroadcast::VerifySignature() - Error: %s\n", errorMessage);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user