Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.gitignore
*.sublime-project
*.sublime-workspace
todo.txt
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5316,7 +5316,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)){
LogPrintf("dstx: Got bad masternode address signature %s \n", vin.ToString());
//pfrom->Misbehaving(20);
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ bool CBudgetVote::SignatureValid(bool fSignatureCheck)

if(!fSignatureCheck) return true;

if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) {
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) {
LogPrintf("CBudgetVote::SignatureValid() - Verify message failed\n");
return false;
}
Expand Down Expand Up @@ -2034,7 +2034,7 @@ bool CFinalizedBudgetVote::SignatureValid(bool fSignatureCheck)

if(!fSignatureCheck) return true;

if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) {
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) {
LogPrintf("CFinalizedBudgetVote::SignatureValid() - Verify message failed\n");
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe
//no masternode detected
CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1);
if(winningNode){
payee = GetScriptForDestination(winningNode->pubkey.GetID());
payee = GetScriptForDestination(winningNode->pubKeyCollateralAddress.GetID());
} else {
LogPrintf("CreateNewBlock: Failed to detect masternode to pay\n");
hasPayment = false;
Expand Down Expand Up @@ -467,7 +467,7 @@ bool CMasternodePayments::IsScheduled(CMasternode& mn, int nNotBlockHeight)
if(pindexPrev == NULL) return false;

CScript mnpayee;
mnpayee = GetScriptForDestination(mn.pubkey.GetID());
mnpayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());

CScript payee;
for(int64_t h = pindexPrev->nHeight; h <= pindexPrev->nHeight+8; h++){
Expand Down Expand Up @@ -722,7 +722,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)

newWinner.nBlockHeight = nBlockHeight;

CScript payee = GetScriptForDestination(pmn->pubkey.GetID());
CScript payee = GetScriptForDestination(pmn->pubKeyCollateralAddress.GetID());
newWinner.AddPayee(payee);

CTxDestination address1;
Expand Down Expand Up @@ -780,7 +780,7 @@ bool CMasternodePaymentWinner::SignatureValid()
payee.ToString();

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)){
return error("CMasternodePaymentWinner::SignatureValid() - Got bad Masternode address signature %s \n", vinMasternode.ToString().c_str());
}

