Masternode related refactorings in preparation of DIP3 (#2212)

* Split CActiveMasternode into CActiveMasternodeInfo and CLegacyActiveMasternodeManager

* Use CKeyID instead of CPubKey whenever possible in masternode code

* Rename activeMasternode to activeMasternodeInfo and make it a struct

* Rename pubKeyIDXXX to keyIDXXX

* Bump SERIALIZATION_VERSION_STRING

* Fix build error after rebase

* Fix compilation warning/error with clang
This commit is contained in:
Alexander Block 2018-08-11 21:55:56 +02:00 committed by UdjinM6
parent 633879cd28
commit d946f21bd9
23 changed files with 277 additions and 256 deletions

View File

@ -11,19 +11,19 @@
#include "netbase.h"
// Keep track of the active Masternode
CActiveMasternode activeMasternode;
CActiveMasternodeInfo activeMasternodeInfo;
CActiveLegacyMasternodeManager legacyActiveMasternodeManager;
void CActiveMasternode::ManageState(CConnman& connman)
void CActiveLegacyMasternodeManager::ManageState(CConnman& connman)
{
LogPrint("masternode", "CActiveMasternode::ManageState -- Start\n");
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- Start\n");
if(!fMasternodeMode) {
LogPrint("masternode", "CActiveMasternode::ManageState -- Not a masternode, returning\n");
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- Not a masternode, returning\n");
return;
}
if(Params().NetworkIDString() != CBaseChainParams::REGTEST && !masternodeSync.IsBlockchainSynced()) {
nState = ACTIVE_MASTERNODE_SYNC_IN_PROCESS;
LogPrintf("CActiveMasternode::ManageState -- %s: %s\n", GetStateString(), GetStatus());
LogPrintf("CActiveLegacyMasternodeManager::ManageState -- %s: %s\n", GetStateString(), GetStatus());
return;
}
@ -31,7 +31,7 @@ void CActiveMasternode::ManageState(CConnman& connman)
nState = ACTIVE_MASTERNODE_INITIAL;
}
LogPrint("masternode", "CActiveMasternode::ManageState -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
if(eType == MASTERNODE_UNKNOWN) {
ManageStateInitial(connman);
@ -44,7 +44,7 @@ void CActiveMasternode::ManageState(CConnman& connman)
SendMasternodePing(connman);
}
std::string CActiveMasternode::GetStateString() const
std::string CActiveLegacyMasternodeManager::GetStateString() const
{
switch (nState) {
case ACTIVE_MASTERNODE_INITIAL: return "INITIAL";
@ -56,7 +56,7 @@ std::string CActiveMasternode::GetStateString() const
}
}
std::string CActiveMasternode::GetStatus() const
std::string CActiveLegacyMasternodeManager::GetStatus() const
{
switch (nState) {
case ACTIVE_MASTERNODE_INITIAL: return "Node just started, not yet activated";
@ -68,7 +68,7 @@ std::string CActiveMasternode::GetStatus() const
}
}
std::string CActiveMasternode::GetTypeString() const
std::string CActiveLegacyMasternodeManager::GetTypeString() const
{
std::string strType;
switch(eType) {
@ -82,44 +82,44 @@ std::string CActiveMasternode::GetTypeString() const
return strType;
}
bool CActiveMasternode::SendMasternodePing(CConnman& connman)
bool CActiveLegacyMasternodeManager::SendMasternodePing(CConnman& connman)
{
if(!fPingerEnabled) {
LogPrint("masternode", "CActiveMasternode::SendMasternodePing -- %s: masternode ping service is disabled, skipping...\n", GetStateString());
LogPrint("masternode", "CActiveLegacyMasternodeManager::SendMasternodePing -- %s: masternode ping service is disabled, skipping...\n", GetStateString());
return false;
}
if(!mnodeman.Has(outpoint)) {
if(!mnodeman.Has(activeMasternodeInfo.outpoint)) {
strNotCapableReason = "Masternode not in masternode list";
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
LogPrintf("CActiveMasternode::SendMasternodePing -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- %s: %s\n", GetStateString(), strNotCapableReason);
return false;
}
CMasternodePing mnp(outpoint);
CMasternodePing mnp(activeMasternodeInfo.outpoint);
mnp.nSentinelVersion = nSentinelVersion;
mnp.fSentinelIsCurrent =
(abs(GetAdjustedTime() - nSentinelPingTime) < MASTERNODE_SENTINEL_PING_MAX_SECONDS);
if(!mnp.Sign(keyMasternode, pubKeyMasternode)) {
LogPrintf("CActiveMasternode::SendMasternodePing -- ERROR: Couldn't sign Masternode Ping\n");
if(!mnp.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode)) {
LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- ERROR: Couldn't sign Masternode Ping\n");
return false;
}
// Update lastPing for our masternode in Masternode list
if(mnodeman.IsMasternodePingedWithin(outpoint, MASTERNODE_MIN_MNP_SECONDS, mnp.sigTime)) {
LogPrintf("CActiveMasternode::SendMasternodePing -- Too early to send Masternode Ping\n");
if(mnodeman.IsMasternodePingedWithin(activeMasternodeInfo.outpoint, MASTERNODE_MIN_MNP_SECONDS, mnp.sigTime)) {
LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- Too early to send Masternode Ping\n");
return false;
}
mnodeman.SetMasternodeLastPing(outpoint, mnp);
mnodeman.SetMasternodeLastPing(activeMasternodeInfo.outpoint, mnp);
LogPrintf("CActiveMasternode::SendMasternodePing -- Relaying ping, collateral=%s\n", outpoint.ToStringShort());
LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- Relaying ping, collateral=%s\n", activeMasternodeInfo.outpoint.ToStringShort());
mnp.Relay(connman);
return true;
}
bool CActiveMasternode::UpdateSentinelPing(int version)
bool CActiveLegacyMasternodeManager::UpdateSentinelPing(int version)
{
nSentinelVersion = version;
nSentinelPingTime = GetAdjustedTime();
@ -127,41 +127,41 @@ bool CActiveMasternode::UpdateSentinelPing(int version)
return true;
}
void CActiveMasternode::ManageStateInitial(CConnman& connman)
void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman)
{
LogPrint("masternode", "CActiveMasternode::ManageStateInitial -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateInitial -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
// Check that our local network configuration is correct
if (!fListen) {
// listen option is probably overwritten by smth else, no good
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Masternode must accept connections from outside. Make sure listen configuration option is not overwritten by some another parameter.";
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
// First try to find whatever local address is specified by externalip option
bool fFoundLocal = GetLocal(service) && CMasternode::IsValidNetAddr(service);
bool fFoundLocal = GetLocal(activeMasternodeInfo.service) && CMasternode::IsValidNetAddr(activeMasternodeInfo.service);
if(!fFoundLocal) {
bool empty = true;
// If we have some peers, let's try to find our local address from one of them
connman.ForEachNodeContinueIf(CConnman::AllNodes, [&fFoundLocal, &empty, this](CNode* pnode) {
empty = false;
if (pnode->addr.IsIPv4())
fFoundLocal = GetLocal(service, &pnode->addr) && CMasternode::IsValidNetAddr(service);
fFoundLocal = GetLocal(activeMasternodeInfo.service, &pnode->addr) && CMasternode::IsValidNetAddr(activeMasternodeInfo.service);
return !fFoundLocal;
});
// nothing and no live connections, can't do anything for now
if (empty) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Can't detect valid external address. Will retry when there are some connections available.";
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
}
if (!fFoundLocal && Params().NetworkIDString() == CBaseChainParams::REGTEST) {
if (Lookup("127.0.0.1", activeMasternode.service, GetListenPort(), false)) {
if (Lookup("127.0.0.1", activeMasternodeInfo.service, GetListenPort(), false)) {
fFoundLocal = true;
}
}
@ -169,75 +169,75 @@ void CActiveMasternode::ManageStateInitial(CConnman& connman)
if(!fFoundLocal) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only.";
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort();
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(service.GetPort() != mainnetDefaultPort) {
if(activeMasternodeInfo.service.GetPort() != mainnetDefaultPort) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = strprintf("Invalid port: %u - only %d is supported on mainnet.", service.GetPort(), mainnetDefaultPort);
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
strNotCapableReason = strprintf("Invalid port: %u - only %d is supported on mainnet.", activeMasternodeInfo.service.GetPort(), mainnetDefaultPort);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
} else if(service.GetPort() == mainnetDefaultPort) {
} else if(activeMasternodeInfo.service.GetPort() == mainnetDefaultPort) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = strprintf("Invalid port: %u - %d is only supported on mainnet.", service.GetPort(), mainnetDefaultPort);
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
strNotCapableReason = strprintf("Invalid port: %u - %d is only supported on mainnet.", activeMasternodeInfo.service.GetPort(), mainnetDefaultPort);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
if(Params().NetworkIDString() != CBaseChainParams::REGTEST) {
// Check socket connectivity
LogPrintf("CActiveMasternode::ManageStateInitial -- Checking inbound connection to '%s'\n", service.ToString());
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- Checking inbound connection to '%s'\n", activeMasternodeInfo.service.ToString());
SOCKET hSocket;
bool fConnected = ConnectSocket(service, hSocket, nConnectTimeout) && IsSelectableSocket(hSocket);
bool fConnected = ConnectSocket(activeMasternodeInfo.service, hSocket, nConnectTimeout) && IsSelectableSocket(hSocket);
CloseSocket(hSocket);
if (!fConnected) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Could not connect to " + service.ToString();
LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
strNotCapableReason = "Could not connect to " + activeMasternodeInfo.service.ToString();
LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
}
// Default to REMOTE
eType = MASTERNODE_REMOTE;
LogPrint("masternode", "CActiveMasternode::ManageStateInitial -- End status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateInitial -- End status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled);
}
void CActiveMasternode::ManageStateRemote()
void CActiveLegacyMasternodeManager::ManageStateRemote()
{
LogPrint("masternode", "CActiveMasternode::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, pubKeyMasternode.GetID() = %s\n",
GetStatus(), GetTypeString(), fPingerEnabled, pubKeyMasternode.GetID().ToString());
LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, keyIDMasternode = %s\n",
GetStatus(), GetTypeString(), fPingerEnabled, activeMasternodeInfo.keyIDMasternode.ToString());
mnodeman.CheckMasternode(pubKeyMasternode, true);
mnodeman.CheckMasternode(activeMasternodeInfo.keyIDMasternode, true);
masternode_info_t infoMn;
if(mnodeman.GetMasternodeInfo(pubKeyMasternode, infoMn)) {
if(mnodeman.GetMasternodeInfo(activeMasternodeInfo.keyIDMasternode, infoMn)) {
if(infoMn.nProtocolVersion != PROTOCOL_VERSION) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Invalid protocol version";
LogPrintf("CActiveMasternode::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
if(service != infoMn.addr) {
if(activeMasternodeInfo.service != infoMn.addr) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Broadcasted IP doesn't match our external address. Make sure you issued a new broadcast if IP of this masternode changed recently.";
LogPrintf("CActiveMasternode::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
if(!CMasternode::IsValidStateForAutoStart(infoMn.nActiveState)) {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = strprintf("Masternode in %s state", CMasternode::StateToString(infoMn.nActiveState));
LogPrintf("CActiveMasternode::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
}
if(nState != ACTIVE_MASTERNODE_STARTED) {
LogPrintf("CActiveMasternode::ManageStateRemote -- STARTED!\n");
outpoint = infoMn.outpoint;
service = infoMn.addr;
LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- STARTED!\n");
activeMasternodeInfo.outpoint = infoMn.outpoint;
activeMasternodeInfo.service = infoMn.addr;
fPingerEnabled = true;
nState = ACTIVE_MASTERNODE_STARTED;
}
@ -245,6 +245,6 @@ void CActiveMasternode::ManageStateRemote()
else {
nState = ACTIVE_MASTERNODE_NOT_CAPABLE;
strNotCapableReason = "Masternode not in masternode list";
LogPrintf("CActiveMasternode::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
}
}

View File

@ -10,7 +10,8 @@
#include "net.h"
#include "primitives/transaction.h"
class CActiveMasternode;
struct CActiveMasternodeInfo;
class CActiveLegacyMasternodeManager;
static const int ACTIVE_MASTERNODE_INITIAL = 0; // initial state
static const int ACTIVE_MASTERNODE_SYNC_IN_PROCESS = 1;
@ -18,10 +19,21 @@ static const int ACTIVE_MASTERNODE_INPUT_TOO_NEW = 2;
static const int ACTIVE_MASTERNODE_NOT_CAPABLE = 3;
static const int ACTIVE_MASTERNODE_STARTED = 4;
extern CActiveMasternode activeMasternode;
extern CActiveMasternodeInfo activeMasternodeInfo;
extern CActiveLegacyMasternodeManager legacyActiveMasternodeManager;
struct CActiveMasternodeInfo {
// Keys for the active Masternode
CKeyID keyIDMasternode;
CKey keyMasternode;
// Initialized while registering Masternode
COutPoint outpoint;
CService service;
};
// Responsible for activating the Masternode and pinging the network
class CActiveMasternode
class CActiveLegacyMasternodeManager
{
public:
enum masternode_type_enum_t {
@ -45,25 +57,13 @@ private:
uint32_t nSentinelVersion;
public:
// Keys for the active Masternode
CPubKey pubKeyMasternode;
CKey keyMasternode;
// Initialized while registering Masternode
COutPoint outpoint;
CService service;
int nState; // should be one of ACTIVE_MASTERNODE_XXXX
std::string strNotCapableReason;
CActiveMasternode()
CActiveLegacyMasternodeManager()
: eType(MASTERNODE_UNKNOWN),
fPingerEnabled(false),
pubKeyMasternode(),
keyMasternode(),
outpoint(),
service(),
nState(ACTIVE_MASTERNODE_INITIAL)
{}

View File

@ -265,7 +265,7 @@ void CGovernanceObject::SetMasternodeOutpoint(const COutPoint& outpoint)
masternodeOutpoint = outpoint;
}
bool CGovernanceObject::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
bool CGovernanceObject::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
{
std::string strError;
@ -277,7 +277,7 @@ bool CGovernanceObject::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMas
return false;
}
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
LogPrintf("CGovernanceObject::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
@ -288,30 +288,30 @@ bool CGovernanceObject::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMas
return false;
}
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CGovernanceObject::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
}
LogPrint("gobject", "CGovernanceObject::Sign -- pubkey id = %s, masternode = %s\n",
pubKeyMasternode.GetID().ToString(), masternodeOutpoint.ToStringShort());
keyIDMasternode.ToString(), masternodeOutpoint.ToStringShort());
return true;
}
bool CGovernanceObject::CheckSignature(const CPubKey& pubKeyMasternode) const
bool CGovernanceObject::CheckSignature(const CKeyID& keyIDMasternode) const
{
std::string strError;
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
// could be an old object
std::string strMessage = GetSignatureMessage();
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
// nope, not in old format either
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
return false;
@ -320,7 +320,7 @@ bool CGovernanceObject::CheckSignature(const CPubKey& pubKeyMasternode) const
} else {
std::string strMessage = GetSignatureMessage();
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -490,7 +490,7 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
masternode_info_t infoMn;
if (!mnodeman.GetMasternodeInfo(masternodeOutpoint, infoMn)) {
CMasternode::CollateralStatus err = CMasternode::CheckCollateral(masternodeOutpoint, CPubKey());
CMasternode::CollateralStatus err = CMasternode::CheckCollateral(masternodeOutpoint, CKeyID());
if (err == CMasternode::COLLATERAL_UTXO_NOT_FOUND) {
strError = "Failed to find Masternode UTXO, missing masternode=" + strOutpoint + "\n";
} else if (err == CMasternode::COLLATERAL_INVALID_AMOUNT) {
@ -507,8 +507,8 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
}
// Check that we have a valid MN signature
if (!CheckSignature(infoMn.pubKeyMasternode)) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.pubKeyMasternode.GetID().ToString();
if (!CheckSignature(infoMn.keyIDMasternode)) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.keyIDMasternode.ToString();
return false;
}

View File

@ -251,8 +251,8 @@ public:
// Signature related functions
void SetMasternodeOutpoint(const COutPoint& outpoint);
bool Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode);
bool CheckSignature(const CPubKey& pubKeyMasternode) const;
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
bool CheckSignature(const CKeyID& keyIDMasternode) const;
std::string GetSignatureMessage() const;
uint256 GetSignatureHash() const;

View File

@ -152,7 +152,7 @@ uint256 CGovernanceVote::GetSignatureHash() const
return SerializeHash(*this);
}
bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
bool CGovernanceVote::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
{
std::string strError;
@ -164,7 +164,7 @@ bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return false;
}
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
LogPrintf("CGovernanceVote::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
@ -178,7 +178,7 @@ bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return false;
}
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CGovernanceVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -187,21 +187,21 @@ bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return true;
}
bool CGovernanceVote::CheckSignature(const CPubKey& pubKeyMasternode) const
bool CGovernanceVote::CheckSignature(const CKeyID& keyIDMasternode) const
{
std::string strError;
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
// could be a signature in old format
std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
std::to_string(nVoteSignal) + "|" +
std::to_string(nVoteOutcome) + "|" +
std::to_string(nTime);
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
// nope, not in old format either
LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
return false;
@ -213,7 +213,7 @@ bool CGovernanceVote::CheckSignature(const CPubKey& pubKeyMasternode) const
std::to_string(nVoteOutcome) + "|" +
std::to_string(nTime);
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -251,7 +251,7 @@ bool CGovernanceVote::IsValid(bool fSignatureCheck) const
if(!fSignatureCheck) return true;
return CheckSignature(infoMn.pubKeyMasternode);
return CheckSignature(infoMn.keyIDMasternode);
}
bool operator==(const CGovernanceVote& vote1, const CGovernanceVote& vote2)

View File

@ -90,8 +90,8 @@ public:
void SetSignature(const std::vector<unsigned char>& vchSigIn) { vchSig = vchSigIn; }
bool Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode);
bool CheckSignature(const CPubKey& pubKeyMasternode) const;
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
bool CheckSignature(const CKeyID& keyIDMasternode) const;
bool IsValid(bool fSignatureCheck) const;
void Relay(CConnman& connman) const;

View File

@ -1851,10 +1851,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
std::string strMasterNodePrivKey = GetArg("-masternodeprivkey", "");
if(!strMasterNodePrivKey.empty()) {
if(!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode))
CPubKey pubKeyMasternode;
if(!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, activeMasternodeInfo.keyMasternode, pubKeyMasternode))
return InitError(_("Invalid masternodeprivkey. Please see documenation."));
LogPrintf(" pubKeyMasternode: %s\n", CBitcoinAddress(activeMasternode.pubKeyMasternode.GetID()).ToString());
activeMasternodeInfo.keyIDMasternode = pubKeyMasternode.GetID();
LogPrintf(" keyIDMasternode: %s\n", CBitcoinAddress(activeMasternodeInfo.keyIDMasternode).ToString());
} else {
return InitError(_("You must specify a masternodeprivkey in the configuration. Please see documentation for help."));
}
@ -1973,7 +1976,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
scheduler.scheduleEvery(boost::bind(&CNetFulfilledRequestManager::DoMaintenance, boost::ref(netfulfilledman)), 60);
scheduler.scheduleEvery(boost::bind(&CMasternodeSync::DoMaintenance, boost::ref(masternodeSync), boost::ref(*g_connman)), MASTERNODE_SYNC_TICK_SECONDS);
scheduler.scheduleEvery(boost::bind(&CMasternodeMan::DoMaintenance, boost::ref(mnodeman), boost::ref(*g_connman)), 1);
scheduler.scheduleEvery(boost::bind(&CActiveMasternode::DoMaintenance, boost::ref(activeMasternode), boost::ref(*g_connman)), MASTERNODE_MIN_MNP_SECONDS);
scheduler.scheduleEvery(boost::bind(&CActiveLegacyMasternodeManager::DoMaintenance, boost::ref(legacyActiveMasternodeManager), boost::ref(*g_connman)), MASTERNODE_MIN_MNP_SECONDS);
scheduler.scheduleEvery(boost::bind(&CMasternodePayments::DoMaintenance, boost::ref(mnpayments)), 60);
scheduler.scheduleEvery(boost::bind(&CGovernanceManager::DoMaintenance, boost::ref(governance), boost::ref(*g_connman)), 60 * 5);

View File

@ -233,8 +233,8 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
int nRank;
int nMinRequiredProtocol = std::max(MIN_INSTANTSEND_PROTO_VERSION, mnpayments.GetMinMasternodePaymentsProto());
if(!mnodeman.GetMasternodeRank(activeMasternode.outpoint, nRank, nLockInputHeight, nMinRequiredProtocol)) {
LogPrint("instantsend", "CInstantSend::Vote -- Can't calculate rank for masternode %s\n", activeMasternode.outpoint.ToStringShort());
if(!mnodeman.GetMasternodeRank(activeMasternodeInfo.outpoint, nRank, nLockInputHeight, nMinRequiredProtocol)) {
LogPrint("instantsend", "CInstantSend::Vote -- Can't calculate rank for masternode %s\n", activeMasternodeInfo.outpoint.ToStringShort());
continue;
}
@ -254,7 +254,7 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
if(itVoted != mapVotedOutpoints.end()) {
for (const auto& hash : itVoted->second) {
std::map<uint256, CTxLockCandidate>::iterator it2 = mapTxLockCandidates.find(hash);
if(it2->second.HasMasternodeVoted(outpointLockPair.first, activeMasternode.outpoint)) {
if(it2->second.HasMasternodeVoted(outpointLockPair.first, activeMasternodeInfo.outpoint)) {
// we already voted for this outpoint to be included either in the same tx or in a competing one,
// skip it anyway
fAlreadyVoted = true;
@ -269,7 +269,7 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
}
// we haven't voted for this outpoint yet, let's try to do this now
CTxLockVote vote(txHash, outpointLockPair.first, activeMasternode.outpoint);
CTxLockVote vote(txHash, outpointLockPair.first, activeMasternodeInfo.outpoint);
if(!vote.Sign()) {
LogPrintf("CInstantSend::Vote -- Failed to sign consensus vote\n");
@ -1059,10 +1059,10 @@ bool CTxLockVote::CheckSignature() const
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, infoMn.pubKeyMasternode, vchMasternodeSignature, strError)) {
if (!CHashSigner::VerifyHash(hash, infoMn.keyIDMasternode, vchMasternodeSignature, strError)) {
// could be a signature in old format
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
if(!CMessageSigner::VerifyMessage(infoMn.pubKeyMasternode, vchMasternodeSignature, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(infoMn.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
// nope, not in old format either
LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
return false;
@ -1070,7 +1070,7 @@ bool CTxLockVote::CheckSignature() const
}
} else {
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
if(!CMessageSigner::VerifyMessage(infoMn.pubKeyMasternode, vchMasternodeSignature, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(infoMn.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -1086,24 +1086,24 @@ bool CTxLockVote::Sign()
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if(!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchMasternodeSignature)) {
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchMasternodeSignature)) {
LogPrintf("CTxLockVote::Sign -- SignHash() failed\n");
return false;
}
if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchMasternodeSignature, strError)) {
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchMasternodeSignature, strError)) {
LogPrintf("CTxLockVote::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = txHash.ToString() + outpoint.ToStringShort();
if(!CMessageSigner::SignMessage(strMessage, vchMasternodeSignature, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage, vchMasternodeSignature, activeMasternodeInfo.keyMasternode)) {
LogPrintf("CTxLockVote::Sign -- SignMessage() failed\n");
return false;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, vchMasternodeSignature, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchMasternodeSignature, strMessage, strError)) {
LogPrintf("CTxLockVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}

View File

@ -264,7 +264,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int nBlockH
return;
}
// fill payee with locally calculated winner and hope for the best
payee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID());
payee = GetScriptForDestination(mnInfo.keyIDCollateralAddress);
}
// GET MASTERNODE PAYMENT VARIABLES SETUP
@ -384,7 +384,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom
}
int nDos = 0;
if(!vote.CheckSignature(mnInfo.pubKeyMasternode, nCachedBlockHeight, nDos)) {
if(!vote.CheckSignature(mnInfo.keyIDMasternode, nCachedBlockHeight, nDos)) {
if(nDos) {
LOCK(cs_main);
LogPrintf("MASTERNODEPAYMENTVOTE -- ERROR: invalid signature\n");
@ -444,12 +444,12 @@ bool CMasternodePaymentVote::Sign()
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if(!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchSig)) {
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
LogPrintf("CMasternodePaymentVote::Sign -- SignHash() failed\n");
return false;
}
if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
LogPrintf("CMasternodePaymentVote::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
@ -458,12 +458,12 @@ bool CMasternodePaymentVote::Sign()
std::to_string(nBlockHeight) +
ScriptToAsmStr(payee);
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
LogPrintf("CMasternodePaymentVote::Sign -- SignMessage() failed\n");
return false;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePaymentVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -489,7 +489,7 @@ bool CMasternodePayments::IsScheduled(const masternode_info_t& mnInfo, int nNotB
if(!masternodeSync.IsMasternodeListSynced()) return false;
CScript mnpayee;
mnpayee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID());
mnpayee = GetScriptForDestination(mnInfo.keyIDCollateralAddress);
CScript payee;
for(int64_t h = nCachedBlockHeight; h <= nCachedBlockHeight + 8; h++){
@ -759,7 +759,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight, CConnman& connman)
int nRank;
if (!mnodeman.GetMasternodeRank(activeMasternode.outpoint, nRank, nBlockHeight - 101, GetMinMasternodePaymentsProto())) {
if (!mnodeman.GetMasternodeRank(activeMasternodeInfo.outpoint, nRank, nBlockHeight - 101, GetMinMasternodePaymentsProto())) {
LogPrint("mnpayments", "CMasternodePayments::ProcessBlock -- Unknown Masternode\n");
return false;
}
@ -772,7 +772,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight, CConnman& connman)
// LOCATE THE NEXT MASTERNODE WHICH SHOULD BE PAID
LogPrintf("CMasternodePayments::ProcessBlock -- Start: nBlockHeight=%d, masternode=%s\n", nBlockHeight, activeMasternode.outpoint.ToStringShort());
LogPrintf("CMasternodePayments::ProcessBlock -- Start: nBlockHeight=%d, masternode=%s\n", nBlockHeight, activeMasternodeInfo.outpoint.ToStringShort());
// pay to the oldest MN that still had no payment but its input is old enough and it was active long enough
int nCount = 0;
@ -786,9 +786,9 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight, CConnman& connman)
LogPrintf("CMasternodePayments::ProcessBlock -- Masternode found by GetNextMasternodeInQueueForPayment(): %s\n", mnInfo.outpoint.ToStringShort());
CScript payee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID());
CScript payee = GetScriptForDestination(mnInfo.keyIDCollateralAddress);
CMasternodePaymentVote voteNew(activeMasternode.outpoint, nBlockHeight, payee);
CMasternodePaymentVote voteNew(activeMasternodeInfo.outpoint, nBlockHeight, payee);
CTxDestination address1;
ExtractDestination(payee, address1);
@ -893,7 +893,7 @@ void CMasternodePaymentVote::Relay(CConnman& connman) const
connman.RelayInv(inv);
}
bool CMasternodePaymentVote::CheckSignature(const CPubKey& pubKeyMasternode, int nValidationHeight, int &nDos) const
bool CMasternodePaymentVote::CheckSignature(const CKeyID& keyIDMasternode, int nValidationHeight, int &nDos) const
{
// do not ban by default
nDos = 0;
@ -902,12 +902,12 @@ bool CMasternodePaymentVote::CheckSignature(const CPubKey& pubKeyMasternode, int
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
// could be a signature in old format
std::string strMessage = masternodeOutpoint.ToStringShort() +
std::to_string(nBlockHeight) +
ScriptToAsmStr(payee);
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
// nope, not in old format either
// Only ban for future block vote when we are already synced.
// Otherwise it could be the case when MN which signed this vote is using another key now
@ -924,7 +924,7 @@ bool CMasternodePaymentVote::CheckSignature(const CPubKey& pubKeyMasternode, int
std::to_string(nBlockHeight) +
ScriptToAsmStr(payee);
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
// Only ban for future block vote when we are already synced.
// Otherwise it could be the case when MN which signed this vote is using another key now
// and we have no idea about the old one.

View File

@ -159,7 +159,7 @@ public:
uint256 GetSignatureHash() const;
bool Sign();
bool CheckSignature(const CPubKey& pubKeyMasternode, int nValidationHeight, int &nDos) const;
bool CheckSignature(const CKeyID& keyIDMasternode, int nValidationHeight, int &nDos) const;
bool IsValid(CNode* pnode, int nValidationHeight, std::string& strError, CConnman& connman) const;
void Relay(CConnman& connman) const;

View File

@ -87,7 +87,7 @@ void CMasternodeSync::SwitchToNextAsset(CConnman& connman)
nRequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
uiInterface.NotifyAdditionalDataSyncProgressChanged(1);
//try to activate our masternode if possible
activeMasternode.ManageState(connman);
legacyActiveMasternodeManager.ManageState(connman);
connman.ForEachNode(CConnman::AllNodes, [](CNode* pnode) {
netfulfilledman.AddFulfilledRequest(pnode->addr, "full-sync");

View File

@ -26,9 +26,9 @@ CMasternode::CMasternode() :
fAllowMixingTx(true)
{}
CMasternode::CMasternode(CService addr, COutPoint outpoint, CPubKey pubKeyCollateralAddress, CPubKey pubKeyMasternode, int nProtocolVersionIn) :
CMasternode::CMasternode(CService addr, COutPoint outpoint, CPubKey pubKeyCollateralAddressNew, CPubKey pubKeyMasternodeNew, int nProtocolVersionIn) :
masternode_info_t{ MASTERNODE_ENABLED, nProtocolVersionIn, GetAdjustedTime(),
outpoint, addr, pubKeyCollateralAddress, pubKeyMasternode},
outpoint, addr, pubKeyCollateralAddressNew, pubKeyMasternodeNew},
fAllowMixingTx(true)
{}
@ -60,6 +60,7 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co
if(mnb.sigTime <= sigTime && !mnb.fRecovery) return false;
pubKeyMasternode = mnb.pubKeyMasternode;
keyIDMasternode = mnb.pubKeyMasternode.GetID();
sigTime = mnb.sigTime;
vchSig = mnb.vchSig;
nProtocolVersion = mnb.nProtocolVersion;
@ -73,11 +74,11 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& co
mnodeman.mapSeenMasternodePing.insert(std::make_pair(lastPing.GetHash(), lastPing));
}
// if it matches our Masternode privkey...
if(fMasternodeMode && pubKeyMasternode == activeMasternode.pubKeyMasternode) {
if(fMasternodeMode && keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
nPoSeBanScore = -MASTERNODE_POSE_BAN_MAX_SCORE;
if(nProtocolVersion == PROTOCOL_VERSION) {
// ... and PROTOCOL_VERSION, then we've been remotely activated ...
activeMasternode.ManageState(connman);
legacyActiveMasternodeManager.ManageState(connman);
} else {
// ... otherwise we need to reactivate our node, do not add it to the list and do not relay
// but also do not ban the node we get this message from
@ -101,13 +102,13 @@ arith_uint256 CMasternode::CalculateScore(const uint256& blockHash) const
return UintToArith256(ss.GetHash());
}
CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outpoint, const CPubKey& pubkey)
CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outpoint, const CKeyID& keyID)
{
int nHeight;
return CheckCollateral(outpoint, pubkey, nHeight);
return CheckCollateral(outpoint, keyID, nHeight);
}
CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outpoint, const CPubKey& pubkey, int& nHeightRet)
CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outpoint, const CKeyID& keyID, int& nHeightRet)
{
AssertLockHeld(cs_main);
@ -120,7 +121,7 @@ CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outp
return COLLATERAL_INVALID_AMOUNT;
}
if(pubkey == CPubKey() || coin.out.scriptPubKey != GetScriptForDestination(pubkey.GetID())) {
if(keyID.IsNull() || coin.out.scriptPubKey != GetScriptForDestination(keyID)) {
return COLLATERAL_INVALID_PUBKEY;
}
@ -171,7 +172,7 @@ void CMasternode::Check(bool fForce)
}
int nActiveStatePrev = nActiveState;
bool fOurMasternode = fMasternodeMode && activeMasternode.pubKeyMasternode == pubKeyMasternode;
bool fOurMasternode = fMasternodeMode && activeMasternodeInfo.keyIDMasternode == keyIDMasternode;
// masternode doesn't meet payment protocol requirements ...
bool fRequireUpdate = nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto() ||
@ -319,7 +320,7 @@ void CMasternode::UpdateLastPaid(const CBlockIndex *pindex, int nMaxBlocksToScan
const CBlockIndex *BlockReading = pindex;
CScript mnpayee = GetScriptForDestination(pubKeyCollateralAddress.GetID());
CScript mnpayee = GetScriptForDestination(keyIDCollateralAddress);
// LogPrint("mnpayments", "CMasternode::UpdateLastPaidBlock -- searching for block with payment to %s\n", outpoint.ToStringShort());
LOCK(cs_mapMasternodeBlocks);
@ -396,7 +397,7 @@ bool CMasternodeBroadcast::Create(const COutPoint& outpoint, const CService& ser
// wait for reindex and/or import to finish
if (fImporting || fReindex) return false;
LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, pubKeyMasternodeNew.GetID() = %s\n",
LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, keyIDMasternode = %s\n",
CBitcoinAddress(pubKeyCollateralAddressNew.GetID()).ToString(),
pubKeyMasternodeNew.GetID().ToString());
@ -409,7 +410,7 @@ bool CMasternodeBroadcast::Create(const COutPoint& outpoint, const CService& ser
};
CMasternodePing mnp(outpoint);
if (!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew))
if (!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew.GetID()))
return Log(strprintf("Failed to sign ping, masternode=%s", outpoint.ToStringShort()));
mnbRet = CMasternodeBroadcast(service, outpoint, pubKeyCollateralAddressNew, pubKeyMasternodeNew, PROTOCOL_VERSION);
@ -457,19 +458,19 @@ bool CMasternodeBroadcast::SimpleCheck(int& nDos)
}
CScript pubkeyScript;
pubkeyScript = GetScriptForDestination(pubKeyCollateralAddress.GetID());
pubkeyScript = GetScriptForDestination(keyIDCollateralAddress);
if(pubkeyScript.size() != 25) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- pubKeyCollateralAddress has the wrong size\n");
LogPrintf("CMasternodeBroadcast::SimpleCheck -- keyIDCollateralAddress has the wrong size\n");
nDos = 100;
return false;
}
CScript pubkeyScript2;
pubkeyScript2 = GetScriptForDestination(pubKeyMasternode.GetID());
pubkeyScript2 = GetScriptForDestination(keyIDMasternode);
if(pubkeyScript2.size() != 25) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- pubKeyMasternode has the wrong size\n");
LogPrintf("CMasternodeBroadcast::SimpleCheck -- keyIDMasternode has the wrong size\n");
nDos = 100;
return false;
}
@ -511,8 +512,8 @@ bool CMasternodeBroadcast::Update(CMasternode* pmn, int& nDos, CConnman& connman
}
// IsVnAssociatedWithPubkey is validated once in CheckOutpoint, after that they just need to match
if(pmn->pubKeyCollateralAddress != pubKeyCollateralAddress) {
LogPrintf("CMasternodeBroadcast::Update -- Got mismatched pubKeyCollateralAddress and outpoint\n");
if(pmn->keyIDCollateralAddress != keyIDCollateralAddress) {
LogPrintf("CMasternodeBroadcast::Update -- Got mismatched keyIDCollateralAddress and outpoint\n");
nDos = 33;
return false;
}
@ -523,7 +524,7 @@ bool CMasternodeBroadcast::Update(CMasternode* pmn, int& nDos, CConnman& connman
}
// if ther was no masternode broadcast recently or if it matches our Masternode privkey...
if(!pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS) || (fMasternodeMode && pubKeyMasternode == activeMasternode.pubKeyMasternode)) {
if(!pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS) || (fMasternodeMode && keyIDMasternode == activeMasternodeInfo.keyIDMasternode)) {
// take the newest entry
LogPrintf("CMasternodeBroadcast::Update -- Got UPDATED Masternode entry: addr=%s\n", addr.ToString());
if(pmn->UpdateFromNewBroadcast(*this, connman)) {
@ -540,14 +541,14 @@ bool CMasternodeBroadcast::CheckOutpoint(int& nDos)
{
// we are a masternode with the same outpoint (i.e. already activated) and this mnb is ours (matches our Masternode privkey)
// so nothing to do here for us
if(fMasternodeMode && outpoint == activeMasternode.outpoint && pubKeyMasternode == activeMasternode.pubKeyMasternode) {
if(fMasternodeMode && outpoint == activeMasternodeInfo.outpoint && keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
return false;
}
AssertLockHeld(cs_main);
int nHeight;
CollateralStatus err = CheckCollateral(outpoint, pubKeyCollateralAddress, nHeight);
CollateralStatus err = CheckCollateral(outpoint, keyIDCollateralAddress, nHeight);
if (err == COLLATERAL_UTXO_NOT_FOUND) {
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Failed to find Masternode UTXO, masternode=%s\n", outpoint.ToStringShort());
return false;
@ -560,7 +561,7 @@ bool CMasternodeBroadcast::CheckOutpoint(int& nDos)
}
if(err == COLLATERAL_INVALID_PUBKEY) {
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO should match pubKeyCollateralAddress, masternode=%s\n", outpoint.ToStringShort());
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO should match keyIDCollateralAddress, masternode=%s\n", outpoint.ToStringShort());
nDos = 33;
return false;
}
@ -635,13 +636,13 @@ bool CMasternodeBroadcast::Sign(const CKey& keyCollateralAddress)
return false;
}
if (!CHashSigner::VerifyHash(hash, pubKeyCollateralAddress, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDCollateralAddress, vchSig, strError)) {
LogPrintf("CMasternodeBroadcast::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
std::to_string(nProtocolVersion);
if (!CMessageSigner::SignMessage(strMessage, vchSig, keyCollateralAddress)) {
@ -649,7 +650,7 @@ bool CMasternodeBroadcast::Sign(const CKey& keyCollateralAddress)
return false;
}
if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDCollateralAddress, vchSig, strMessage, strError)) {
LogPrintf("CMasternodeBroadcast::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -666,13 +667,13 @@ bool CMasternodeBroadcast::CheckSignature(int& nDos) const
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyCollateralAddress, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDCollateralAddress, vchSig, strError)) {
// maybe it's in old format
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
std::to_string(nProtocolVersion);
if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)){
if (!CMessageSigner::VerifyMessage(keyIDCollateralAddress, vchSig, strMessage, strError)){
// nope, not in old format either
LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, error: %s\n", strError);
nDos = 100;
@ -681,10 +682,10 @@ bool CMasternodeBroadcast::CheckSignature(int& nDos) const
}
} else {
std::string strMessage = addr.ToString(false) + std::to_string(sigTime) +
pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
keyIDCollateralAddress.ToString() + keyIDMasternode.ToString() +
std::to_string(nProtocolVersion);
if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)){
if(!CMessageSigner::VerifyMessage(keyIDCollateralAddress, vchSig, strMessage, strError)){
LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, error: %s\n", strError);
nDos = 100;
return false;
@ -742,7 +743,7 @@ CMasternodePing::CMasternodePing(const COutPoint& outpoint)
nDaemonVersion = CLIENT_VERSION;
}
bool CMasternodePing::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
bool CMasternodePing::Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode)
{
std::string strError;
@ -756,7 +757,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return false;
}
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
LogPrintf("CMasternodePing::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
@ -769,7 +770,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return false;
}
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePing::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -778,7 +779,7 @@ bool CMasternodePing::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMaste
return true;
}
bool CMasternodePing::CheckSignature(const CPubKey& pubKeyMasternode, int &nDos) const
bool CMasternodePing::CheckSignature(CKeyID& keyIDMasternode, int &nDos) const
{
std::string strError = "";
nDos = 0;
@ -786,11 +787,11 @@ bool CMasternodePing::CheckSignature(const CPubKey& pubKeyMasternode, int &nDos)
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
std::to_string(sigTime);
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
nDos = 33;
return false;
@ -800,7 +801,7 @@ bool CMasternodePing::CheckSignature(const CPubKey& pubKeyMasternode, int &nDos)
std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
std::to_string(sigTime);
if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if (!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
nDos = 33;
return false;
@ -884,7 +885,7 @@ bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, i
return false;
}
if (!CheckSignature(pmn->pubKeyMasternode, nDos)) return false;
if (!CheckSignature(pmn->keyIDMasternode, nDos)) return false;
// so, ping seems to be ok

View File

@ -95,8 +95,8 @@ public:
bool IsExpired() const { return GetAdjustedTime() - sigTime > MASTERNODE_NEW_START_REQUIRED_SECONDS; }
bool Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode);
bool CheckSignature(const CPubKey& pubKeyMasternode, int &nDos) const;
bool Sign(const CKey& keyMasternode, const CKeyID& keyIDMasternode);
bool CheckSignature(CKeyID& keyIDMasternode, int &nDos) const;
bool SimpleCheck(int& nDos);
bool CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos, CConnman& connman);
void Relay(CConnman& connman);
@ -130,12 +130,21 @@ struct masternode_info_t
masternode_info_t(int activeState, int protoVer, int64_t sTime) :
nActiveState{activeState}, nProtocolVersion{protoVer}, sigTime{sTime} {}
// only called when the network is in legacy MN list mode
masternode_info_t(int activeState, int protoVer, int64_t sTime,
COutPoint const& outpnt, CService const& addr,
CPubKey const& pkCollAddr, CPubKey const& pkMN) :
nActiveState{activeState}, nProtocolVersion{protoVer}, sigTime{sTime},
outpoint{outpnt}, addr{addr},
pubKeyCollateralAddress{pkCollAddr}, pubKeyMasternode{pkMN} {}
pubKeyCollateralAddress{pkCollAddr}, pubKeyMasternode{pkMN}, keyIDCollateralAddress{pkCollAddr.GetID()}, keyIDMasternode{pkMN.GetID()} {}
// only called when the network is in deterministic MN list mode
masternode_info_t(int activeState, int protoVer, int64_t sTime,
COutPoint const& outpnt, CService const& addr,
CKeyID const& pkCollAddr, CKeyID const& pkMN) :
nActiveState{activeState}, nProtocolVersion{protoVer}, sigTime{sTime},
outpoint{outpnt}, addr{addr},
pubKeyCollateralAddress{}, pubKeyMasternode{}, keyIDCollateralAddress{pkCollAddr}, keyIDMasternode{pkMN} {}
int nActiveState = 0;
int nProtocolVersion = 0;
@ -143,8 +152,10 @@ struct masternode_info_t
COutPoint outpoint{};
CService addr{};
CPubKey pubKeyCollateralAddress{};
CPubKey pubKeyMasternode{};
CPubKey pubKeyCollateralAddress{}; // this will be invalid/unset when the network switches to deterministic MNs (luckely it's only important for the broadcast hash)
CPubKey pubKeyMasternode{}; // this will be invalid/unset when the network switches to deterministic MNs (luckely it's only important for the broadcast hash)
CKeyID keyIDCollateralAddress{};
CKeyID keyIDMasternode{};
int64_t nLastDsq = 0; //the dsq count from the last dsq broadcast of this node
int64_t nTimeLastChecked = 0;
@ -224,6 +235,8 @@ public:
READWRITE(addr);
READWRITE(pubKeyCollateralAddress);
READWRITE(pubKeyMasternode);
READWRITE(keyIDCollateralAddress);
READWRITE(keyIDMasternode);
READWRITE(lastPing);
READWRITE(vchSig);
READWRITE(sigTime);
@ -246,8 +259,8 @@ public:
bool UpdateFromNewBroadcast(CMasternodeBroadcast& mnb, CConnman& connman);
static CollateralStatus CheckCollateral(const COutPoint& outpoint, const CPubKey& pubkey);
static CollateralStatus CheckCollateral(const COutPoint& outpoint, const CPubKey& pubkey, int& nHeightRet);
static CollateralStatus CheckCollateral(const COutPoint& outpoint, const CKeyID& keyID);
static CollateralStatus CheckCollateral(const COutPoint& outpoint, const CKeyID& keyID, int& nHeightRet);
void Check(bool fForce = false);
bool IsBroadcastedWithin(int nSeconds) { return GetAdjustedTime() - sigTime < nSeconds; }
@ -389,6 +402,11 @@ public:
if (!(s.GetType() & SER_GETHASH)) {
READWRITE(lastPing);
}
if (ser_action.ForRead()) {
keyIDCollateralAddress = pubKeyCollateralAddress.GetID();
keyIDMasternode = pubKeyMasternode.GetID();
}
}
uint256 GetHash() const;

View File

@ -25,7 +25,7 @@
/** Masternode manager */
CMasternodeMan mnodeman;
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-8";
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-9";
const int CMasternodeMan::LAST_PAID_SCAN_BLOCKS = 100;
struct CompareLastPaidBlock
@ -471,11 +471,10 @@ bool CMasternodeMan::GetMasternodeInfo(const COutPoint& outpoint, masternode_inf
return true;
}
bool CMasternodeMan::GetMasternodeInfo(const CPubKey& pubKeyMasternode, masternode_info_t& mnInfoRet)
{
bool CMasternodeMan::GetMasternodeInfo(const CKeyID& keyIDMasternode, masternode_info_t& mnInfoRet) {
LOCK(cs);
for (const auto& mnpair : mapMasternodes) {
if (mnpair.second.pubKeyMasternode == pubKeyMasternode) {
if (mnpair.second.keyIDMasternode == keyIDMasternode) {
mnInfoRet = mnpair.second.GetInfo();
return true;
}
@ -483,17 +482,18 @@ bool CMasternodeMan::GetMasternodeInfo(const CPubKey& pubKeyMasternode, masterno
return false;
}
bool CMasternodeMan::GetMasternodeInfo(const CPubKey& pubKeyMasternode, masternode_info_t& mnInfoRet)
{
return GetMasternodeInfo(pubKeyMasternode.GetID(), mnInfoRet);
}
bool CMasternodeMan::GetMasternodeInfo(const CScript& payee, masternode_info_t& mnInfoRet)
{
LOCK(cs);
for (const auto& mnpair : mapMasternodes) {
CScript scriptCollateralAddress = GetScriptForDestination(mnpair.second.pubKeyCollateralAddress.GetID());
if (scriptCollateralAddress == payee) {
mnInfoRet = mnpair.second.GetInfo();
return true;
}
}
return false;
CTxDestination dest;
if (!ExtractDestination(payee, dest) || !boost::get<CKeyID>(&dest))
return false;
CKeyID keyId = *boost::get<CKeyID>(&dest);
return GetMasternodeInfo(keyId, mnInfoRet);
}
bool CMasternodeMan::Has(const COutPoint& outpoint)
@ -994,7 +994,7 @@ void CMasternodeMan::PushDsegInvs(CNode* pnode, const CMasternode& mn)
void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
{
if(activeMasternode.outpoint.IsNull()) return;
if(activeMasternodeInfo.outpoint.IsNull()) return;
if(!masternodeSync.IsSynced()) return;
rank_pair_vec_t vecMasternodeRanks;
@ -1014,7 +1014,7 @@ void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
(int)MAX_POSE_RANK);
return;
}
if(rankPair.second.outpoint == activeMasternode.outpoint) {
if(rankPair.second.outpoint == activeMasternodeInfo.outpoint) {
nMyRank = rankPair.first;
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Found self at rank %d/%d, verifying up to %d masternodes\n",
nMyRank, nRanksTotal, (int)MAX_POSE_CONNECTIONS);
@ -1199,24 +1199,24 @@ void CMasternodeMan::SendVerifyReply(CNode* pnode, CMasternodeVerification& mnv,
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = mnv.GetSignatureHash1(blockHash);
if(!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, mnv.vchSig1)) {
if(!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, mnv.vchSig1)) {
LogPrintf("CMasternodeMan::SendVerifyReply -- SignHash() failed\n");
return;
}
if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, mnv.vchSig1, strError)) {
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, mnv.vchSig1, strError)) {
LogPrintf("CMasternodeMan::SendVerifyReply -- VerifyHash() failed, error: %s\n", strError);
return;
}
} else {
std::string strMessage = strprintf("%s%d%s", activeMasternode.service.ToString(false), mnv.nonce, blockHash.ToString());
std::string strMessage = strprintf("%s%d%s", activeMasternodeInfo.service.ToString(false), mnv.nonce, blockHash.ToString());
if(!CMessageSigner::SignMessage(strMessage, mnv.vchSig1, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage, mnv.vchSig1, activeMasternodeInfo.keyMasternode)) {
LogPrintf("MasternodeMan::SendVerifyReply -- SignMessage() failed\n");
return;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, mnv.vchSig1, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, mnv.vchSig1, strMessage, strError)) {
LogPrintf("MasternodeMan::SendVerifyReply -- VerifyMessage() failed, error: %s\n", strError);
return;
}
@ -1283,10 +1283,10 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
if(CAddress(mnpair.second.addr, NODE_NETWORK) == pnode->addr) {
bool fFound = false;
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
fFound = CHashSigner::VerifyHash(hash1, mnpair.second.pubKeyMasternode, mnv.vchSig1, strError);
fFound = CHashSigner::VerifyHash(hash1, mnpair.second.keyIDMasternode, mnv.vchSig1, strError);
// we don't care about mnv with signature in old format
} else {
fFound = CMessageSigner::VerifyMessage(mnpair.second.pubKeyMasternode, mnv.vchSig1, strMessage1, strError);
fFound = CMessageSigner::VerifyMessage(mnpair.second.keyIDMasternode, mnv.vchSig1, strMessage1, strError);
}
if (fFound) {
// found it!
@ -1297,23 +1297,23 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
netfulfilledman.AddFulfilledRequest(pnode->addr, strprintf("%s", NetMsgType::MNVERIFY)+"-done");
// we can only broadcast it if we are an activated masternode
if(activeMasternode.outpoint.IsNull()) continue;
if(activeMasternodeInfo.outpoint.IsNull()) continue;
// update ...
mnv.addr = mnpair.second.addr;
mnv.masternodeOutpoint1 = mnpair.second.outpoint;
mnv.masternodeOutpoint2 = activeMasternode.outpoint;
mnv.masternodeOutpoint2 = activeMasternodeInfo.outpoint;
// ... and sign it
std::string strError;
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash2 = mnv.GetSignatureHash2(blockHash);
if(!CHashSigner::SignHash(hash2, activeMasternode.keyMasternode, mnv.vchSig2)) {
if(!CHashSigner::SignHash(hash2, activeMasternodeInfo.keyMasternode, mnv.vchSig2)) {
LogPrintf("MasternodeMan::ProcessVerifyReply -- SignHash() failed\n");
return;
}
if(!CHashSigner::VerifyHash(hash2, activeMasternode.pubKeyMasternode, mnv.vchSig2, strError)) {
if(!CHashSigner::VerifyHash(hash2, activeMasternodeInfo.keyIDMasternode, mnv.vchSig2, strError)) {
LogPrintf("MasternodeMan::ProcessVerifyReply -- VerifyHash() failed, error: %s\n", strError);
return;
}
@ -1321,12 +1321,12 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
std::string strMessage2 = strprintf("%s%d%s%s%s", mnv.addr.ToString(false), mnv.nonce, blockHash.ToString(),
mnv.masternodeOutpoint1.ToStringShort(), mnv.masternodeOutpoint2.ToStringShort());
if(!CMessageSigner::SignMessage(strMessage2, mnv.vchSig2, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage2, mnv.vchSig2, activeMasternodeInfo.keyMasternode)) {
LogPrintf("MasternodeMan::ProcessVerifyReply -- SignMessage() failed\n");
return;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, mnv.vchSig2, strMessage2, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, mnv.vchSig2, strMessage2, strError)) {
LogPrintf("MasternodeMan::ProcessVerifyReply -- VerifyMessage() failed, error: %s\n", strError);
return;
}
@ -1436,12 +1436,12 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
uint256 hash1 = mnv.GetSignatureHash1(blockHash);
uint256 hash2 = mnv.GetSignatureHash2(blockHash);
if(!CHashSigner::VerifyHash(hash1, pmn1->pubKeyMasternode, mnv.vchSig1, strError)) {
if(!CHashSigner::VerifyHash(hash1, pmn1->keyIDMasternode, mnv.vchSig1, strError)) {
LogPrintf("MasternodeMan::ProcessVerifyBroadcast -- VerifyHash() failed, error: %s\n", strError);
return;
}
if(!CHashSigner::VerifyHash(hash2, pmn2->pubKeyMasternode, mnv.vchSig2, strError)) {
if(!CHashSigner::VerifyHash(hash2, pmn2->keyIDMasternode, mnv.vchSig2, strError)) {
LogPrintf("MasternodeMan::ProcessVerifyBroadcast -- VerifyHash() failed, error: %s\n", strError);
return;
}
@ -1450,12 +1450,12 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
std::string strMessage2 = strprintf("%s%d%s%s%s", mnv.addr.ToString(false), mnv.nonce, blockHash.ToString(),
mnv.masternodeOutpoint1.ToStringShort(), mnv.masternodeOutpoint2.ToStringShort());
if(!CMessageSigner::VerifyMessage(pmn1->pubKeyMasternode, mnv.vchSig1, strMessage1, strError)) {
if(!CMessageSigner::VerifyMessage(pmn1->keyIDMasternode, mnv.vchSig1, strMessage1, strError)) {
LogPrintf("CMasternodeMan::ProcessVerifyBroadcast -- VerifyMessage() for masternode1 failed, error: %s\n", strError);
return;
}
if(!CMessageSigner::VerifyMessage(pmn2->pubKeyMasternode, mnv.vchSig2, strMessage2, strError)) {
if(!CMessageSigner::VerifyMessage(pmn2->keyIDMasternode, mnv.vchSig2, strMessage2, strError)) {
LogPrintf("CMasternodeMan::ProcessVerifyBroadcast -- VerifyMessage() for masternode2 failed, error: %s\n", strError);
return;
}
@ -1567,13 +1567,13 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBr
Add(mnb);
masternodeSync.BumpAssetLastTime("CMasternodeMan::CheckMnbAndUpdateMasternodeList - new");
// if it matches our Masternode privkey...
if(fMasternodeMode && mnb.pubKeyMasternode == activeMasternode.pubKeyMasternode) {
if(fMasternodeMode && mnb.keyIDMasternode == activeMasternodeInfo.keyIDMasternode) {
mnb.nPoSeBanScore = -MASTERNODE_POSE_BAN_MAX_SCORE;
if(mnb.nProtocolVersion == PROTOCOL_VERSION) {
// ... and PROTOCOL_VERSION, then we've been remotely activated ...
LogPrintf("CMasternodeMan::CheckMnbAndUpdateMasternodeList -- Got NEW Masternode entry: masternode=%s sigTime=%lld addr=%s\n",
mnb.outpoint.ToStringShort(), mnb.sigTime, mnb.addr.ToString());
activeMasternode.ManageState(connman);
legacyActiveMasternodeManager.ManageState(connman);
} else {
// ... otherwise we need to reactivate our node, do not add it to the list and do not relay
// but also do not ban the node we get this message from
@ -1643,11 +1643,11 @@ void CMasternodeMan::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
}
}
void CMasternodeMan::CheckMasternode(const CPubKey& pubKeyMasternode, bool fForce)
void CMasternodeMan::CheckMasternode(const CKeyID& keyIDMasternode, bool fForce)
{
LOCK2(cs_main, cs);
for (auto& mnpair : mapMasternodes) {
if (mnpair.second.pubKeyMasternode == pubKeyMasternode) {
if (mnpair.second.keyIDMasternode == keyIDMasternode) {
mnpair.second.Check(fForce);
return;
}

View File

@ -169,6 +169,7 @@ public:
bool Has(const COutPoint& outpoint);
bool GetMasternodeInfo(const COutPoint& outpoint, masternode_info_t& mnInfoRet);
bool GetMasternodeInfo(const CKeyID& keyIDMasternode, masternode_info_t& mnInfoRet);
bool GetMasternodeInfo(const CPubKey& pubKeyMasternode, masternode_info_t& mnInfoRet);
bool GetMasternodeInfo(const CScript& payee, masternode_info_t& mnInfoRet);
@ -229,7 +230,7 @@ public:
bool AddGovernanceVote(const COutPoint& outpoint, uint256 nGovernanceObjectHash);
void RemoveGovernanceObject(uint256 nGovernanceObjectHash);
void CheckMasternode(const CPubKey& pubKeyMasternode, bool fForce);
void CheckMasternode(const CKeyID& keyIDMasternode, bool fForce);
bool IsMasternodePingedWithin(const COutPoint& outpoint, int nSeconds, int64_t nTimeToCheckAt = -1);
void SetMasternodeLastPing(const COutPoint& outpoint, const CMasternodePing& mnp);

View File

@ -1973,7 +1973,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
// we have no idea about (e.g we were offline)? How to handle them?
}
if(!dstx.CheckSignature(mn.pubKeyMasternode)) {
if(!dstx.CheckSignature(mn.keyIDMasternode)) {
LogPrint("privatesend", "DSTX -- CheckSignature() failed for %s\n", hashTx.ToString());
return false;
}

View File

@ -56,7 +56,7 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm
masternode_info_t infoMn;
if(!mnodeman.GetMasternodeInfo(dsq.masternodeOutpoint, infoMn)) return;
if(!dsq.CheckSignature(infoMn.pubKeyMasternode)) {
if(!dsq.CheckSignature(infoMn.keyIDMasternode)) {
// we probably have outdated info
mnodeman.AskForMN(pfrom, dsq.masternodeOutpoint, connman);
return;

View File

@ -48,7 +48,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
if(dsa.nInputCount < 0 || dsa.nInputCount > PRIVATESEND_ENTRY_MAX_SIZE) return;
masternode_info_t mnInfo;
if(!mnodeman.GetMasternodeInfo(activeMasternode.outpoint, mnInfo)) {
if(!mnodeman.GetMasternodeInfo(activeMasternodeInfo.outpoint, mnInfo)) {
PushStatus(pfrom, STATUS_REJECTED, ERR_MN_LIST, connman);
return;
}
@ -105,7 +105,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
masternode_info_t mnInfo;
if(!mnodeman.GetMasternodeInfo(dsq.masternodeOutpoint, mnInfo)) return;
if(!dsq.CheckSignature(mnInfo.pubKeyMasternode)) {
if(!dsq.CheckSignature(mnInfo.keyIDMasternode)) {
// we probably have outdated info
mnodeman.AskForMN(pfrom, dsq.masternodeOutpoint, connman);
return;
@ -363,7 +363,7 @@ void CPrivateSendServer::CommitFinalTransaction(CConnman& connman)
// create and sign masternode dstx transaction
if(!CPrivateSend::GetDSTX(hashTx)) {
CDarksendBroadcastTx dstxNew(finalTransaction, activeMasternode.outpoint, GetAdjustedTime());
CDarksendBroadcastTx dstxNew(finalTransaction, activeMasternodeInfo.outpoint, GetAdjustedTime());
dstxNew.Sign();
CPrivateSend::AddDSTX(dstxNew);
}
@ -524,7 +524,7 @@ void CPrivateSendServer::CheckForCompleteQueue(CConnman& connman)
if(nState == POOL_STATE_QUEUE && IsSessionReady()) {
SetState(POOL_STATE_ACCEPTING_ENTRIES);
CDarksendQueue dsq(nSessionDenom, nSessionInputCount, activeMasternode.outpoint, GetAdjustedTime(), true);
CDarksendQueue dsq(nSessionDenom, nSessionInputCount, activeMasternodeInfo.outpoint, GetAdjustedTime(), true);
LogPrint("privatesend", "CPrivateSendServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s)\n", dsq.ToString());
dsq.Sign();
dsq.Relay(connman);
@ -739,7 +739,7 @@ bool CPrivateSendServer::CreateNewSession(const CDarksendAccept& dsa, PoolMessag
if(!fUnitTest) {
//broadcast that I'm accepting entries, only if it's the first entry through
CDarksendQueue dsq(dsa.nDenom, dsa.nInputCount, activeMasternode.outpoint, GetAdjustedTime(), false);
CDarksendQueue dsq(dsa.nDenom, dsa.nInputCount, activeMasternodeInfo.outpoint, GetAdjustedTime(), false);
LogPrint("privatesend", "CPrivateSendServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString());
dsq.Sign();
dsq.Relay(connman);

View File

@ -47,12 +47,12 @@ bool CDarksendQueue::Sign()
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchSig)) {
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
LogPrintf("CDarksendQueue::Sign -- SignHash() failed\n");
return false;
}
if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
LogPrintf("CDarksendQueue::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
@ -62,12 +62,12 @@ bool CDarksendQueue::Sign()
std::to_string(nTime) +
std::to_string(fReady);
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
LogPrintf("CDarksendQueue::Sign -- SignMessage() failed, %s\n", ToString());
return false;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CDarksendQueue::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -76,14 +76,14 @@ bool CDarksendQueue::Sign()
return true;
}
bool CDarksendQueue::CheckSignature(const CPubKey& pubKeyMasternode) const
bool CDarksendQueue::CheckSignature(const CKeyID& keyIDMasternode) const
{
std::string strError = "";
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
// we don't care about queues with old signature format
LogPrintf("CDarksendQueue::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
return false;
@ -94,7 +94,7 @@ bool CDarksendQueue::CheckSignature(const CPubKey& pubKeyMasternode) const
std::to_string(nTime) +
std::to_string(fReady);
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CDarksendQueue::CheckSignature -- Got bad Masternode queue signature: %s; error: %s\n", ToString(), strError);
return false;
}
@ -127,24 +127,24 @@ bool CDarksendBroadcastTx::Sign()
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchSig)) {
if (!CHashSigner::SignHash(hash, activeMasternodeInfo.keyMasternode, vchSig)) {
LogPrintf("CDarksendBroadcastTx::Sign -- SignHash() failed\n");
return false;
}
if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.keyIDMasternode, vchSig, strError)) {
LogPrintf("CDarksendBroadcastTx::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) {
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.keyMasternode)) {
LogPrintf("CDarksendBroadcastTx::Sign -- SignMessage() failed\n");
return false;
}
if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(activeMasternodeInfo.keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CDarksendBroadcastTx::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -153,14 +153,14 @@ bool CDarksendBroadcastTx::Sign()
return true;
}
bool CDarksendBroadcastTx::CheckSignature(const CPubKey& pubKeyMasternode) const
bool CDarksendBroadcastTx::CheckSignature(const CKeyID& keyIDMasternode) const
{
std::string strError = "";
if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();
if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
if (!CHashSigner::VerifyHash(hash, keyIDMasternode, vchSig, strError)) {
// we don't care about dstxes with old signature format
LogPrintf("CDarksendBroadcastTx::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
return false;
@ -168,7 +168,7 @@ bool CDarksendBroadcastTx::CheckSignature(const CPubKey& pubKeyMasternode) const
} else {
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
if(!CMessageSigner::VerifyMessage(keyIDMasternode, vchSig, strMessage, strError)) {
LogPrintf("CDarksendBroadcastTx::CheckSignature -- Got bad dstx signature, error: %s\n", strError);
return false;
}

View File

@ -249,7 +249,7 @@ public:
*/
bool Sign();
/// Check if we have a valid Masternode address
bool CheckSignature(const CPubKey& pubKeyMasternode) const;
bool CheckSignature(const CKeyID& keyIDMasternode) const;
bool Relay(CConnman &connman);
@ -341,7 +341,7 @@ public:
uint256 GetSignatureHash() const;
bool Sign();
bool CheckSignature(const CPubKey& pubKeyMasternode) const;
bool CheckSignature(const CKeyID& keyIDMasternode) const;
void SetConfirmedHeight(int nConfirmedHeightIn) { nConfirmedHeight = nConfirmedHeightIn; }
bool IsExpired(int nHeight);

View File

@ -215,7 +215,7 @@ void MasternodeList::updateMyMasternodeInfo(QString strAlias, QString strAddr, c
QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(QString::fromStdString(DurationToDHMS(fFound ? (infoMn.nTimeLastPing - infoMn.sigTime) : 0)));
QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat("%Y-%m-%d %H:%M",
fFound ? infoMn.nTimeLastPing + GetOffsetFromUtc() : 0)));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(fFound ? CBitcoinAddress(infoMn.pubKeyCollateralAddress.GetID()).ToString() : ""));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(fFound ? CBitcoinAddress(infoMn.keyIDCollateralAddress).ToString() : ""));
ui->tableWidgetMyMasternodes->setItem(nNewRow, 0, aliasItem);
ui->tableWidgetMyMasternodes->setItem(nNewRow, 1, addrItem);
@ -302,7 +302,7 @@ void MasternodeList::updateNodeList()
QTableWidgetItem *statusItem = new QTableWidgetItem(QString::fromStdString(mn.GetStatus()));
QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(QString::fromStdString(DurationToDHMS(mn.lastPing.sigTime - mn.sigTime)));
QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat("%Y-%m-%d %H:%M", mn.lastPing.sigTime + offsetFromUtc)));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(CBitcoinAddress(mn.keyIDCollateralAddress).ToString()));
if (strCurrentFilter != "")
{

View File

@ -223,10 +223,10 @@ UniValue gobject(const JSONRPCRequest& request)
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so.");
}
bool fMnFound = mnodeman.Has(activeMasternode.outpoint);
bool fMnFound = mnodeman.Has(activeMasternodeInfo.outpoint);
DBG( std::cout << "gobject: submit activeMasternode.pubKeyMasternode = " << activeMasternode.pubKeyMasternode.GetHash().ToString()
<< ", outpoint = " << activeMasternode.outpoint.ToStringShort()
DBG( std::cout << "gobject: submit activeMasternodeInfo.keyIDMasternode = " << activeMasternodeInfo.keyIDMasternode.ToString()
<< ", outpoint = " << activeMasternodeInfo.outpoint.ToStringShort()
<< ", params.size() = " << request.params.size()
<< ", fMnFound = " << fMnFound << std::endl; );
@ -274,8 +274,8 @@ UniValue gobject(const JSONRPCRequest& request)
// Attempt to sign triggers if we are a MN
if(govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) {
if(fMnFound) {
govobj.SetMasternodeOutpoint(activeMasternode.outpoint);
govobj.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode);
govobj.SetMasternodeOutpoint(activeMasternodeInfo.outpoint);
govobj.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode);
}
else {
LogPrintf("gobject(submit) -- Object submission rejected because node is not a masternode\n");
@ -357,7 +357,7 @@ UniValue gobject(const JSONRPCRequest& request)
UniValue returnObj(UniValue::VOBJ);
CMasternode mn;
bool fMnFound = mnodeman.Get(activeMasternode.outpoint, mn);
bool fMnFound = mnodeman.Get(activeMasternodeInfo.outpoint, mn);
if(!fMnFound) {
nFailed++;
@ -370,7 +370,7 @@ UniValue gobject(const JSONRPCRequest& request)
}
CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) {
if(!vote.Sign(activeMasternodeInfo.keyMasternode, activeMasternodeInfo.keyIDMasternode)) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
@ -443,8 +443,6 @@ UniValue gobject(const JSONRPCRequest& request)
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
@ -480,7 +478,7 @@ UniValue gobject(const JSONRPCRequest& request)
}
CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(keyMasternode, pubKeyMasternode)){
if(!vote.Sign(keyMasternode, pubKeyMasternode.GetID())){
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));

View File

@ -253,7 +253,7 @@ UniValue masternode(const JSONRPCRequest& request)
obj.push_back(Pair("IP:port", mnInfo.addr.ToString()));
obj.push_back(Pair("protocol", mnInfo.nProtocolVersion));
obj.push_back(Pair("outpoint", mnInfo.outpoint.ToStringShort()));
obj.push_back(Pair("payee", CBitcoinAddress(mnInfo.pubKeyCollateralAddress.GetID()).ToString()));
obj.push_back(Pair("payee", CBitcoinAddress(mnInfo.keyIDCollateralAddress).ToString()));
obj.push_back(Pair("lastseen", mnInfo.nTimeLastPing));
obj.push_back(Pair("activeseconds", mnInfo.nTimeLastPing - mnInfo.sigTime));
return obj;
@ -430,15 +430,15 @@ UniValue masternode(const JSONRPCRequest& request)
UniValue mnObj(UniValue::VOBJ);
mnObj.push_back(Pair("outpoint", activeMasternode.outpoint.ToStringShort()));
mnObj.push_back(Pair("service", activeMasternode.service.ToString()));
mnObj.push_back(Pair("outpoint", activeMasternodeInfo.outpoint.ToStringShort()));
mnObj.push_back(Pair("service", activeMasternodeInfo.service.ToString()));
CMasternode mn;
if(mnodeman.Get(activeMasternode.outpoint, mn)) {
mnObj.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
if(mnodeman.Get(activeMasternodeInfo.outpoint, mn)) {
mnObj.push_back(Pair("payee", CBitcoinAddress(mn.keyIDCollateralAddress).ToString()));
}
mnObj.push_back(Pair("status", activeMasternode.GetStatus()));
mnObj.push_back(Pair("status", legacyActiveMasternodeManager.GetStatus()));
return mnObj;
}
@ -538,7 +538,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
" payee - Print Dash address associated with a masternode (can be additionally filtered,\n"
" partial match)\n"
" protocol - Print protocol of a masternode (can be additionally filtered, exact match)\n"
" pubkey - Print the masternode (not collateral) public key\n"
" keyid - Print the masternode (not collateral) key id\n"
" rank - Print rank of a masternode based on current block\n"
" sentinel - Print sentinel version of a masternode (can be additionally filtered, exact match)\n"
" status - Print masternode status: PRE_ENABLED / ENABLED / EXPIRED / SENTINEL_PING_EXPIRED / NEW_START_REQUIRED /\n"
@ -592,7 +592,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
streamFull << std::setw(18) <<
mn.GetStatus() << " " <<
mn.nProtocolVersion << " " <<
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
CBitcoinAddress(mn.keyIDCollateralAddress).ToString() << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " << std::setw(10) <<
mn.GetLastPaidTime() << " " << std::setw(6) <<
@ -607,7 +607,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
streamInfo << std::setw(18) <<
mn.GetStatus() << " " <<
mn.nProtocolVersion << " " <<
CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString() << " " <<
CBitcoinAddress(mn.keyIDCollateralAddress).ToString() << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " <<
mn.lastPing.GetSentinelString() << " " <<
@ -656,7 +656,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, (int64_t)mn.lastPing.sigTime));
} else if (strMode == "payee") {
CBitcoinAddress address(mn.pubKeyCollateralAddress.GetID());
CBitcoinAddress address(mn.keyIDCollateralAddress);
std::string strPayee = address.ToString();
if (strFilter !="" && strPayee.find(strFilter) == std::string::npos &&
strOutpoint.find(strFilter) == std::string::npos) continue;
@ -665,9 +665,9 @@ UniValue masternodelist(const JSONRPCRequest& request)
if (strFilter !="" && strFilter != strprintf("%d", mn.nProtocolVersion) &&
strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, mn.nProtocolVersion));
} else if (strMode == "pubkey") {
} else if (strMode == "keyid") {
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strOutpoint, HexStr(mn.pubKeyMasternode)));
obj.push_back(Pair(strOutpoint, HexStr(mn.keyIDMasternode)));
} else if (strMode == "status") {
std::string strStatus = mn.GetStatus();
if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
@ -852,8 +852,8 @@ UniValue masternodebroadcast(const JSONRPCRequest& request)
nSuccessful++;
resultObj.push_back(Pair("outpoint", mnb.outpoint.ToStringShort()));
resultObj.push_back(Pair("addr", mnb.addr.ToString()));
resultObj.push_back(Pair("pubKeyCollateralAddress", CBitcoinAddress(mnb.pubKeyCollateralAddress.GetID()).ToString()));
resultObj.push_back(Pair("pubKeyMasternode", CBitcoinAddress(mnb.pubKeyMasternode.GetID()).ToString()));
resultObj.push_back(Pair("keyIDCollateralAddress", CBitcoinAddress(mnb.keyIDCollateralAddress).ToString()));
resultObj.push_back(Pair("keyIDMasternode", CBitcoinAddress(mnb.keyIDMasternode).ToString()));
resultObj.push_back(Pair("vchSig", EncodeBase64(&mnb.vchSig[0], mnb.vchSig.size())));
resultObj.push_back(Pair("sigTime", mnb.sigTime));
resultObj.push_back(Pair("protocolVersion", mnb.nProtocolVersion));
@ -944,7 +944,7 @@ UniValue sentinelping(const JSONRPCRequest& request)
);
}
activeMasternode.UpdateSentinelPing(StringVersionToInt(request.params[0].get_str()));
legacyActiveMasternodeManager.UpdateSentinelPing(StringVersionToInt(request.params[0].get_str()));
return true;
}