diff --git a/src/main.cpp b/src/main.cpp index a5599c181f..3e0508f549 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6854,22 +6854,15 @@ bool CDarkSendPool::GetLastValidBlockHash(uint256& hash, int mod, int nBlockHeig bool CDarkSendPool::DoConcessusVote(int64 nBlockHeight) { - LogPrintf("CDarkSendPool::DoConcessusVote\n"); bool fIsInitialDownload = IsInitialBlockDownload(); if(fIsInitialDownload) return false; - LogPrintf("CDarkSendPool::DoConcessusVote - 2\n"); - //If masternode, vote for whoever I think should win next block if(!fMasterNode || isCapableMasterNode != MASTERNODE_IS_CAPABLE) return false; - LogPrintf("CDarkSendPool::DoConcessusVote - 3\n"); - int rank = GetMasternodeRank(vinMasterNode, 1); int winner = GetCurrentMasterNode(1, nBlockHeight); - LogPrintf("CDarkSendPool::DoConcessusVote - 4 %d %d\n", rank, winner); - if(rank <= 10 && winner != 1){ std::vector vchMasterNodeSignature; std::string errorMessage = ""; @@ -7083,7 +7076,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) } if(balanceNeedsAnonymized > nValueMax) balanceNeedsAnonymized = nValueMax; - if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, minRounds, nDarksendRounds)) + if (!pwalletMain->SelectCoinsDark(nValueMin, maxAmount*COIN, vCoins, nValueIn, minRounds, nDarksendRounds)) { nValueIn = 0; vCoins.clear(); @@ -7099,6 +7092,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) return false; } + if(nValueIn < COIN*1.1){ //simply look for non-denominated coins @@ -7116,13 +7110,17 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) // initial phase, find a masternode if(!sessionFoundMasternode){ + int64 nTotalValue = pwalletMain->GetTotalValue(vCoins) - DARKSEND_FEE; + double fDarkcoinSubmitted = nTotalValue / COIN; + LogPrintf("Submiting Darksend for %f DRK\n", fDarkcoinSubmitted); + // 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(nValueIn)) { - LogPrintf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(nValueIn)); + if(dsq.nDenom != GetDenominationsByAmount(nTotalValue)) { + LogPrintf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(nTotalValue)); continue; } dsq.time = 0; //remove node @@ -7133,8 +7131,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) BOOST_FOREACH(CNode* pnode, vNodes) { if(submittedToMasternode != pnode->addr) continue; - pnode->PushMessage("dsa", nValueIn); - LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %"PRI64d"\n", balanceNeedsAnonymized); + pnode->PushMessage("dsa", nTotalValue); + LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %"PRI64d"\n", nTotalValue); return true; } } else { @@ -7158,8 +7156,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun) BOOST_FOREACH(CNode* pnode, vNodes) { if(darkSendMasterNodes[i].addr != pnode->addr) continue; - pnode->PushMessage("dsa", balanceNeedsAnonymized); - LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %"PRI64d"\n", balanceNeedsAnonymized); + pnode->PushMessage("dsa", nTotalValue); + LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %"PRI64d"\n", nTotalValue); return true; } } else { diff --git a/src/wallet.cpp b/src/wallet.cpp index 37eeb8f216..3ee11efb6b 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1678,6 +1678,21 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nVal return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee, coin_type); } +int64 CWallet::GetTotalValue(std::vector vCoins) { + int64 nTotalValue = 0; + CWalletTx wtx; + BOOST_FOREACH(CTxIn i, vCoins){ + if (mapWallet.count(i.prevout.hash)) + { + CWalletTx& wtx = mapWallet[i.prevout.hash]; + nTotalValue += wtx.vout[i.prevout.n].nValue; + } else { + LogPrintf("GetTotalValue -- Couldn't find transaction\n"); + } + } + return nTotalValue; +} + string CWallet::DarkSendDenominate(int minRounds, int maxAmount) { @@ -1709,18 +1724,7 @@ string CWallet::DarkSendDenominate(int minRounds, int maxAmount) } // calculate total value out - int64 nTotalValue = 0; - CWalletTx wtx; - BOOST_FOREACH(CTxIn i, vCoins){ - if (mapWallet.count(i.prevout.hash)) - { - CWalletTx& wtx = mapWallet[i.prevout.hash]; - nTotalValue += wtx.vout[i.prevout.n].nValue; - } else { - LogPrintf("SelectCoinsDarkDenominated -- Couldn't find transaction\n"); - } - } - nTotalValue -= nFeeRet; //minus fees + int64 nTotalValue = GetTotalValue(vCoins) - nFeeRet; //-------------- diff --git a/src/wallet.h b/src/wallet.h index 0685c2d993..4fb8fd88c6 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -146,6 +146,7 @@ public: void UnlockCoin(COutPoint& output); void UnlockAllCoins(); void ListLockedCoins(std::vector& vOutpts); + int64 GetTotalValue(std::vector vCoins); // keystore implementation // Generate a new key