Expand Down
57 changes: 29 additions & 28 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ CMasternode::CMasternode()
LOCK(cs);
vin = CTxIn();
addr = CService();
pubkey = CPubKey();
pubkey2 = CPubKey();
pubKeyCollateralAddress = CPubKey();
pubKeyMasternode = CPubKey();
sig = std::vector<unsigned char>();
activeState = MASTERNODE_ENABLED;
sigTime = GetAdjustedTime();
Expand All @@ -84,8 +84,8 @@ CMasternode::CMasternode(const CMasternode& other)
LOCK(cs);
vin = other.vin;
addr = other.addr;
pubkey = other.pubkey;
pubkey2 = other.pubkey2;
pubKeyCollateralAddress = other.pubKeyCollateralAddress;
pubKeyMasternode = other.pubKeyMasternode;
sig = other.sig;
activeState = other.activeState;
sigTime = other.sigTime;
Expand All @@ -109,8 +109,8 @@ CMasternode::CMasternode(const CMasternodeBroadcast& mnb)
LOCK(cs);
vin = mnb.vin;
addr = mnb.addr;
pubkey = mnb.pubkey;
pubkey2 = mnb.pubkey2;
pubKeyCollateralAddress = mnb.pubKeyCollateralAddress;
pubKeyMasternode = mnb.pubKeyMasternode;
sig = mnb.sig;
activeState = MASTERNODE_ENABLED;
sigTime = mnb.sigTime;
Expand All @@ -135,7 +135,8 @@ CMasternode::CMasternode(const CMasternodeBroadcast& mnb)
bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb)
{
if(mnb.sigTime > sigTime) {
pubkey2 = mnb.pubkey2;
pubKeyMasternode = mnb.pubKeyMasternode;
pubKeyCollateralAddress = mnb.pubKeyCollateralAddress;
sigTime = mnb.sigTime;
sig = mnb.sig;
protocolVersion = mnb.protocolVersion;
Expand Down Expand Up @@ -228,7 +229,7 @@ void CMasternode::Check(bool forceCheck)

int64_t CMasternode::SecondsSincePayment() {
CScript pubkeyScript;
pubkeyScript = GetScriptForDestination(pubkey.GetID());
pubkeyScript = GetScriptForDestination(pubKeyCollateralAddress.GetID());

int64_t sec = (GetAdjustedTime() - GetLastPaid());
int64_t month = 60*60*24*30;
Expand All @@ -248,7 +249,7 @@ int64_t CMasternode::GetLastPaid() {
if(pindexPrev == NULL) return false;

CScript mnpayee;
mnpayee = GetScriptForDestination(pubkey.GetID());
mnpayee = GetScriptForDestination(pubKeyCollateralAddress.GetID());

CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << vin;
Expand Down Expand Up @@ -313,8 +314,8 @@ CMasternodeBroadcast::CMasternodeBroadcast()
{
vin = CTxIn();
addr = CService();
pubkey = CPubKey();
pubkey2 = CPubKey();
pubKeyCollateralAddress = CPubKey();
pubKeyMasternode1 = CPubKey();
sig = std::vector<unsigned char>();
activeState = MASTERNODE_ENABLED;
sigTime = GetAdjustedTime();
Expand All @@ -329,12 +330,12 @@ CMasternodeBroadcast::CMasternodeBroadcast()
nLastScanningErrorBlockHeight = 0;
}

CMasternodeBroadcast::CMasternodeBroadcast(CService newAddr, CTxIn newVin, CPubKey newPubkey, CPubKey newPubkey2, int protocolVersionIn)
CMasternodeBroadcast::CMasternodeBroadcast(CService newAddr, CTxIn newVin, CPubKey pubKeyCollateralAddressNew, CPubKey pubKeyMasternodeNew, int protocolVersionIn)
{
vin = newVin;
addr = newAddr;
pubkey = newPubkey;
pubkey2 = newPubkey2;
pubKeyCollateralAddress = pubKeyCollateralAddressNew;
pubKeyMasternode = pubKeyMasternodeNew;
sig = std::vector<unsigned char>();
activeState = MASTERNODE_ENABLED;
sigTime = GetAdjustedTime();
Expand All @@ -353,8 +354,8 @@ CMasternodeBroadcast::CMasternodeBroadcast(const CMasternode& mn)
{
vin = mn.vin;
addr = mn.addr;
pubkey = mn.pubkey;
pubkey2 = mn.pubkey2;
pubKeyCollateralAddress = mn.pubKeyCollateralAddress;
pubKeyMasternode = mn.pubKeyMasternode;
sig = mn.sig;
activeState = mn.activeState;
sigTime = mn.sigTime;
Expand Down Expand Up @@ -460,8 +461,8 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
return false;
}

std::string vchPubKey(pubkey.begin(), pubkey.end());
std::string vchPubKey2(pubkey2.begin(), pubkey2.end());
std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end());
std::string strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion);

if(protocolVersion < masternodePayments.GetMinMasternodePaymentsProto()) {
Expand All @@ -470,7 +471,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
}

CScript pubkeyScript;
pubkeyScript = GetScriptForDestination(pubkey.GetID());
pubkeyScript = GetScriptForDestination(pubKeyCollateralAddress.GetID());

if(pubkeyScript.size() != 25) {
LogPrintf("mnb - pubkey the wrong size\n");
Expand All @@ -479,7 +480,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
}

CScript pubkeyScript2;
pubkeyScript2 = GetScriptForDestination(pubkey2.GetID());
pubkeyScript2 = GetScriptForDestination(pubKeyMasternode.GetID());

if(pubkeyScript2.size() != 25) {
LogPrintf("mnb - pubkey2 the wrong size\n");
Expand All @@ -493,7 +494,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
}

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pubkey, sig, strMessage, errorMessage)){
if(!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, strMessage, errorMessage)){
LogPrintf("mnb - Got bad Masternode address signature\n");
nDos = 100;
return false;
Expand Down Expand Up @@ -521,7 +522,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)

// mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below,
// after that they just need to match
if(pmn->pubkey == pubkey && !pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS)) {
if(pmn->pubKeyCollateralAddress == pubKeyCollateralAddress && !pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS)) {
//take the newest entry
LogPrintf("mnb - Got updated entry for %s\n", addr.ToString());
if(pmn->UpdateFromNewBroadcast((*this))){
Expand All @@ -538,7 +539,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)
{
// we are a masternode with the same vin (i.e. already activated) and this mnb is ours (matches our Masternode privkey)
// so nothing to do here for us
if(fMasterNode && vin.prevout == activeMasternode.vin.prevout && pubkey2 == activeMasternode.pubKeyMasternode)
if(fMasterNode && vin.prevout == activeMasternode.vin.prevout && pubKeyMasternode == activeMasternode.pubKeyMasternode)
return true;

// search existing Masternode list
Expand Down Expand Up @@ -606,7 +607,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)
mnodeman.Add(mn);

// if it matches our Masternode privkey, then we've been remotely activated
if(pubkey2 == activeMasternode.pubKeyMasternode && protocolVersion == PROTOCOL_VERSION){
if(pubKeyMasternode == activeMasternode.pubKeyMasternode && protocolVersion == PROTOCOL_VERSION){
activeMasternode.EnableHotColdMasterNode(vin, addr);
}

Expand All @@ -628,8 +629,8 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
{
std::string errorMessage;

std::string vchPubKey(pubkey.begin(), pubkey.end());
std::string vchPubKey2(pubkey2.begin(), pubkey2.end());
std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end());

sigTime = GetAdjustedTime();

Expand All @@ -640,7 +641,7 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
return false;
}

if(!obfuScationSigner.VerifyMessage(pubkey, sig, strMessage, errorMessage)) {
if(!obfuScationSigner.VerifyMessage(pubKeyCollateralAddress, sig, strMessage, errorMessage)) {
LogPrintf("CMasternodeBroadcast::Sign() - Error: %s\n", errorMessage);
return false;
}
Expand Down Expand Up @@ -716,7 +717,7 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled)
std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast<std::string>(sigTime);

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage))
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage))
{
LogPrintf("CMasternodePing::CheckAndUpdate - Got bad Masternode address signature %s\n", vin.ToString());
nDos = 33;
Expand Down
18 changes: 9 additions & 9 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class CMasternode

CTxIn vin;
CService addr;
CPubKey pubkey;
CPubKey pubkey2;
CPubKey pubKeyCollateralAddress;
CPubKey pubKeyMasternode;
CPubKey pubKeyCollateralAddress1;
CPubKey pubKeyMasternode1;
std::vector<unsigned char> sig;
int activeState;
int64_t sigTime; //mnb message time
Expand Down Expand Up @@ -159,8 +159,8 @@ class CMasternode
// the two classes are effectively swapped
swap(first.vin, second.vin);
swap(first.addr, second.addr);
swap(first.pubkey, second.pubkey);
swap(first.pubkey2, second.pubkey2);
swap(first.pubKeyCollateralAddress, second.pubKeyCollateralAddress);
swap(first.pubKeyMasternode, second.pubKeyMasternode);
swap(first.sig, second.sig);
swap(first.activeState, second.activeState);
swap(first.sigTime, second.sigTime);
Expand Down Expand Up @@ -199,8 +199,8 @@ class CMasternode

READWRITE(vin);
READWRITE(addr);
READWRITE(pubkey);
READWRITE(pubkey2);
READWRITE(pubKeyCollateralAddress);
READWRITE(pubKeyMasternode);
READWRITE(sig);
READWRITE(sigTime);
READWRITE(protocolVersion);
Expand Down Expand Up @@ -307,8 +307,8 @@ class CMasternodeBroadcast : public CMasternode
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vin);
READWRITE(addr);
READWRITE(pubkey);
READWRITE(pubkey2);
READWRITE(pubKeyCollateralAddress);
READWRITE(pubKeyMasternode);
READWRITE(sig);
READWRITE(sigTime);
READWRITE(protocolVersion);
Expand All @@ -319,7 +319,7 @@ class CMasternodeBroadcast : public CMasternode
uint256 GetHash(){
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << sigTime;
ss << pubkey;
ss << pubKeyCollateralAddress;
return ss.GetHash();
}

