From 198286a59a2850d43e7189a9dd918169bf217b85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 14:43:24 +0200 Subject: [PATCH 1/4] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ad671896d..ab95c4aa6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -846,7 +846,7 @@ void static BitcoinMiner(CWallet *pwallet) } if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"0xffff, break\n"); break; } From e7fa1876d518e94aefe281a667aef6ad04ecb5d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 15:56:36 +0200 Subject: [PATCH 2/4] Test --- src/komodo_gateway.h | 2 +- src/main.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8e9af6a04..84ce254f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1430,7 +1430,7 @@ void komodo_passport_iteration() printf("from.(%s) lastpos[%s] %ld isrt.%d\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid],komodo_isrealtime(&ht)); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); - } else printf("error.(%s) %p\n",fname,sp); + } //else printf("error.(%s) %p\n",fname,sp); komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"rb")) != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 2233faed8..f926c71a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -716,7 +716,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) { static uint32_t counter0; prevblocktime = chainActive.Tip()->nTime; - if ( counter0++ < 100 ) + if ( counter0++ < 3 ) fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime); } if ( (int64_t)tx.nLockTime < prevblocktime-3600 ) @@ -740,14 +740,13 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int return true; if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& (int64_t)tx.nLockTime < nBlockTime-3600 ) { - if ( komodo_validate_interest(tx) < 0 ) - return(false); - /* + //if ( komodo_validate_interest(tx) < 0 ) + // return(false); if ( nBlockTime >= 1490159171 ) // 246748 { fprintf(stderr,"[%d] IsFinalTx reject.%d locktime %u vs nBlockTime %u\n",(int32_t)(tx.nLockTime-nBlockTime),(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); return(false); // need to prevent pastdating tx - } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime);*/ + } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); } if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; @@ -1137,6 +1136,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = false; auto verifier = libzcash::ProofVerifier::Strict(); + if ( komodo_validate_interest(tx) < 0 ) + { + fprintf(stderr,"komodo_validate_interest failure\n"); + return error("AcceptToMemoryPool: komodo_validate_interest failed"); + } if (!CheckTransaction(tx, state, verifier)) { fprintf(stderr,"accept failure.0\n"); From 3640e4c9b2734b932b62048341f6d38e56eac6a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 16:08:33 +0200 Subject: [PATCH 3/4] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f926c71a8..6deb2947c 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,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 72afbcf22425a56d69aa8e41b60bfb15b133d831 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 16:25:43 +0200 Subject: [PATCH 4/4] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6deb2947c..627722907 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -738,11 +738,11 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int int32_t i; if (tx.nLockTime == 0) return true; - if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& (int64_t)tx.nLockTime < nBlockTime-3600 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 ) { //if ( komodo_validate_interest(tx) < 0 ) // return(false); - if ( nBlockTime >= 1490159171 ) // 246748 + if ( nBlockTime >= 1490159171 || nBlockHeight > 246748 ) // 246748 { fprintf(stderr,"[%d] IsFinalTx reject.%d locktime %u vs nBlockTime %u\n",(int32_t)(tx.nLockTime-nBlockTime),(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); return(false); // need to prevent pastdating tx