diff --git a/src/main.cpp b/src/main.cpp index 73da510da1..2d3b51b2a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3965,8 +3965,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } printf("new darksend queue object - %s\n", addr.ToString().c_str()); - dsq.Relay(); vecDarksendQueue.push_back(dsq); + dsq.Relay(); } else if (strCommand == "dsi") { //DarkSend vIn if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) { @@ -4095,7 +4095,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return false; } - if(darkSendPool.submittedToMasternode != pfrom->addr){ printf("dssu - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str()); return false; @@ -6241,7 +6240,9 @@ void CDarkSendPool::CheckTimeout(){ } - } else if(GetTimeMillis()-lastTimeChanged >= 30000){ + } + + if(GetTimeMillis()-lastTimeChanged >= 30000){ if(fDebug) printf("CDarkSendPool::CheckTimeout() -- SESSION TIMED OUT (30) -- RESETTING\n"); SetNull(); UnlockCoins(); @@ -6370,7 +6371,7 @@ bool CDarkSendPool::AddEntry(const std::vector& newInput, const int64& nA if(entries.size() == 1) { //broadcast that I'm accepting entries CDarksendQueue dsq; - dsq.nAmount = nAmount; + dsq.nDenom = GetDenominations(newOutput); dsq.vin = vinMasterNode; dsq.time = GetTime(); dsq.Relay(); @@ -6904,8 +6905,6 @@ void CDarkSendPool::NewBlock() if(IsInitialBlockDownload()) return; - printf("CDarkSendPool::NewBlock - 2\n"); - { LOCK2(cs_main, mempool.cs); if(pindexBest != NULL) { @@ -6921,8 +6920,6 @@ void CDarkSendPool::NewBlock() } } - printf("CDarkSendPool::NewBlock - 3\n"); - //send votes for next block and one after that DoConcessusVote(pindexBest->nHeight + 2); DoConcessusVote(pindexBest->nHeight + 3); @@ -7103,7 +7100,12 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) // if we have any pending merges BOOST_FOREACH(CDarksendQueue dsq, vecDarksendQueue){ CService addr; + if(dsq.time == 0) continue; if(!dsq.GetAddress(addr)) continue; + if(dsq.nDenom != GetDenominationsByAmount(balanceNeedsAnonymized)) { + printf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(balanceNeedsAnonymized)); + continue; + } dsq.time = 0; //remove node if(ConnectNode((CAddress)addr, NULL, true)){ @@ -7488,42 +7490,16 @@ bool CDarkSendPool::IsCompatibleWithSession(int64 nAmount) return false; } - /*CScript e = CScript(); - int64 nValueLeft = nAmount; - std::vector vout1; - BOOST_FOREACH(int64 v, darkSendDenominations){ - int nOutputs = 0; - while(nValueLeft - v >= 0 && nOutputs <= 10) { - CTxOut o(v, e); - vout1.push_back(o); - nValueLeft -= v; - nOutputs++; - } - } - - nValueLeft = sessionAmount; - - std::vector vout2; - BOOST_FOREACH(int64 v, darkSendDenominations){ - int nOutputs = 0; - while(nValueLeft - v >= 0 && nOutputs <= 10) { - CTxOut o(v, e); - vout2.push_back(o); - nValueLeft -= v; - nOutputs++; - } - } - - if(GetDenominations(vout1) != GetDenominations(vout2)) return false; - printf("CDarkSendPool::IsCompatibleWithSession - compatible\n");*/ + if(GetDenominationsByAmount(nAmount) != GetDenominationsByAmount(sessionAmount)) return false; + printf("CDarkSendPool::IsCompatibleWithSession - compatible\n"); sessionUsers++; lastTimeChanged = GetTimeMillis(); return true; } -int CDarkSendPool::GetDenominations(std::vector vout){ +int CDarkSendPool::GetDenominations(const std::vector& vout){ std::vector > denomUsed; BOOST_FOREACH(int64 d, darkSendDenominations) @@ -7542,6 +7518,24 @@ int CDarkSendPool::GetDenominations(std::vector vout){ return denom; } +int CDarkSendPool::GetDenominationsByAmount(int64 nAmount){ + CScript e = CScript(); + int64 nValueLeft = nAmount; + + std::vector vout1; + BOOST_FOREACH(int64 v, darkSendDenominations){ + int nOutputs = 0; + while(nValueLeft - v >= 0 && nOutputs <= 10) { + CTxOut o(v, e); + vout1.push_back(o); + nValueLeft -= v; + nOutputs++; + } + } + + return GetDenominations(vout1); +} + bool CDarkSendSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey){ CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); diff --git a/src/main.h b/src/main.h index 1d1e0a3cc9..d6b97d3d51 100644 --- a/src/main.h +++ b/src/main.h @@ -2570,20 +2570,20 @@ public: class CDarksendQueue { public: - int64 nAmount; CTxIn vin; int64 time; + int nDenom; CDarksendQueue() { - nAmount = 0; + nDenom = 0; vin = CTxIn(); time = 0; } IMPLEMENT_SERIALIZE ( - READWRITE(nAmount); + READWRITE(nDenom); READWRITE(vin); READWRITE(time); ) @@ -2632,7 +2632,7 @@ static const int64 DARKSEND_FEE = 0.001*COIN; class CDarkSendPool { public: - static const int MIN_PEER_PROTO_VERSION = 70029; + static const int MIN_PEER_PROTO_VERSION = 70030; std::vector myEntries; std::vector entries; @@ -2795,7 +2795,8 @@ public: bool DoConcessusVote(int64 nBlockHeight); int GetInputDarksendRounds(CTxIn in, int rounds=0); bool SplitUpMoney(bool justCollateral=false); - int GetDenominations(std::vector vout); + int GetDenominations(const std::vector& vout); + int GetDenominationsByAmount(int64 nAmount); }; void ConnectToDarkSendMasterNodeWinner(); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index a28ae47527..636fe6d271 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -313,6 +313,8 @@ void SendCoinsDialog::darkSendStatus() } } + if(!darkSendPool.sessionFoundMasternode) return; + int state = darkSendPool.GetState(); int entries = darkSendPool.GetEntriesCount(); int accepted = darkSendPool.GetLastEntryAccepted(); diff --git a/src/version.h b/src/version.h index 9827adb0f8..5da7fd32f9 100644 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70029; +static const int PROTOCOL_VERSION = 70030; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209;