From 4dc232ac4d91279aa1aa1d034cdf8d203e93378b Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Thu, 9 Oct 2014 12:05:25 -0700 Subject: [PATCH] missing changes --- src/darksend.cpp | 19 +++++++++++++++++++ src/darksend.h | 1 + src/main.cpp | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/darksend.cpp b/src/darksend.cpp index 11ca810194..a1277cf423 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -1859,6 +1859,23 @@ int CDarkSendPool::GetDenominationsByAmount(int64 nAmount){ return GetDenominations(vout1); } +bool CDarkSendSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){ + CScript payee2; + payee2.SetDestination(pubkey.GetID()); + + CTransaction txVin; + uint256 hash; + if(GetTransaction(vin.prevout.hash, txVin, hash, true)){ + BOOST_FOREACH(CTxOut out, txVin.vout){ + if(out.nValue == 1000*COIN){ + if(out.scriptPubKey == payee2) return true; + } + } + } + + return false; +} + bool CDarkSendSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey){ CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); @@ -1905,6 +1922,8 @@ bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, vector& vchSi bool CDarksendQueue::Sign() { + if(!fMasterNode) return false; + std::string strMessage = vin.ToString() + boost::lexical_cast(nDenom) + boost::lexical_cast(time) + boost::lexical_cast(ready); CKey key2; diff --git a/src/darksend.h b/src/darksend.h index c6fed0d1f0..81dcace968 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -255,6 +255,7 @@ public: class CDarkSendSigner { public: + bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey); bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey); bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector& vchSig, CKey key); bool VerifyMessage(CPubKey pubkey, std::vector& vchSig, std::string strMessage, std::string& errorMessage); diff --git a/src/main.cpp b/src/main.cpp index f7d5d71022..8be5fc19e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3940,6 +3940,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return true; } + if(!fMasterNode){ + return false; + } + int64 nAmount; CTransaction txCollateral; vRecv >> nAmount >> txCollateral; @@ -4343,6 +4347,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } } + if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) { + LogPrintf("dsee - Got mismatched pubkey and vin\n"); + pfrom->Misbehaving(100); + return false; + } + LogPrintf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str()); CValidationState state;