From b2d09a90d469c62c9cbbad5ca3855c404648b5aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Mar 2017 22:46:42 +0200 Subject: [PATCH] Test --- src/komodo_bitcoind.h | 5 ++++- src/main.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 481ede104..8a5bcfec1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -620,7 +620,10 @@ void komodo_connectpindex(CBlockIndex *pindex) CBlockIndex *komodo_chainactive(int32_t height) { - return(chainActive[height]); + if ( chainActive.Tip() != 0 && height <= chainActive.Tip()->nHeight ) + { + return(chainActive[height]); + } else return(0); } int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height); diff --git a/src/main.cpp b/src/main.cpp index ba8944a24..cf7da0e44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -710,10 +710,15 @@ bool IsStandardTx(const CTransaction& tx, string& reason) int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint32_t txblocktime) { - int32_t i,txheight=0; uint32_t cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; + int32_t i,txheight=0; uint32_t prevblocktime,cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; CBlockIndex *prev; if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//1473793441 ) { - locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); + prevblocktime = 0; + if ( (locktime= komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0)) != 0 && txheight > 0 ) + { + if ( (prev= komodo_chainactive(txheight-1)) != 0 ) + prevblocktime = prev->nTime; + } if ( tiptime == 0 ) tiptime = (int32_t)chainActive.Tip()->nTime; if ( txheighttime == 0 ) @@ -733,6 +738,8 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint3 cmptime = txblocktime; if ( tiptime != 0 && tiptime < cmptime ) cmptime = tiptime; + if ( locktime != 0 && prevblocktime != 0 && prevblocktime < cmptime ) + cmptime = prevblocktime; if ( cmptime >= 1490159171 - 24*3600 ) { if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 ) @@ -740,7 +747,9 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint3 if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748 { if ( tx.nLockTime != 1477258935 ) + { fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime); + } if ( expiredp != 0 ) *expiredp = cmptime-3600; return(-1); -- 2.42.0