|
|
@ -3242,8 +3242,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const |
|
|
|
!IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && |
|
|
|
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) |
|
|
|
{ |
|
|
|
if ( KOMODO_EXCHANGEWALLET == 0 ) |
|
|
|
{ |
|
|
|
if ( 1 ) { |
|
|
|
uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; |
|
|
|
if ( SMART_CHAIN_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && chainActive.LastTip()->GetHeight() >= 60000 ) |
|
|
|
{ |
|
|
@ -3257,28 +3256,18 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const |
|
|
|
//interest = komodo_interestnew(chainActive.LastTip()->GetHeight()+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
|
|
|
if ( interest != 0 ) |
|
|
|
{ |
|
|
|
//printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime);
|
|
|
|
//fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.LastTip()->GetHeight()+1,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
|
|
|
//ptr = (uint64_t *)&pcoin->vout[i].nValue;
|
|
|
|
//(*ptr) += interest;
|
|
|
|
ptr = (uint64_t *)&pcoin->vout[i].interest; |
|
|
|
(*ptr) = interest; |
|
|
|
//pcoin->vout[i].nValue += interest;
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
} else { |
|
|
|
ptr = (uint64_t *)&pcoin->vout[i].interest; |
|
|
|
(*ptr) = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
} else { |
|
|
|
ptr = (uint64_t *)&pcoin->vout[i].interest; |
|
|
|
(*ptr) = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
} else { |
|
|
|
ptr = (uint64_t *)&pcoin->vout[i].interest; |
|
|
|
(*ptr) = 0; |
|
|
|
} |
|
|
@ -3369,30 +3358,20 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int |
|
|
|
{ |
|
|
|
setCoinsRet.insert(coin.second); |
|
|
|
nValueRet += coin.first; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 )
|
|
|
|
// *interestp += pcoin->vout[i].interest;
|
|
|
|
return true; |
|
|
|
} |
|
|
|
else if (n < nTargetValue + CENT) |
|
|
|
{ |
|
|
|
vValue.push_back(coin); |
|
|
|
nTotalLower += n; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 && count < sizeof(interests)/sizeof(*interests) )
|
|
|
|
//{
|
|
|
|
//fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN);
|
|
|
|
//interests[count++] = pcoin->vout[i].interest;
|
|
|
|
//}
|
|
|
|
if ( nTotalLower > 4*nTargetValue + CENT ) |
|
|
|
{ |
|
|
|
//fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n");
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (n < coinLowestLarger.first) |
|
|
|
} else if (n < coinLowestLarger.first) |
|
|
|
{ |
|
|
|
coinLowestLarger = coin; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 )
|
|
|
|
// lowest_interest = pcoin->vout[i].interest;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -3402,8 +3381,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int |
|
|
|
{ |
|
|
|
setCoinsRet.insert(vValue[i].second); |
|
|
|
nValueRet += vValue[i].first; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
|
|
|
|
// *interestp += interests[i];
|
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
@ -3414,8 +3391,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int |
|
|
|
return false; |
|
|
|
setCoinsRet.insert(coinLowestLarger.second); |
|
|
|
nValueRet += coinLowestLarger.first; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 )
|
|
|
|
// *interestp += lowest_interest;
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -3435,17 +3410,12 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int |
|
|
|
{ |
|
|
|
setCoinsRet.insert(coinLowestLarger.second); |
|
|
|
nValueRet += coinLowestLarger.first; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 )
|
|
|
|
// *interestp += lowest_interest;
|
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
for (unsigned int i = 0; i < vValue.size(); i++) |
|
|
|
if (vfBest[i]) |
|
|
|
{ |
|
|
|
setCoinsRet.insert(vValue[i].second); |
|
|
|
nValueRet += vValue[i].first; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
|
|
|
|
// *interestp += interests[i];
|
|
|
|
} |
|
|
|
|
|
|
|
LogPrint("selectcoins", "SelectCoins() best subset: "); |
|
|
@ -3484,8 +3454,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx* |
|
|
|
continue; |
|
|
|
} |
|
|
|
value += out.tx->vout[out.i].nValue; |
|
|
|
if ( KOMODO_EXCHANGEWALLET == 0 ) |
|
|
|
value += out.tx->vout[out.i].interest; |
|
|
|
value += out.tx->vout[out.i].interest; |
|
|
|
} |
|
|
|
if (value <= nTargetValue) { |
|
|
|
CAmount valueWithCoinbase = 0; |
|
|
@ -3494,8 +3463,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx* |
|
|
|
continue; |
|
|
|
} |
|
|
|
valueWithCoinbase += out.tx->vout[out.i].nValue; |
|
|
|
if ( KOMODO_EXCHANGEWALLET == 0 ) |
|
|
|
valueWithCoinbase += out.tx->vout[out.i].interest; |
|
|
|
valueWithCoinbase += out.tx->vout[out.i].interest; |
|
|
|
} |
|
|
|
fNeedCoinbaseCoinsRet = (valueWithCoinbase >= nTargetValue); |
|
|
|
} |
|
|
@ -3508,8 +3476,6 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx* |
|
|
|
if (!out.fSpendable) |
|
|
|
continue; |
|
|
|
nValueRet += out.tx->vout[out.i].nValue; |
|
|
|
//if ( KOMODO_EXCHANGEWALLET == 0 )
|
|
|
|
// *interestp += out.tx->vout[out.i].interest;
|
|
|
|
setCoinsRet.insert(make_pair(out.tx, out.i)); |
|
|
|
} |
|
|
|
return (nValueRet >= nTargetValue); |
|
|
@ -3531,8 +3497,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx* |
|
|
|
if (pcoin->vout.size() <= outpoint.n) |
|
|
|
return false; |
|
|
|
nValueFromPresetInputs += pcoin->vout[outpoint.n].nValue; |
|
|
|
if ( KOMODO_EXCHANGEWALLET == 0 ) |
|
|
|
nValueFromPresetInputs += pcoin->vout[outpoint.n].interest; |
|
|
|
nValueFromPresetInputs += pcoin->vout[outpoint.n].interest; |
|
|
|
setPresetCoins.insert(make_pair(pcoin, outpoint.n)); |
|
|
|
} else |
|
|
|
return false; // TODO: Allow non-wallet inputs
|
|
|
@ -3747,7 +3712,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt |
|
|
|
//a chance at a free transaction.
|
|
|
|
//But mempool inputs might still be in the mempool, so their age stays 0
|
|
|
|
//fprintf(stderr,"nCredit %.8f interest %.8f\n",(double)nCredit/COIN,(double)pcoin.first->vout[pcoin.second].interest/COIN);
|
|
|
|
if ( KOMODO_EXCHANGEWALLET == 0 && SMART_CHAIN_SYMBOL[0] == 0 ) |
|
|
|
if ( SMART_CHAIN_SYMBOL[0] == 0 ) |
|
|
|
{ |
|
|
|
interest2 += pcoin.first->vout[pcoin.second].interest; |
|
|
|
//fprintf(stderr,"%.8f ",(double)pcoin.first->vout[pcoin.second].interest/COIN);
|
|
|
@ -3757,11 +3722,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt |
|
|
|
age += 1; |
|
|
|
dPriority += (double)nCredit * age; |
|
|
|
} |
|
|
|
//if ( KOMODO_EXCHANGEWALLET != 0 )
|
|
|
|
//{
|
|
|
|
//fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN);
|
|
|
|
//interest = 0; // interest2 also
|
|
|
|
//}
|
|
|
|
if ( SMART_CHAIN_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) |
|
|
|
{ |
|
|
|
CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG; |
|
|
|