From 09e3cf94a43180076e45a0ce8c36aa128c98eaff Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Nov 2016 19:07:45 -0300 Subject: [PATCH] test --- src/komodo.h | 3 +-- src/komodo_bitcoind.h | 1 - src/rpcmisc.cpp | 3 +++ src/wallet/rpcwallet.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ccc94bb36..f308c893b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,11 +17,10 @@ #define H_KOMODO_H // Todo: -// 00. standardize interests // 0. optimize assetchains RT loop // 1. error check fiat redeem amounts // 2. net balance limiter -// 3. verify: interest payment, reorgs +// 3. verify: reorgs // 4. automate notarization fee payouts // 5. automated distribution of test REVS snapshot diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0c4748275..017703dbf 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -582,4 +582,3 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 } return(0); } - diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 122ee0a90..dc4f82074 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -39,6 +39,8 @@ using namespace std; * * Or alternatively, create a specific query method for the information. **/ +uint64_t komod_interestsum(); + Value getinfo(const Array& params, bool fHelp) { extern uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; @@ -90,6 +92,7 @@ Value getinfo(const Array& params, bool fHelp) if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("interest", ValueFromAmount(komod_interestsum()))); } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 12350db81..e51863dba 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2489,6 +2489,32 @@ Value listunspent(const Array& params, bool fHelp) return results; } +uint64_t komod_interestsum() +{ + uint64_t interest,sum = 0; + vector vecOutputs; + assert(pwalletMain != NULL); + LOCK2(cs_main, pwalletMain->cs_wallet); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + BOOST_FOREACH(const COutput& out,vecOutputs) + { + if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) + continue; + CAmount nValue = out.tx->vout[out.i].nValue; + if ( out.tx->nLockTime != 0 ) + { + BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); + CBlockIndex *tipindex,*pindex = it->second; + if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) + { + interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); + sum += interest; + } + } + } + return(sum); +} + Value zc_sample_joinsplit(const json_spirit::Array& params, bool fHelp) { if (fHelp) {