From 560c5598bebab043da7b9a2984286bd7beb04ac8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 21 Oct 2016 18:03:15 -0300 Subject: [PATCH] test --- src/coins.cpp | 1 + src/komodo.h | 9 ++++++--- src/wallet/wallet.cpp | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 85bf791f5..6387e13f2 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -384,6 +384,7 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const } uint32_t komodo_txtime(uint256 hash); +int64_t komodo_interest(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx,uint32_t tiptime) const { diff --git a/src/komodo.h b/src/komodo.h index e51a69df8..cc3bb60f8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -271,13 +271,16 @@ uint32_t komodo_txtime(uint256 hash) int64_t komodo_interest(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { - int32_t minutes; + int32_t minutes,days; uint64_t interest = 0; if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= COIN ) { minutes = (tiptime - nLockTime) / 60; - fprintf(stderr,"komodo_interest %lld nLockTime.%u tiptime.%u minutes.%d\n",(long long)nValue,nLockTime,tiptime,minutes); + days = minutes / (24 * 60); + if ( days > 0 ) + interest = (nValue * 50000) / (365 * 1000000 / days); + fprintf(stderr,"komodo_interest %lld nLockTime.%u tiptime.%u minutes.%d days.%d interest %lld %.4f%%\n",(long long)nValue,nLockTime,tiptime,minutes,days,(long long)interest,(double)interest/10000.); } - return(0); + return(interest * 0); } void komodo_nutxoadd(int32_t addflag,int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 194299472..3c58aca4c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2333,6 +2333,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return true; } +int64_t komodo_interest(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); bool CWallet::SelectCoins(const CAmount& nTargetValue, set >& setCoinsRet, CAmount& nValueRet, bool& fOnlyCoinbaseCoinsRet, bool& fNeedCoinbaseCoinsRet, const CCoinControl* coinControl) const { // Output parameter fOnlyCoinbaseCoinsRet is set to true when the only available coins are coinbase utxos. @@ -2374,6 +2375,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; + nValueRet += komodo_interest(out.tx->vout[out.i].nValue,out.tx.nLockTime,activeChain.Tip()->nTime); setCoinsRet.insert(make_pair(out.tx, out.i)); } return (nValueRet >= nTargetValue);