mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
darksend is working, seemingly
This commit is contained in:
parent
8e282f23f4
commit
9dcd60885b
14
src/main.cpp
14
src/main.cpp
@ -6977,13 +6977,13 @@ void CDarkSendPool::DoAutomaticDenominating()
|
||||
int64 nValueMax = 999*COIN;
|
||||
int64 nValueIn = 0;
|
||||
|
||||
if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, 0, nDarksendRounds))
|
||||
if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, -2, nDarksendRounds))
|
||||
{
|
||||
nValueIn = 0;
|
||||
vCoins.clear();
|
||||
|
||||
//simply look for non-denominated coins
|
||||
if (pwalletMain->SelectCoinsDark(nValueMax+1, 9999999*COIN, vCoins, nValueIn, 0, nDarksendRounds))
|
||||
if (pwalletMain->SelectCoinsDark(nValueMax+1, 9999999*COIN, vCoins, nValueIn, -2, nDarksendRounds))
|
||||
{
|
||||
SplitUpMoney();
|
||||
return;
|
||||
@ -6993,6 +6993,11 @@ void CDarkSendPool::DoAutomaticDenominating()
|
||||
return;
|
||||
}
|
||||
|
||||
if(nValueIn < COIN*1.1){
|
||||
printf("DoAutomaticDenominating : Too little to denominate (must have 1.1DRK) \n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int64 amount = pwalletMain->GetBalance();
|
||||
if(amount > 999*COIN) amount = (999*COIN);
|
||||
@ -7044,7 +7049,8 @@ bool CDarkSendPool::SplitUpMoney()
|
||||
nTotalOut += (nTotalBalance/5) + (nTotalBalance/5/5) + (POOL_FEE_AMOUNT*4);
|
||||
}
|
||||
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, strFail);
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED);
|
||||
if(!success){
|
||||
printf("SplitUpMoney: Error - %s\n", strFail.c_str());
|
||||
return false;
|
||||
@ -7138,7 +7144,7 @@ bool CDarkSendPool::GetCurrentMasterNodeConsessus(int64 blockHeight, CScript& pa
|
||||
// recursively find how many transactions deep the darksending goes
|
||||
int CDarkSendPool::GetInputDarksendRounds(CTxIn in, int rounds)
|
||||
{
|
||||
if(rounds >= 8) return rounds;
|
||||
if(rounds >= 9) return rounds;
|
||||
|
||||
std::string padding = "";
|
||||
padding.insert(0, ((rounds+1)*5)+3, ' ');
|
||||
|
@ -197,9 +197,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
||||
std::string strFailReason;
|
||||
bool fCreated = false;
|
||||
|
||||
AvailableCoinsType act = ONLY_NONDENOMINATED;
|
||||
//if(isDarkSend) act = ONLY_DENOMINATED;
|
||||
|
||||
AvailableCoinsType act = ONLY_DENOMINATED;
|
||||
if(recipients[0].inputType == "ONLY_NONDENOMINATED"){
|
||||
act = ONLY_NONDENOMINATED;
|
||||
} else if(recipients[0].inputType == "ONLY_DENOMINATED"){
|
||||
|
@ -716,7 +716,11 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
CReserveKey keyChange(pwalletMain);
|
||||
int64 nFeeRequired = 0;
|
||||
string strFailReason;
|
||||
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason);
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
AvailableCoinsType act = ONLY_DENOMINATED;
|
||||
|
||||
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason, coinControl, act);
|
||||
if (!fCreated)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
|
||||
if (!pwalletMain->CommitTransaction(wtx, keyChange))
|
||||
|
@ -1236,7 +1236,7 @@ bool CWallet::SelectCoinsDark(int64 nValueMin, int64 nValueMax, std::vector<CTxI
|
||||
CCoinControl *coinControl=NULL;
|
||||
|
||||
vector<COutput> vCoins;
|
||||
AvailableCoins(vCoins, false, coinControl);
|
||||
AvailableCoins(vCoins, false, coinControl, ALL_COINS);
|
||||
|
||||
printf("found coins %d\n", (int)vCoins.size());
|
||||
|
||||
@ -1248,21 +1248,58 @@ bool CWallet::SelectCoinsDark(int64 nValueMin, int64 nValueMax, std::vector<CTxI
|
||||
|
||||
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);
|
||||
if(rounds < 0) rounds = 0;
|
||||
if(rounds < nDarksendRoundsMin && rounds >= nDarksendRoundsMax) continue;
|
||||
|
||||
printf(" -- rounds %d\n", rounds);
|
||||
if(rounds >= nDarksendRoundsMax) continue;
|
||||
printf(" -- rounds continue\n");
|
||||
|
||||
if(rounds < nDarksendRoundsMin) continue;
|
||||
|
||||
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
|
||||
printf(" vin nValue %"PRI64d"\n", out.tx->vout[out.i].nValue);
|
||||
nValueRet += out.tx->vout[out.i].nValue;
|
||||
setCoinsRet.push_back(vin);
|
||||
setCoinsRet2.insert(make_pair(out.tx, out.i));
|
||||
printf(" -- nValueRet %"PRI64d"\n", nValueRet);
|
||||
if(nValueRet >= nValueMin) return true;
|
||||
if(nValueRet >= nValueMax) return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(nValueRet >= nValueMin) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CWallet::SelectCoinsCollateral(int64 nValueMin, int64 nValueMax, std::vector<CTxIn>& setCoinsRet, int64& nValueRet) const
|
||||
{
|
||||
CCoinControl *coinControl=NULL;
|
||||
|
||||
vector<COutput> vCoins;
|
||||
AvailableCoins(vCoins, false, coinControl, ALL_COINS);
|
||||
|
||||
printf("found coins %d\n", (int)vCoins.size());
|
||||
|
||||
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
|
||||
|
||||
BOOST_FOREACH(const COutput& out, vCoins)
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
if(nValueRet >= nValueMax) return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(nValueRet >= nValueMin) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1615,7 +1652,7 @@ string CWallet::DarkSendDenominate(int64 nValue)
|
||||
int64 nValueIn = 0;
|
||||
|
||||
//try to use denominated funds (for added anonymity)
|
||||
if (!SelectCoinsDark(nTotalValue, 1000*COIN, vCoins, nValueIn, 0, nDarksendRounds))
|
||||
if (!SelectCoinsDark(0, nTotalValue, vCoins, nValueIn, -2, nDarksendRounds))
|
||||
{
|
||||
vCoins.clear();
|
||||
return _("Insufficient funds 2");
|
||||
@ -1648,12 +1685,12 @@ string CWallet::DarkSendDenominate(int64 nValue)
|
||||
int64 nValueIn2 = 0;
|
||||
std::vector<CTxIn> vCoinsCollateral;
|
||||
|
||||
if (!SelectCoinsDark(POOL_FEE_AMOUNT+(0.01*COIN), 99999*COIN, vCoinsCollateral, nValueIn2, 0, nDarksendRounds))
|
||||
if (!SelectCoinsCollateral(POOL_FEE_AMOUNT, POOL_FEE_AMOUNT*6, vCoinsCollateral, nValueIn2))
|
||||
{
|
||||
BOOST_FOREACH(CTxIn v, vCoins)
|
||||
UnlockCoin(v.prevout);
|
||||
|
||||
return _("Error: The DarkSend requires a collateral transaction and could not locate the input!");
|
||||
return _("Error: Darksend requires a collateral transaction and could not locate an acceptable input!");
|
||||
}
|
||||
|
||||
// make our change address
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
bool SelectCoinsDarkDenominated(int64 nTargetValue, std::vector<CTxIn>& setCoinsRet, int64& nValueRet) const;
|
||||
bool SelectCoinsExactOutput(int64 nTargetValue, CTxIn& vin, int64& nValueRet, CScript& pubScript, bool confirmed) const;
|
||||
|
||||
bool SelectCoinsCollateral(int64 nValueMin, int64 nValueMax, std::vector<CTxIn>& setCoinsRet, int64& nValueRet) const;
|
||||
bool SelectCoinsWithoutDenomination(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const;
|
||||
bool SelectCoinsMoreThanOutput(int64 nTargetValue, CTxIn& vin, int64& nValueRet, bool confirmed) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user