Expand Down
16 changes: 8 additions & 8 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ CMasternode *CMasternodeMan::Find(const CScript &payee)

BOOST_FOREACH(CMasternode& mn, vMasternodes)
{
payee2 = GetScriptForDestination(mn.pubkey.GetID());
payee2 = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());
if(payee2 == payee)
return &mn;
}
Expand All @@ -429,7 +429,7 @@ CMasternode *CMasternodeMan::Find(const CPubKey &pubKeyMasternode)

BOOST_FOREACH(CMasternode& mn, vMasternodes)
{
if(mn.pubkey2 == pubKeyMasternode)
if(mn.pubKeyMasternode == pubKeyMasternode)
return &mn;
}
return NULL;
Expand Down Expand Up @@ -704,7 +704,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData

// make sure the vout that was signed is related to the transaction that spawned the Masternode
// - this is expensive, so it's only done once per Masternode
if(!obfuScationSigner.IsVinAssociatedWithPubkey(mnb.vin, mnb.pubkey)) {
if(!obfuScationSigner.IsVinAssociatedWithPubkey(mnb.vin, mnb.pubKeyCollateralAddress)) {
LogPrintf("mnb - Got mismatched pubkey and vin\n");
Misbehaving(pfrom->GetId(), 33);
return;
Expand Down Expand Up @@ -890,12 +890,12 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
// e.g. We don't want the entry relayed/time updated when we're syncing the list
// mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below,
// after that they just need to match
if(count == -1 && pmn->pubkey == pubkey && (GetAdjustedTime() - pmn->nLastDsee > MASTERNODE_MIN_MNB_SECONDS)){
if(count == -1 && pmn->pubKeyCollateralAddress == pubkey && (GetAdjustedTime() - pmn->nLastDsee > MASTERNODE_MIN_MNB_SECONDS)){
if(pmn->protocolVersion > GETHEADERS_VERSION && sigTime - pmn->lastPing.sigTime < MASTERNODE_MIN_MNB_SECONDS) return;
if(pmn->nLastDsee < sigTime){ //take the newest entry
LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str());
if(pmn->protocolVersion < GETHEADERS_VERSION) {
pmn->pubkey2 = pubkey2;
pmn->pubKeyMasternode = pubkey2;
pmn->sigTime = sigTime;
pmn->sig = vchSig;
pmn->protocolVersion = protocolVersion;
Expand Down Expand Up @@ -983,10 +983,10 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CMasternode mn = CMasternode();
mn.addr = addr;
mn.vin = vin;
mn.pubkey = pubkey;
mn.pubKeyCollateralAddress = pubkey;
mn.sig = vchSig;
mn.sigTime = sigTime;
mn.pubkey2 = pubkey2;
mn.pubKeyMasternode = pubkey2;
mn.protocolVersion = protocolVersion;
// fake ping
mn.lastPing = CMasternodePing(vin);
Expand Down Expand Up @@ -1059,7 +1059,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
std::string strMessage = pmn->addr.ToString() + boost::lexical_cast<std::string>(sigTime) + boost::lexical_cast<std::string>(stop);

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage))
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage))
{
LogPrintf("dseep - Got bad Masternode address signature %s \n", vin.ToString().c_str());
//Misbehaving(pfrom->GetId(), 100);
Expand Down
6 changes: 3 additions & 3 deletions src/obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,8 +1699,8 @@ bool CObfuscationPool::MakeCollateralAmounts()
std::string strFail = "";
vector< pair<CScript, int64_t> > vecSend;
CCoinControl coinControl;
coinControl.fAllowOtherInputs = false; // TKS probable crash reason
coinControl.fAllowWatchOnly = false; // TKS
coinControl.fAllowOtherInputs = false;
coinControl.fAllowWatchOnly = false;
// make our collateral address
CReserveKey reservekeyCollateral(pwalletMain);
// make our change address
Expand Down Expand Up @@ -2183,7 +2183,7 @@ bool CObfuscationQueue::CheckSignature()
std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(time) + boost::lexical_cast<std::string>(ready);

std::string errorMessage = "";
if(!obfuScationSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){
if(!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)){
return error("CObfuscationQueue::CheckSignature() - Got bad Masternode address signature %s \n", vin.ToString().c_str());
}

Expand Down
Loading