mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
more fixes/cleanup/debug output to DS mixing
This commit is contained in:
parent
9a4fac6bb6
commit
144b24bee5
@ -1388,7 +1388,6 @@ void CDarkSendPool::CompletedTransaction(bool error, std::string lastMessageNew)
|
||||
|
||||
// To avoid race conditions, we'll only let DS run once per block
|
||||
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||
splitUpInARow = 0;
|
||||
}
|
||||
lastMessage = lastMessageNew;
|
||||
|
||||
@ -1415,8 +1414,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false;
|
||||
|
||||
if(chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing) {
|
||||
LogPrintf("CDarkSendPool::DoAutomaticDenominating - Last successful darksend was too recent\n");
|
||||
strAutoDenomResult = "Last successful darksend was too recent";
|
||||
LogPrintf("CDarkSendPool::DoAutomaticDenominating - Last successful darksend action was too recent\n");
|
||||
strAutoDenomResult = "Last successful darksend action was too recent";
|
||||
return false;
|
||||
}
|
||||
if(!fEnableDarksend) {
|
||||
@ -1445,7 +1444,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
// ** find the coins we'll use
|
||||
std::vector<CTxIn> vCoins;
|
||||
std::vector<COutput> vCoins2;
|
||||
int64_t nValueMin = 0.01*COIN;
|
||||
int64_t nValueMin = CENT;
|
||||
int64_t nValueIn = 0;
|
||||
|
||||
// should not be less than fees in DARKSEND_FEE + few (lets say 5) smallest denoms
|
||||
@ -1499,7 +1498,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
|
||||
//check to see if we have the fee sized inputs, it requires these
|
||||
if(!pwalletMain->HasDarksendFeeInputs()){
|
||||
if(!fDryRun) SplitUpMoney(true);
|
||||
if(!fDryRun) MakeCollateralAmounts();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1713,31 +1712,17 @@ bool CDarkSendPool::SendRandomPaymentToSelf()
|
||||
}
|
||||
|
||||
// Split up large inputs or create fee sized inputs
|
||||
bool CDarkSendPool::SplitUpMoney(bool justCollateral)
|
||||
bool CDarkSendPool::MakeCollateralAmounts()
|
||||
{
|
||||
if((chainActive.Tip()->nHeight - lastSplitUpBlock) < 10){
|
||||
LogPrintf("SplitUpMoney - Too soon to split up again\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(splitUpInARow >= 2){
|
||||
LogPrintf("Error: Darksend SplitUpMoney was called multiple times in a row. This should not happen. Please submit a detailed explanation of the steps it took to create this error and submit to evan@darkcoin.io. \n");
|
||||
fEnableDarksend = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// should split up to remaining amount only...
|
||||
int64_t nTotalBalance = pwalletMain->GetDenominatedBalance(false);
|
||||
int64_t nSplitBalance = nAnonymizeDarkcoinAmount*COIN - pwalletMain->GetDenominatedBalance();
|
||||
if(nSplitBalance > nTotalBalance) nSplitBalance = nTotalBalance;
|
||||
// ...or up to 1 DRK if it's just collateral
|
||||
if(justCollateral && nSplitBalance > 1*COIN) nSplitBalance = 1*COIN;
|
||||
// ...but up to 1 DRK only
|
||||
if(nSplitBalance > 1*COIN) nSplitBalance = 1*COIN;
|
||||
int64_t nTotalOut = 0;
|
||||
lastSplitUpBlock = chainActive.Tip()->nHeight;
|
||||
|
||||
LogPrintf("DoAutomaticDenominating: Split up large input (justCollateral %d):\n", justCollateral);
|
||||
LogPrintf(" -- nSplitBalance %d\n", nSplitBalance);
|
||||
LogPrintf(" -- denom %d \n", pwalletMain->GetDenominatedBalance(false));
|
||||
LogPrintf("DoAutomaticDenominating: MakeCollateralAmounts: nSplitBalance %d nTotalBalance %d\n", nSplitBalance, pwalletMain->GetDenominatedBalance(false));
|
||||
|
||||
// make our change address
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
@ -1752,54 +1737,31 @@ bool CDarkSendPool::SplitUpMoney(bool justCollateral)
|
||||
std::string strFail = "";
|
||||
vector< pair<CScript, int64_t> > vecSend;
|
||||
|
||||
int64_t a = 1*COIN;
|
||||
|
||||
// ****** Add fees ************ /
|
||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||
nTotalOut += (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||
|
||||
// ****** Add outputs in bases of two from 1 darkcoin *** /
|
||||
if(!justCollateral){
|
||||
bool continuing = true;
|
||||
|
||||
while(continuing){
|
||||
if(nTotalOut + a < nSplitBalance){
|
||||
//LogPrintf(" nTotalOut %d, added %d\n", nTotalOut, a);
|
||||
|
||||
vecSend.push_back(make_pair(scriptChange, a));
|
||||
nTotalOut += a;
|
||||
} else {
|
||||
continuing = false;
|
||||
}
|
||||
|
||||
a = a * 2;
|
||||
}
|
||||
}
|
||||
|
||||
if((justCollateral && nTotalOut <= 0.1*COIN) || vecSend.size() < 1) {
|
||||
LogPrintf("SplitUpMoney: Not enough outputs to make a transaction\n");
|
||||
return false;
|
||||
}
|
||||
if((!justCollateral && nTotalOut <= 1*COIN) || vecSend.size() < 1){
|
||||
LogPrintf("SplitUpMoney: Not enough outputs to make a transaction\n");
|
||||
if(nTotalOut > nSplitBalance) {
|
||||
LogPrintf("MakeCollateralAmounts: Not enough outputs to make a transaction\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||
nFeeRet, strFail, coinControl, justCollateral ? ALL_COINS : ONLY_NONDENOMINATED);
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||
if(!success){
|
||||
LogPrintf("SplitUpMoney: Error - %s\n", strFail.c_str());
|
||||
LogPrintf("MakeCollateralAmounts: Error - %s\n", strFail.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
pwalletMain->CommitTransaction(wtx, reservekey);
|
||||
// use the same cachedLastSuccess as for DS mixinx to prevent race
|
||||
if(pwalletMain->CommitTransaction(wtx, reservekey))
|
||||
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||
|
||||
LogPrintf("SplitUpMoney Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
||||
LogPrintf("MakeCollateralAmounts Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
||||
|
||||
splitUpInARow++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1857,13 +1819,15 @@ bool CDarkSendPool::CreateDenominated(int64_t nTotalValue)
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_MN);
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||
if(!success){
|
||||
LogPrintf("CreateDenominated: Error - %s\n", strFail.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
pwalletMain->CommitTransaction(wtx, reservekey);
|
||||
// use the same cachedLastSuccess as for DS mixinx to prevent race
|
||||
if(pwalletMain->CommitTransaction(wtx, reservekey))
|
||||
cachedLastSuccess = chainActive.Tip()->nHeight;
|
||||
|
||||
LogPrintf("CreateDenominated Success: tx %s\n", wtx.GetHash().GetHex().c_str());
|
||||
|
||||
@ -2125,6 +2089,9 @@ bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, vector<unsigned char>& vchSi
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fDebug && pubkey2.GetID() != pubkey.GetID())
|
||||
LogPrintf("CDarkSendSigner::VerifyMessage -- keys don't match: %s %s", pubkey2.GetID().ToString(), pubkey.GetID().ToString());
|
||||
|
||||
return (pubkey2.GetID() == pubkey.GetID());
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,6 @@ public:
|
||||
int64_t sessionTotalValue; //used for autoDenom
|
||||
std::vector<CTransaction> vecSessionCollateral;
|
||||
|
||||
int lastSplitUpBlock;
|
||||
int splitUpInARow; // how many splits we've done since a success?
|
||||
int cachedLastSuccess;
|
||||
int cachedNumBlocks; //used for the overview screen
|
||||
int minBlockSpacing; //required blocks between mixes
|
||||
@ -277,11 +275,9 @@ public:
|
||||
/* DarkSend uses collateral addresses to trust parties entering the pool
|
||||
to behave themselves. If they don't it takes their money. */
|
||||
|
||||
lastSplitUpBlock = 0;
|
||||
cachedLastSuccess = 0;
|
||||
cachedNumBlocks = 0;
|
||||
unitTest = false;
|
||||
splitUpInARow = 0;
|
||||
txCollateral = CTransaction();
|
||||
minBlockSpacing = 1;
|
||||
nDsqCount = 0;
|
||||
@ -420,7 +416,7 @@ public:
|
||||
// used for liquidity providers
|
||||
bool SendRandomPaymentToSelf();
|
||||
// split up large inputs or make fee sized inputs
|
||||
bool SplitUpMoney(bool justCollateral=false);
|
||||
bool MakeCollateralAmounts();
|
||||
bool CreateDenominated(int64_t nTotalValue);
|
||||
// get the denominations for a list of outputs (returns a bitshifted integer)
|
||||
int GetDenominations(const std::vector<CTxOut>& vout);
|
||||
|
@ -1237,12 +1237,12 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
|
||||
int rounds = GetInputDarksendRounds(vin);
|
||||
if(rounds >= 0) found = true;
|
||||
} else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_MN) {
|
||||
} else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) {
|
||||
found = true;
|
||||
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
||||
if(pcoin->vout[i].nValue == d)
|
||||
found = false;
|
||||
if(coin_type == ONLY_NONDENOMINATED_MN) found = found && (pcoin->vout[i].nValue != 1000*COIN);
|
||||
if(coin_type == ONLY_NONDENOMINATED_NOTMN) found = found && (pcoin->vout[i].nValue != 1000*COIN);
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
@ -1590,7 +1590,7 @@ bool CWallet::SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector<
|
||||
nValueRet = 0;
|
||||
|
||||
vector<COutput> vCoins;
|
||||
AvailableCoins(vCoins, false, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED : ONLY_DENOMINATED);
|
||||
AvailableCoins(vCoins, false, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOTMN : ONLY_DENOMINATED);
|
||||
|
||||
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
|
||||
|
||||
@ -1849,7 +1849,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
||||
strFailReason = _("Insufficient funds");
|
||||
else if (coin_type == ONLY_NONDENOMINATED)
|
||||
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction");
|
||||
else if (coin_type == ONLY_NONDENOMINATED_MN)
|
||||
else if (coin_type == ONLY_NONDENOMINATED_NOTMN)
|
||||
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction that are not equal 1000 DRK");
|
||||
else
|
||||
strFailReason = _("Unable to locate enough Darksend denominated funds for this transaction");
|
||||
|
@ -56,7 +56,7 @@ enum AvailableCoinsType
|
||||
ALL_COINS = 1,
|
||||
ONLY_DENOMINATED = 2,
|
||||
ONLY_NONDENOMINATED = 3,
|
||||
ONLY_NONDENOMINATED_MN = 4 // ONLY_NONDENOMINATED and not 1000 DRK at the same time
|
||||
ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 DRK at the same time
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user