From a3981907123a926c2001ff8fb85002b6c0e37922 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 10:44:29 +0200 Subject: [PATCH 01/16] test --- src/komodo_interest.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2814ca85b..d3e55b831 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -78,6 +78,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( nValue > 25000LL*COIN ) { exception = 0; + if ( nValue == 4000000000000LL ) + printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( txheight <= 155949 ) { if ( (txheight == 116607 && nValue == 2502721100000LL) || From fec202b542e82116ac0b12b7d544ab5187943987 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 10:44:55 +0200 Subject: [PATCH 02/16] test --- src/komodo_interest.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index d3e55b831..8009b66e0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -78,8 +78,6 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( nValue > 25000LL*COIN ) { exception = 0; - if ( nValue == 4000000000000LL ) - printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( txheight <= 155949 ) { if ( (txheight == 116607 && nValue == 2502721100000LL) || @@ -95,7 +93,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin (txheight == 155613 && nValue == 2590000000000LL) || (txheight == 155949 && nValue == 4000000000000LL) ) exception = 1; - if ( exception == 0 ) + if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } if ( exception == 0 ) From c4df506a7d2123c6d5fdecc8f750b73b458355b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 10:45:46 +0200 Subject: [PATCH 03/16] test --- src/komodo_interest.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 8009b66e0..127c14501 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -96,6 +96,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } + if ( nValue == 4000000000000LL ) + printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! From 1b345eb3d7416192bf7339013f8830efa64ca02f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 10:57:48 +0200 Subject: [PATCH 04/16] test --- src/wallet/rpcwallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9ed4f5c70..3ae1744de 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2635,11 +2635,14 @@ Value listunspent(const Array& params, bool fHelp) BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *tipindex,*pindex = it->second; uint64_t interest; - if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) + fprintf(stderr,"pindex.%p tipindex.%p\n",pindex,chainActive.Tip()); + /*if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) { interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); - } + }*/ + if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,out.nHeight,nValue)) != 0 ) + ret.push_back(Pair("interest", ValueFromAmount(interest))); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); From 23c2f1e36ef8b7ac194ed2121fe84c7aceb137ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 11:01:17 +0200 Subject: [PATCH 05/16] test --- src/wallet/rpcwallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3ae1744de..1aca3c21e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2641,8 +2641,10 @@ Value listunspent(const Array& params, bool fHelp) interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); }*/ - if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,out.nHeight,nValue)) != 0 ) + uint32_t locktime; int32_t txheight; + if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,pindex->nHeight,nValue)) != 0 ) ret.push_back(Pair("interest", ValueFromAmount(interest))); + printf("locktime.%u txheight.%d pindexht.%d\n",locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); From b02b5c03b8b868154061116ecea1bf0ebff53063 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 11:02:15 +0200 Subject: [PATCH 06/16] test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1aca3c21e..6f674ccf3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2643,7 +2643,7 @@ Value listunspent(const Array& params, bool fHelp) }*/ uint32_t locktime; int32_t txheight; if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,pindex->nHeight,nValue)) != 0 ) - ret.push_back(Pair("interest", ValueFromAmount(interest))); + entry.push_back(Pair("interest", ValueFromAmount(interest))); printf("locktime.%u txheight.%d pindexht.%d\n",locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); From d0524eb259cc943f36fee8f4a32de8e4c066aeaf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 11:08:53 +0200 Subject: [PATCH 07/16] test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6f674ccf3..dd2625e0d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2642,9 +2642,9 @@ Value listunspent(const Array& params, bool fHelp) entry.push_back(Pair("interest",ValueFromAmount(interest))); }*/ uint32_t locktime; int32_t txheight; - if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,pindex->nHeight,nValue)) != 0 ) + if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue)) != 0 ) entry.push_back(Pair("interest", ValueFromAmount(interest))); - printf("locktime.%u txheight.%d pindexht.%d\n",locktime,txheight,pindex->nHeight); + fprintf(stderr,"locktime.%u txheight.%d pindexht.%d\n",locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); From e7876b36893b20f3f7c8b6b6ac63257b42b5e271 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 11:12:51 +0200 Subject: [PATCH 08/16] test --- src/wallet/rpcwallet.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dd2625e0d..2b3c81a11 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2634,17 +2634,14 @@ Value listunspent(const Array& params, bool fHelp) { BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *tipindex,*pindex = it->second; - uint64_t interest; - fprintf(stderr,"pindex.%p tipindex.%p\n",pindex,chainActive.Tip()); - /*if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) + uint64_t interest; uint32_t locktime; int32_t txheight; + komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue); + if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) { - interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); + interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); - }*/ - uint32_t locktime; int32_t txheight; - if ( (interest= komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue)) != 0 ) - entry.push_back(Pair("interest", ValueFromAmount(interest))); - fprintf(stderr,"locktime.%u txheight.%d pindexht.%d\n",locktime,txheight,pindex->nHeight); + } + fprintf(stderr,"pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); From a2c3713eccc1e40ad000a8e9984045138d9a66be Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 11:13:10 +0200 Subject: [PATCH 09/16] test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2b3c81a11..792f2f417 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2641,7 +2641,7 @@ Value listunspent(const Array& params, bool fHelp) interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); } - fprintf(stderr,"pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); + fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); From 68c266b2ba43dc9df3b367e7ba8c9f3d10088989 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 14:46:21 +0200 Subject: [PATCH 10/16] test --- src/komodo_interest.h | 4 ++-- src/main.cpp | 49 ++++++++++++++++++++++++++++------------ src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 4 +++- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 127c14501..269a8ff6c 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -96,8 +96,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } - if ( nValue == 4000000000000LL ) - printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); + //if ( nValue == 4000000000000LL ) + // printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! diff --git a/src/main.cpp b/src/main.cpp index bda78f893..a9e4efb87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1084,7 +1084,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa *pfMissingInputs = false; auto verifier = libzcash::ProofVerifier::Strict(); if (!CheckTransaction(tx, state, verifier)) + { + fprintf(stderr,"accept failure.0\n"); return error("AcceptToMemoryPool: CheckTransaction failed"); + } // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) { @@ -1124,7 +1127,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { static uint32_t counter; // Disable replacement feature for now - if ( counter++ < 100 ) + //if ( counter++ < 100 ) fprintf(stderr,"Disable replacement feature for now\n"); return false; } @@ -1164,20 +1167,23 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveCoins(txin.prevout.hash)) { if (pfMissingInputs) *pfMissingInputs = true; - //fprintf(stderr,"missing inputs\n"); + fprintf(stderr,"missing inputs\n"); return false; } } // are the actual inputs available? if (!view.HaveInputs(tx)) - return state.Invalid(error("AcceptToMemoryPool: inputs already spent"), - REJECT_DUPLICATE, "bad-txns-inputs-spent"); - + { + fprintf(stderr,"accept failure.1\n"); + return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); + } // are the joinsplit's requirements met? if (!view.HaveJoinSplitRequirements(tx)) - return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"), - REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); + { + fprintf(stderr,"accept failure.2\n"); + return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); + } // Bring the best block into scope view.GetBestBlock(); @@ -1191,7 +1197,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Check for non-standard pay-to-script-hash in inputs if (Params().RequireStandard() && !AreInputsStandard(tx, view)) + { + fprintf(stderr,"accept failure.3\n"); return error("AcceptToMemoryPool: nonstandard transaction input"); + } // Check that the transaction doesn't have an excessive number of // sigops, making it impossible to mine. Since the coinbase transaction @@ -1201,9 +1210,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa unsigned int nSigOps = GetLegacySigOpCount(tx); nSigOps += GetP2SHSigOpCount(tx, view); if (nSigOps > MAX_STANDARD_TX_SIGOPS) - return state.DoS(0, error("AcceptToMemoryPool: too many sigops %s, %d > %d", - hash.ToString(), nSigOps, MAX_STANDARD_TX_SIGOPS), - REJECT_NONSTANDARD, "bad-txns-too-many-sigops"); + { + fprintf(stderr,"accept failure.4\n"); + return state.DoS(0, error("AcceptToMemoryPool: too many sigops %s, %d > %d", hash.ToString(), nSigOps, MAX_STANDARD_TX_SIGOPS),REJECT_NONSTANDARD, "bad-txns-too-many-sigops"); + } CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; @@ -1219,13 +1229,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Don't accept it if it can't get into a block CAmount txMinFee = GetMinRelayFee(tx, nSize, true); if (fLimitFree && nFees < txMinFee) - return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d", - hash.ToString(), nFees, txMinFee), - REJECT_INSUFFICIENTFEE, "insufficient fee"); + { + fprintf(stderr,"accept failure.5\n"); + return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",hash.ToString(), nFees, txMinFee),REJECT_INSUFFICIENTFEE, "insufficient fee"); + } } // Require that free transactions have sufficient priority to be mined in the next block. if (GetBoolArg("-relaypriority", false) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) { + fprintf(stderr,"accept failure.6\n"); return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority"); } @@ -1247,19 +1259,25 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) + { + fprintf(stderr,"accept failure.7\n"); return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); + } LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; } if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000) - return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d", - hash.ToString(), nFees, ::minRelayTxFee.GetFee(nSize) * 10000); + { + fprintf(stderr,"accept failure.8\n"); + return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",hash.ToString(), nFees, ::minRelayTxFee.GetFee(nSize) * 10000); + } // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, Params().GetConsensus())) { + fprintf(stderr,"accept failure.9\n"); return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString()); } @@ -1274,6 +1292,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // can be exploited as a DoS attack. if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, Params().GetConsensus())) { + fprintf(stderr,"accept failure.10\n"); return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString()); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 792f2f417..e68ccc9be 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2641,7 +2641,7 @@ Value listunspent(const Array& params, bool fHelp) interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); } - fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); + //fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); } entry.push_back(Pair("confirmations",out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 870f5c32c..da2ae7fad 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2789,6 +2789,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { { + fprintf(stderr,"commit start\n"); LOCK2(cs_main, cs_wallet); LogPrintf("CommitTransaction:\n%s", wtxNew.ToString()); { @@ -2825,7 +2826,8 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // Broadcast if (!wtxNew.AcceptToMemoryPool(false)) { - // This must not fail. The transaction has already been signed and recorded. + fprintf(stderr,"commit failed\n"); + // This must not fail. The transaction has already been signed and recorded. LogPrintf("CommitTransaction(): Error: Transaction not valid\n"); return false; } From 9d92c93d5ab9ce7ee13a215c1fa76ddc7707d831 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:04:09 +0200 Subject: [PATCH 11/16] test --- src/main.cpp | 6 ++++-- src/wallet/wallet.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a9e4efb87..538ca6c24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1836,6 +1836,7 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, const Consensus::Params& consensusParams, std::vector *pvChecks) { if (!NonContextualCheckInputs(tx, state, inputs, fScriptChecks, flags, cacheStore, consensusParams, pvChecks)) { + fprintf(stderr,"ContextualCheckInputs failure.0\n"); return false; } @@ -1856,9 +1857,10 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons // If prev is coinbase, check that it's matured if (coins->IsCoinBase()) { if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { + fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,tx.vin.size()); + return state.Invalid( - error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight), - REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); + error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); } } } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index da2ae7fad..aabc46f0a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2243,14 +2243,20 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const { #ifdef KOMODO_ENABLE_INTEREST extern char ASSETCHAINS_SYMBOL[16]; + uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 ) { if ( pcoin->vout[i].nValue >= 10*COIN ) { - interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime); + komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue); + if ( (tipindex= chainActive.Tip()) != 0 ) + { + interest = komodo_interest(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime); + } else interest = 0; + //interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime); if ( interest != 0 ) { - //printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime); + printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); //fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime); //ptr = (uint64_t *)&pcoin->vout[i].nValue; //(*ptr) += interest; From 6bc7804a338e7392af656165df8f3b4134dd12fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:05:36 +0200 Subject: [PATCH 12/16] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 538ca6c24..19f4fd0b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1857,7 +1857,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons // If prev is coinbase, check that it's matured if (coins->IsCoinBase()) { if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { - fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,tx.vin.size()); + fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,(int32_t)tx.vin.size()); return state.Invalid( error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); From bbf5692c93587c5129667c96dfca607b53f92df9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:07:09 +0200 Subject: [PATCH 13/16] test --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index aabc46f0a..946a4329d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2205,6 +2205,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const * populate vCoins with vector of available COutputs. */ 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); void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const { From c7aa40393ea18136b4c6b5834efc5d1f4f146388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:11:18 +0200 Subject: [PATCH 14/16] fix --- src/wallet/wallet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 946a4329d..9926d67d1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2796,7 +2796,6 @@ bool CWallet::CreateTransaction(const vector& vecSend, bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { { - fprintf(stderr,"commit start\n"); LOCK2(cs_main, cs_wallet); LogPrintf("CommitTransaction:\n%s", wtxNew.ToString()); { From 28216d3172a0f0da79c4e528fe60ecbbce8fd571 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:14:03 +0200 Subject: [PATCH 15/16] test --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9926d67d1..c5423aecf 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2257,7 +2257,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const //interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime); if ( interest != 0 ) { - printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); + //printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); //fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime); //ptr = (uint64_t *)&pcoin->vout[i].nValue; //(*ptr) += interest; From 2f60e36d1555cc4d6d74ccd8f16ad90422b62fef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Jan 2017 15:15:47 +0200 Subject: [PATCH 16/16] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 19f4fd0b4..f92e59f4c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1167,7 +1167,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveCoins(txin.prevout.hash)) { if (pfMissingInputs) *pfMissingInputs = true; - fprintf(stderr,"missing inputs\n"); + //fprintf(stderr,"missing inputs\n"); return false; } }