mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
don't use collateral amounts on CreateDenominated / make collateral inputs from all available coins and not only from non-denominated / IsCollateralAmount function
This commit is contained in:
parent
144b24bee5
commit
a07d637a48
@ -1450,8 +1450,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
// should not be less than fees in DARKSEND_FEE + few (lets say 5) smallest denoms
|
||||
int64_t nLowestDenom = DARKSEND_FEE + darkSendDenominations[darkSendDenominations.size() - 1]*5;
|
||||
|
||||
// if there is no DS fee yet
|
||||
if(!pwalletMain->HasDarksendFeeInputs())
|
||||
// if there are no DS collateral inputs yet
|
||||
if(!pwalletMain->HasCollateralInputs())
|
||||
// should have some additional amount for them
|
||||
nLowestDenom += (DARKSEND_COLLATERAL*4)+DARKSEND_FEE*2;
|
||||
|
||||
@ -1496,8 +1496,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
|
||||
|
||||
}
|
||||
|
||||
//check to see if we have the fee sized inputs, it requires these
|
||||
if(!pwalletMain->HasDarksendFeeInputs()){
|
||||
//check to see if we have the collateral sized inputs, it requires these
|
||||
if(!pwalletMain->HasCollateralInputs()){
|
||||
if(!fDryRun) MakeCollateralAmounts();
|
||||
return true;
|
||||
}
|
||||
@ -1715,11 +1715,9 @@ bool CDarkSendPool::SendRandomPaymentToSelf()
|
||||
bool CDarkSendPool::MakeCollateralAmounts()
|
||||
{
|
||||
// should split up to remaining amount only...
|
||||
int64_t nTotalBalance = pwalletMain->GetDenominatedBalance(false);
|
||||
int64_t nTotalBalance = pwalletMain->GetBalance();
|
||||
int64_t nSplitBalance = nAnonymizeDarkcoinAmount*COIN - pwalletMain->GetDenominatedBalance();
|
||||
if(nSplitBalance > nTotalBalance) nSplitBalance = nTotalBalance;
|
||||
// ...but up to 1 DRK only
|
||||
if(nSplitBalance > 1*COIN) nSplitBalance = 1*COIN;
|
||||
int64_t nTotalOut = 0;
|
||||
|
||||
LogPrintf("DoAutomaticDenominating: MakeCollateralAmounts: nSplitBalance %d nTotalBalance %d\n", nSplitBalance, pwalletMain->GetDenominatedBalance(false));
|
||||
@ -1737,20 +1735,19 @@ bool CDarkSendPool::MakeCollateralAmounts()
|
||||
std::string strFail = "";
|
||||
vector< pair<CScript, int64_t> > vecSend;
|
||||
|
||||
// ****** 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;
|
||||
|
||||
if(nTotalOut > nSplitBalance) {
|
||||
LogPrintf("MakeCollateralAmounts: Not enough outputs to make a transaction\n");
|
||||
LogPrintf("MakeCollateralAmounts: Not enough balance to split\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey,
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||
nFeeRet, strFail, coinControl, ALL_COINS);
|
||||
if(!success){
|
||||
LogPrintf("MakeCollateralAmounts: Error - %s\n", strFail.c_str());
|
||||
return false;
|
||||
@ -1782,8 +1779,8 @@ bool CDarkSendPool::CreateDenominated(int64_t nTotalValue)
|
||||
vector< pair<CScript, int64_t> > vecSend;
|
||||
int64_t nValueLeft = nTotalValue;
|
||||
|
||||
// ****** Add fees ************ /
|
||||
if(!pwalletMain->HasDarksendFeeInputs()) {
|
||||
// ****** Add collateral outputs ************ /
|
||||
if(!pwalletMain->HasCollateralInputs()) {
|
||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||
nValueLeft -= (DARKSEND_COLLATERAL*2)+DARKSEND_FEE;
|
||||
vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE));
|
||||
|
@ -1239,10 +1239,11 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
if(rounds >= 0) found = true;
|
||||
} else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) {
|
||||
found = true;
|
||||
if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts
|
||||
BOOST_FOREACH(int64_t d, darkSendDenominations)
|
||||
if(pcoin->vout[i].nValue == d)
|
||||
found = false;
|
||||
if(coin_type == ONLY_NONDENOMINATED_NOTMN) found = found && (pcoin->vout[i].nValue != 1000*COIN);
|
||||
if(found && coin_type == ONLY_NONDENOMINATED_NOTMN) found = (pcoin->vout[i].nValue != 1000*COIN); // do not use MN funds
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
@ -1640,13 +1641,8 @@ bool CWallet::SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nV
|
||||
BOOST_FOREACH(const COutput& out, vCoins)
|
||||
{
|
||||
// collateral inputs will always be a multiple of DARSEND_COLLATERAL, up to five
|
||||
if(
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE
|
||||
){
|
||||
if(IsCollateralAmount(out.tx->vout[out.i].nValue))
|
||||
{
|
||||
CTxIn vin = CTxIn(out.tx->GetHash(),out.i);
|
||||
|
||||
vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey
|
||||
@ -1689,7 +1685,7 @@ int CWallet::CountInputsWithAmount(int64_t nInputAmount)
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
bool CWallet::HasDarksendFeeInputs() const
|
||||
bool CWallet::HasCollateralInputs() const
|
||||
{
|
||||
CCoinControl *coinControl=NULL;
|
||||
|
||||
@ -1698,20 +1694,20 @@ bool CWallet::HasDarksendFeeInputs() const
|
||||
|
||||
int nFound = 0;
|
||||
BOOST_FOREACH(const COutput& out, vCoins)
|
||||
{
|
||||
if(
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
||||
out.tx->vout[out.i].nValue == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE
|
||||
) nFound++;
|
||||
|
||||
}
|
||||
if(IsCollateralAmount(out.tx->vout[out.i].nValue)) nFound++;
|
||||
|
||||
return nFound > 1; // should have more than one just in case
|
||||
}
|
||||
|
||||
bool CWallet::IsCollateralAmount(int64_t nInputAmount) const
|
||||
{
|
||||
return nInputAmount == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE ||
|
||||
nInputAmount == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE ||
|
||||
nInputAmount == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE ||
|
||||
nInputAmount == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE ||
|
||||
nInputAmount == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE;
|
||||
}
|
||||
|
||||
bool CWallet::SelectCoinsWithoutDenomination(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
||||
{
|
||||
CCoinControl *coinControl=NULL;
|
||||
|
@ -137,7 +137,8 @@ public:
|
||||
bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector<CTxIn>& setCoinsRet, vector<COutput>& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax);
|
||||
bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const;
|
||||
bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const;
|
||||
bool HasDarksendFeeInputs() const;
|
||||
bool HasCollateralInputs() const;
|
||||
bool IsCollateralAmount(int64_t nInputAmount) const;
|
||||
int CountInputsWithAmount(int64_t nInputAmount);
|
||||
|
||||
bool SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const ;
|
||||
|
Loading…
Reference in New Issue
Block a user