From 83da1e16c306b9d426188ad16dfb50d6f3084422 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:12:40 +0200 Subject: [PATCH 1/8] Test --- src/komodo_bitcoind.h | 7 ++++--- src/main.cpp | 18 +++++++++--------- src/rpcblockchain.cpp | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d575b02b1..36b16bde2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -740,7 +740,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has return(0); } -uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n) +uint32_t komodo_interest_args(uint32_t *txheighttimep,int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n) { LOCK(cs_main); CTransaction tx; uint256 hashBlock; CBlockIndex *pindex,*tipindex; @@ -753,6 +753,7 @@ uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *va { *valuep = tx.vout[n].nValue; *txheightp = pindex->nHeight; + *txheighttimep = pindex->nTime; *tiptimep = tipindex->nTime; locktime = tx.nLockTime; //fprintf(stderr,"tx locktime.%u %.8f height.%d | tiptime.%u\n",locktime,(double)*valuep/COIN,*txheightp,*tiptimep); @@ -764,8 +765,8 @@ uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *va uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue) { - uint64_t value; uint32_t tiptime; - if ( (*locktimep= komodo_interest_args(txheightp,&tiptime,&value,hash,n)) != 0 ) + uint64_t value; uint32_t tiptime,txheighttimep; + if ( (*locktimep= komodo_interest_args(&txheighttimep,txheightp,&tiptime,&value,hash,n)) != 0 ) { if ( (checkvalue == 0 || value == checkvalue) && (checkheight == 0 || *txheightp == checkheight) ) return(komodo_interest(*txheightp,value,*locktimep,tiptime)); diff --git a/src/main.cpp b/src/main.cpp index 627722907..10d0d29e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -708,26 +708,26 @@ bool IsStandardTx(const CTransaction& tx, string& reason) int32_t komodo_validate_interest(const CTransaction& tx) { - int32_t i,txheight=0; uint32_t prevblocktime=0,locktime; uint64_t value=0; + int32_t i,txheight=0; uint32_t txheighttime,tiptime=0,locktime; uint64_t value=0; if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) { - locktime = komodo_interest_args(&txheight,&prevblocktime,&value,tx.GetHash(),0); - if ( prevblocktime == 0 ) + locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); + if ( txheighttime == 0 ) { static uint32_t counter0; - prevblocktime = chainActive.Tip()->nTime; + txheighttime = tiptime; if ( counter0++ < 3 ) - fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime); + fprintf(stderr,"error getting txheighttime, set to tiptime.%u\n",tiptime); } - if ( (int64_t)tx.nLockTime < prevblocktime-3600 ) + if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { - if ( prevblocktime > 1490159171 || (txheight == 0 && prevblocktime >= 1490159171) ) // 246748 + if ( txheighttime > 1490159171 || (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { static uint32_t counter; if ( counter++ < 100 ) - fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u prevblocktime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,prevblocktime); + fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime); return(-1); - } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)txheight,tx.nLockTime,(uint32_t)prevblocktime); + } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs nBlockTime %u txheighttime.%u\n",(int32_t)txheight,tx.nLockTime,(uint32_t)prevblocktime,txheighttime); } } return(0); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 70456a63f..b1fa9d3d5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -406,7 +406,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); +//uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n); int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); From eab04ab9c820e8fb080991c19075c4d6f8833139 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:15:35 +0200 Subject: [PATCH 2/8] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 10d0d29e1..d893a897c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -727,7 +727,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) if ( counter++ < 100 ) fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime); return(-1); - } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs nBlockTime %u txheighttime.%u\n",(int32_t)txheight,tx.nLockTime,(uint32_t)prevblocktime,txheighttime); + } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime); } } return(0); From 63c93b0c0e26907de07087f66d1f7529004c7f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:20:30 +0200 Subject: [PATCH 3/8] Test --- src/komodo_bitcoind.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 36b16bde2..481ede104 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -744,6 +744,8 @@ uint32_t komodo_interest_args(uint32_t *txheighttimep,int32_t *txheightp,uint32_ { LOCK(cs_main); CTransaction tx; uint256 hashBlock; CBlockIndex *pindex,*tipindex; + *txheighttimep = *txheightp = *tiptimep = 0; + *valuep = 0; if ( !GetTransaction(hash,tx,hashBlock,true) ) return(0); uint32_t locktime = 0; From 36f4d2cdc6bf4a77956697ec15e541ff7828ddc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:25:32 +0200 Subject: [PATCH 4/8] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d893a897c..3f944a3bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -715,9 +715,9 @@ int32_t komodo_validate_interest(const CTransaction& tx) if ( txheighttime == 0 ) { static uint32_t counter0; - txheighttime = tiptime; + txheighttime = chainActive.Tip()->nTime; if ( counter0++ < 3 ) - fprintf(stderr,"error getting txheighttime, set to tiptime.%u\n",tiptime); + fprintf(stderr,"error getting txheighttime, set to tiptime.%u\n",txheighttime); } if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { From 89e99094aafca9ee6191d19441e3040c2b5dfaa8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:29:04 +0200 Subject: [PATCH 5/8] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3f944a3bc..f8a32e000 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -898,8 +898,8 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - if ( komodo_validate_interest(tx) < 0 ) - return(false); + //if ( komodo_validate_interest(tx) < 0 ) + // return(false); n = tx.vin.size(); for (j=0; jGetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } From ff51a18d9ac97167df78845f2fb56e54f23bf2a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 17:38:04 +0200 Subject: [PATCH 6/8] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f8a32e000..6bf802ef8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -898,8 +898,8 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: static uint256 array[15]; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); - //if ( komodo_validate_interest(tx) < 0 ) - // return(false); + if ( komodo_validate_interest(tx) < 0 ) + return(false); n = tx.vin.size(); for (j=0; j Date: Wed, 22 Mar 2017 17:42:45 +0200 Subject: [PATCH 7/8] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6bf802ef8..3f944a3bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3320,7 +3320,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } From 3750f5afb810088a52f57e0ca3965c4f9b895d60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 18:00:08 +0200 Subject: [PATCH 8/8] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 84ce254f3..14ad70405 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -717,8 +717,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above extern int32_t KOMODO_REWIND; if ( KOMODO_REWIND < 0 ) { - fprintf(stderr,"rewind.%d\n",KOMODO_REWIND); - sleep(3); + fprintf(stderr,">>>>>>> rewind.%d will pause here for a minute. issue command and stop\n",KOMODO_REWIND); + sleep(60); KOMODO_REWIND = 0; } // 6a35506c65617365206d616b6520796f75722047697420636f6d6d6974206d65737361676573206d6f726520696e74657265737469 height.241778 checkdeposit n.4 [6a] [P] 80 vs 88