From 50760585735d7df3d8bad3d47b641edb1126bb4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 Nov 2016 11:47:21 -0300 Subject: [PATCH] test --- src/coins.cpp | 4 ++-- src/komodo_bitcoind.h | 11 ----------- src/komodo_interest.h | 32 ++++++++++++++++++++++++++++++++ src/rpcblockchain.cpp | 21 +-------------------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 6343e2374..4b89e8a69 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -405,8 +405,8 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr int64_t interest; interest = komodo_accrued_interest(tx.vin[i].prevout.hash,tx.vin[i].prevout.n,nHeight,value); //interest = komodo_interest(nHeight,value,tx.nLockTime,tiptime); - printf("nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); - fprintf(stderr,"nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + printf("nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + fprintf(stderr,"nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); nResult += interest; (*interestp) += interest; } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1bb2ddf91..602174257 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -548,14 +548,3 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has return(0); } -uint64_t komodo_accrued_interest(uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue) -{ - uint64_t value; int32_t txheight; uint32_t locktime,tiptime; - if ( (locktime= komodo_interest_args(&txheight,&tiptime,&value,hash,n)) != 0 ) - { - if ( (checkvalue == 0 || value == checkvalue) && (checkheight == 0 || txheight == checkheight) ) - return(komodo_interest(txheight,value,locktime,tiptime)); - //fprintf(stderr,"nValue %llu lock.%u:%u nTime.%u -> %llu\n",(long long)coins.vout[n].nValue,coins.nLockTime,timestamp,pindex->nTime,(long long)interest); - } else fprintf(stderr,"komodo_accrued_interest value mismatch %llu vs %llu or height mismatch %d vs %d\n",(long long)value,(long long)checkvalue,txheight,checkheight); - return(0); -} diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 9d66b3344..d0b8f014c 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -72,3 +72,35 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin } return(interest); } + +uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n) +{ + LOCK(cs_main); + CTransaction tx; uint256 hashBlock; CBlockIndex *pindex,*tipindex; + if ( !GetTransaction(hash,tx,hashBlock,true) ) + return(0); + uint32_t locktime = 0; + if ( n < tx.vout.size() ) + { + if ( (pindex= mapBlockIndex[hashBlock]) != 0 && (tipindex= chainActive.Tip()) != 0 ) + { + *valuep = tx.vout[n].nValue; + *txheightp = pindex->nHeight; + *tiptimep = tipindex->nTime; + locktime = tx.nLockTime; + } + } + return(locktime); +} + +uint64_t komodo_accrued_interest(uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue) +{ + uint64_t value; int32_t txheight; uint32_t locktime,tiptime; + if ( (locktime= komodo_interest_args(&txheight,&tiptime,&value,hash,n)) != 0 ) + { + if ( (checkvalue == 0 || value == checkvalue) && (checkheight == 0 || txheight == checkheight) ) + return(komodo_interest(txheight,value,locktime,tiptime)); + //fprintf(stderr,"nValue %llu lock.%u:%u nTime.%u -> %llu\n",(long long)coins.vout[n].nValue,coins.nLockTime,timestamp,pindex->nTime,(long long)interest); + } else fprintf(stderr,"komodo_accrued_interest value mismatch %llu vs %llu or height mismatch %d vs %d\n",(long long)value,(long long)checkvalue,txheight,checkheight); + return(0); +} diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 4c1f06dea..37079088a 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -386,26 +386,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); - -uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n) -{ - LOCK(cs_main); - CTransaction tx; uint256 hashBlock; CBlockIndex *pindex,*tipindex; - if ( !GetTransaction(hash,tx,hashBlock,true) ) - return(0); - uint32_t locktime = 0; - if ( n < tx.vout.size() ) - { - if ( (pindex= mapBlockIndex[hashBlock]) != 0 && (tipindex= chainActive.Tip()) != 0 ) - { - *valuep = tx.vout[n].nValue; - *txheightp = pindex->nHeight; - *tiptimep = tipindex->nTime; - locktime = tx.nLockTime; - } - } - return(locktime); -} +uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n); Value notaries(const Array& params, bool fHelp) {