From 7a90b9dd6b619b7d7bc06c209855900fb9c38fc9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 6 Feb 2017 10:16:12 +0200 Subject: [PATCH] maturity --- src/komodo_globals.h | 3 ++- src/main.cpp | 2 ++ src/qt/transactiondesc.cpp | 3 +++ src/txmempool.cpp | 3 +++ src/wallet/wallet.cpp | 3 +++ src/wallet/wallet.h | 2 +- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index afe589e21..536fc0b5b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -36,7 +36,8 @@ struct knotaries_entry *Pubkeys; struct komodo_state KOMODO_STATES[34]; -int COINBASE_MATURITY = 100; +#define _COINBASE_MATURITY 64 +int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; diff --git a/src/main.cpp b/src/main.cpp index 42dff0ffa..679524628 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1860,6 +1860,8 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons // If prev is coinbase, check that it's matured if (coins->IsCoinBase()) { + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + COINBASE_MATURITY = _COINBASE_MATURITY; if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,(int32_t)tx.vin.size()); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index d7ee3d4c7..d8a0a184b 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -264,6 +264,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco if (wtx.IsCoinBase()) { + extern char ASSETCHAINS_SYMBOL[]; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + COINBASE_MATURITY = _COINBASE_MATURITY; quint32 numBlocksToMaturity = COINBASE_MATURITY + 1; strHTML += "
" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(numBlocksToMaturity)) + "
"; } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index e9c846485..cbb36094d 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -166,6 +166,9 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list& rem void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight) { // Remove transactions spending a coinbase which are now immature + extern char ASSETCHAINS_SYMBOL[]; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + COINBASE_MATURITY = _COINBASE_MATURITY; LOCK(cs); list transactionsToRemove; for (std::map::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 80766e30b..fb53715e4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3593,6 +3593,9 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const int CMerkleTx::GetBlocksToMaturity() const { + extern char ASSETCHAINS_SYMBOL[]; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + COINBASE_MATURITY = _COINBASE_MATURITY; if (!IsCoinBase()) return 0; return max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain()); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f7531ba8f..90e3a7f0e 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -58,7 +58,7 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; //! Size of witness cache // Should be large enough that we can expect not to reorg beyond our cache // unless there is some exceptional network disruption. -static const unsigned int WITNESS_CACHE_SIZE = COINBASE_MATURITY+1; +static const unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+1; class CAccountingEntry; class CBlockIndex;