diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9b5d4e898..65b1b4e8b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -596,11 +596,13 @@ int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex) CBlockIndex *komodo_chainactive(int32_t height) { - if ( chainActive.Tip() != 0 && height <= chainActive.Tip()->nHeight ) + if ( chainActive.Tip() != 0 ) { - return(chainActive[height]); + if ( height <= chainActive.Tip()->nHeight ) + return(chainActive[height]); + else fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); } - fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); + fprintf(stderr,"komodo_chainactive null chainActive.Tip() height %d\n",height); return(0); } diff --git a/src/main.cpp b/src/main.cpp index 78af52e15..40d9ee355 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -712,7 +712,7 @@ uint32_t komodo_heightstamp(int32_t height); int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32_t txheightarg) { - int32_t i; uint32_t cmptime; uint64_t value=0; CBlockIndex *prev; + int32_t i; uint32_t cmptime; uint64_t value=0; CBlockIndex *tip=0; if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//1473793441 ) { /* uint32_t prevblocktime=0,cmptime=0,txheighttime=0,tiptime=0,locktime=0; @@ -761,9 +761,17 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime); } }*/ + tip = chainActive.Tip(); if ( txheightarg == 0 ) - txheightarg = chainActive.Tip()->nHeight; - else txheightarg--; + { + if ( tip != 0 ) + txheightarg = tip->nHeight + 1; + else + { + fprintf(stderr,"couldnt get chaintip for [%d]\n",txheightarg); + return(-1); + } + } if ( (cmptime= komodo_heightstamp(txheightarg-1)) == 0 ) { fprintf(stderr,"couldnt get prev.[%d] use tiptime.%u\n",txheightarg-1,cmptime); @@ -779,14 +787,14 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 { if ( tx.nLockTime != 1477258935 ) { - fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u tiptime.%u cmp.%u\n",txheightarg,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,(uint32_t)chainActive.Tip()->nTime,cmptime); + fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u tiptime.%u cmp.%u\n",txheightarg,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,(uint32_t)tip != 0 ? tip->nTime : 0,cmptime); } if ( expiredp != 0 ) *expiredp = cmptime-3600; return(-1); } } - fprintf(stderr,"validateinterest accept.%d [%d] tip.%d locktime %u cmp.%u\n",(int32_t)txheightarg,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)chainActive.Tip()->nHeight,(int32_t)tx.nLockTime,cmptime); + fprintf(stderr,"validateinterest accept.%d [%d] tip.%d locktime %u cmp.%u\n",(int32_t)txheightarg,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)tip != 0 ? tip->nHeight : 0,(int32_t)tx.nLockTime,cmptime); } return(0); }