denominating 1 satoshi higher and other fixes

This commit is contained in:
Evan Duffield 2014-07-29 07:40:06 -07:00
parent 57b5cd02e2
commit 0f0b5a20d9
4 changed files with 50 additions and 20 deletions

View File

@ -1180,10 +1180,10 @@ bool AppInit2(boost::thread_group& threadGroup)
//override masternode
strUseMasternode = GetArg("-usemasternode", "");
darkSendDenominations.push_back( 500 * COIN );
darkSendDenominations.push_back( 100 * COIN );
darkSendDenominations.push_back( 10 * COIN );
darkSendDenominations.push_back( 1 * COIN );
darkSendDenominations.push_back( (500 * COIN)+1 );
darkSendDenominations.push_back( (100 * COIN)+1 );
darkSendDenominations.push_back( (10 * COIN)+1 );
darkSendDenominations.push_back( (1 * COIN)+1 );
threadGroup.create_thread(boost::bind(&ThreadCheckDarkSendPool));

View File

@ -6994,6 +6994,14 @@ void CDarkSendPool::DoAutomaticDenominating()
}
if(nValueIn < COIN*1.1){
//simply look for non-denominated coins
if (pwalletMain->SelectCoinsDark(nValueMax+1, 9999999*COIN, vCoins, nValueIn, -2, nDarksendRounds))
{
SplitUpMoney();
return;
}
printf("DoAutomaticDenominating : Too little to denominate (must have 1.1DRK) \n");
return;
}
@ -7002,11 +7010,10 @@ void CDarkSendPool::DoAutomaticDenominating()
int64 amount = pwalletMain->GetBalance();
if(amount > 999*COIN) amount = (999*COIN);
amount -= amount/10;
amount = roundUp64(amount, COIN/100); //
amount = roundUp64(amount, COIN/100);
std::string strError = pwalletMain->DarkSendDenominate(amount);
printf("DoAutomaticDenominating : Running darksend denominate for %"PRI64d" coins. Return '%s'\n", nValueIn, strError.c_str());
printf("DoAutomaticDenominating : Running darksend denominate for %"PRI64d" coins. Return '%s'\n", nValueIn/COIN, strError.c_str());
if(strError == "") return;
@ -7019,7 +7026,7 @@ void CDarkSendPool::DoAutomaticDenominating()
bool CDarkSendPool::SplitUpMoney()
{
int64 nTotalBalance = pwalletMain->GetBalance();
int64 nTotalBalance = pwalletMain->GetNonDenominatedBalance();
int64 nTotalOut = 0;
printf("DoAutomaticDenominating: Split up large input:\n");
@ -7041,9 +7048,9 @@ bool CDarkSendPool::SplitUpMoney()
int64 a = nTotalBalance/5;
if(a > 900*COIN) a = 900*COIN;
while(nTotalOut + a + (a/5) + (POOL_FEE_AMOUNT*4) < nTotalBalance-FEE){
printf(" nTotalOut %"PRI64d"\n", nTotalOut);
printf(" nTotalOut + ((nTotalBalance/5) + (nTotalBalance/5/5) + 0.01*COIN) %"PRI64d"\n", nTotalOut + ((a) + (a/5) + ((POOL_FEE_AMOUNT*4))));
printf(" nTotalBalance-(FEE) %"PRI64d"\n", nTotalBalance-(FEE));
printf(" nTotalOut %"PRI64d"\n", nTotalOut/COIN);
printf(" nTotalOut + ((nTotalBalance/5) + (nTotalBalance/5/5) + 0.01*COIN) %"PRI64d"\n", nTotalOut + ((a) + (a/5) + ((POOL_FEE_AMOUNT*4)))/COIN);
printf(" nTotalBalance-(FEE) %"PRI64d"\n", (nTotalBalance-FEE)/COIN);
vecSend.push_back(make_pair(scriptChange, a));
vecSend.push_back(make_pair(scriptChange, a/5));
vecSend.push_back(make_pair(scriptChange, POOL_FEE_AMOUNT*4));

View File

@ -927,8 +927,32 @@ int64 CWallet::GetBalance() const
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx* pcoin = &(*it).second;
if (pcoin->IsConfirmed())
if (pcoin->IsConfirmed()){
nTotal += pcoin->GetAvailableCredit();
}
}
}
return nTotal;
}
int64 CWallet::GetNonDenominatedBalance() const
{
int64 nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx* pcoin = &(*it).second;
if (pcoin->IsConfirmed()){
bool isDenom = false;
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
BOOST_FOREACH(int64 d, darkSendDenominations)
if(pcoin->vout[i].nValue == d)
isDenom = true;
if(!isDenom) nTotal += pcoin->GetAvailableCredit();
}
}
}
@ -1245,24 +1269,22 @@ bool CWallet::SelectCoinsDark(int64 nValueMin, int64 nValueMax, std::vector<CTxI
BOOST_FOREACH(const COutput& out, vCoins)
{
if(out.tx->vout[out.i].nValue == POOL_FEE_AMOUNT*4) continue; //these are made for collateral
if(fMasterNode && out.tx->vout[out.i].nValue == 1000*COIN) continue; //masternode input
if(nValueRet + out.tx->vout[out.i].nValue <= nValueMax){
CTxIn vin = CTxIn(out.tx->GetHash(),out.i);
printf(" vin nValue %"PRI64d"\n", out.tx->vout[out.i].nValue);
int rounds = darkSendPool.GetInputDarksendRounds(vin);
printf(" -- rounds %d\n", rounds);
printf(" vin nValue %"PRI64d" rounds %d\n", out.tx->vout[out.i].nValue/COIN, rounds);
if(rounds >= nDarksendRoundsMax) continue;
printf(" -- rounds continue\n");
if(rounds < nDarksendRoundsMin) continue;
printf(" -- rounds less than max\n");
if(rounds < nDarksendRoundsMin) continue;
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
nValueRet += out.tx->vout[out.i].nValue;
setCoinsRet.push_back(vin);
setCoinsRet2.insert(make_pair(out.tx, out.i));
printf(" -- nValueRet %"PRI64d"\n", nValueRet);
printf(" -- nValueRet %"PRI64d"\n", nValueRet/COIN);
if(nValueRet >= nValueMax) return true;
}
}
@ -1344,7 +1366,7 @@ bool CWallet::CreateTransaction(std::vector<pair<CScript, int64> >& vecSend,
{
BOOST_FOREACH(int64 d, darkSendDenominations)
if(s.second == d)
s.second += 1; //denominations are reserved, add 1 satoshi
s.second -= 1; //denominations are reserved, subtract 1 satoshi (10.00000001 will become 10DRK)
if (nValue < 0)
{

View File

@ -193,6 +193,7 @@ public:
void ReacceptWalletTransactions();
void ResendWalletTransactions();
int64 GetBalance() const;
int64 GetNonDenominatedBalance() const;
int64 GetUnconfirmedBalance() const;
int64 GetImmatureBalance() const;
bool CreateTransaction(std::vector<std::pair<CScript, int64> >& vecSend,