refactor names and select logic for ONLY_
coins enum members
This commit is contained in:
parent
d1aed33d7a
commit
628d281209
@ -1692,15 +1692,15 @@ bool CDarksendPool::MakeCollateralAmounts()
|
||||
|
||||
// try to use non-denominated and not mn-like funds
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange,
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOT1000IFMN);
|
||||
if(!success){
|
||||
// if we failed (most likeky not enough funds), try to use denominated instead -
|
||||
// if we failed (most likeky not enough funds), try to use all coins instead -
|
||||
// MN-like funds should not be touched in any case and we can't mix denominated without collaterals anyway
|
||||
LogPrintf("MakeCollateralAmounts: ONLY_NONDENOMINATED_NOTMN Error - %s\n", strFail);
|
||||
LogPrintf("MakeCollateralAmounts: ONLY_NONDENOMINATED_NOT1000IFMN Error - %s\n", strFail);
|
||||
success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange,
|
||||
nFeeRet, strFail, coinControl, ONLY_DENOMINATED);
|
||||
nFeeRet, strFail, coinControl, ONLY_NOT1000IFMN);
|
||||
if(!success){
|
||||
LogPrintf("MakeCollateralAmounts: ONLY_DENOMINATED Error - %s\n", strFail);
|
||||
LogPrintf("MakeCollateralAmounts: ONLY_NOT1000IFMN Error - %s\n", strFail);
|
||||
reservekeyCollateral.ReturnKey();
|
||||
return false;
|
||||
}
|
||||
@ -1778,7 +1778,7 @@ bool CDarksendPool::CreateDenominated(int64_t nTotalValue)
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange,
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN);
|
||||
nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOT1000IFMN);
|
||||
if(!success){
|
||||
LogPrintf("CreateDenominated: Error - %s\n", strFail);
|
||||
// TODO: return reservekeyDenom here
|
||||
|
@ -1514,13 +1514,13 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
|
||||
bool found = false;
|
||||
if(coin_type == ONLY_DENOMINATED) {
|
||||
//should make this a vector
|
||||
|
||||
found = IsDenominatedAmount(pcoin->vout[i].nValue);
|
||||
} else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) {
|
||||
} else if(coin_type == ONLY_NOT1000IFMN) {
|
||||
found = !(fMasterNode && pcoin->vout[i].nValue == 1000*COIN);
|
||||
} else if(coin_type == ONLY_NONDENOMINATED_NOT1000IFMN) {
|
||||
if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts
|
||||
found = !IsDenominatedAmount(pcoin->vout[i].nValue);
|
||||
if(found && fMasterNode && coin_type == ONLY_NONDENOMINATED_NOTMN) found = (pcoin->vout[i].nValue != 1000*COIN); // do not use MN funds
|
||||
if(found && fMasterNode) found = pcoin->vout[i].nValue != 1000*COIN; // do not use Hot MN funds
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
@ -1871,7 +1871,7 @@ bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector<
|
||||
nValueRet = 0;
|
||||
|
||||
vector<COutput> vCoins;
|
||||
AvailableCoins(vCoins, true, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOTMN : ONLY_DENOMINATED);
|
||||
AvailableCoins(vCoins, true, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOT1000IFMN : ONLY_DENOMINATED);
|
||||
|
||||
set<pair<const CWalletTx*,unsigned int> > setCoinsRet2;
|
||||
|
||||
@ -1980,21 +1980,6 @@ bool CWallet::IsCollateralAmount(int64_t nInputAmount) const
|
||||
return nInputAmount != 0 && nInputAmount % DARKSEND_COLLATERAL == 0 && nInputAmount < DARKSEND_COLLATERAL * 5 && nInputAmount > DARKSEND_COLLATERAL;
|
||||
}
|
||||
|
||||
bool CWallet::SelectCoinsWithoutDenomination(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
||||
{
|
||||
CCoinControl *coinControl=NULL;
|
||||
|
||||
vector<COutput> vCoins;
|
||||
AvailableCoins(vCoins, true, coinControl, ONLY_NONDENOMINATED);
|
||||
|
||||
BOOST_FOREACH(const COutput& out, vCoins)
|
||||
{
|
||||
nValueRet += out.tx->vout[out.i].nValue;
|
||||
setCoinsRet.insert(make_pair(out.tx, out.i));
|
||||
}
|
||||
return (nValueRet >= nTargetValue);
|
||||
}
|
||||
|
||||
bool CWallet::CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason)
|
||||
{
|
||||
/*
|
||||
@ -2156,9 +2141,9 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend,
|
||||
{
|
||||
if(coin_type == ALL_COINS) {
|
||||
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_NOTMN) {
|
||||
} else if (coin_type == ONLY_NOT1000IFMN) {
|
||||
strFailReason = _("Unable to locate enough funds for this transaction that are not equal 1000 DASH.");
|
||||
} else if (coin_type == ONLY_NONDENOMINATED_NOT1000IFMN) {
|
||||
strFailReason = _("Unable to locate enough Darksend non-denominated funds for this transaction that are not equal 1000 DASH.");
|
||||
} else {
|
||||
strFailReason = _("Unable to locate enough Darksend denominated funds for this transaction.");
|
||||
|
@ -71,8 +71,8 @@ enum AvailableCoinsType
|
||||
{
|
||||
ALL_COINS = 1,
|
||||
ONLY_DENOMINATED = 2,
|
||||
ONLY_NONDENOMINATED = 3,
|
||||
ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 DASH at the same time
|
||||
ONLY_NOT1000IFMN = 3,
|
||||
ONLY_NONDENOMINATED_NOT1000IFMN = 4
|
||||
};
|
||||
|
||||
|
||||
@ -156,7 +156,6 @@ public:
|
||||
int CountInputsWithAmount(int64_t nInputAmount);
|
||||
|
||||
bool SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet) const ;
|
||||
bool SelectCoinsWithoutDenomination(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
|
||||
|
||||
/*
|
||||
* Main wallet lock.
|
||||
|
Loading…
Reference in New Issue
Block a user