diff --git a/README.md b/README.md index 463c3f983..28160dd6e 100644 --- a/README.md +++ b/README.md @@ -162,3 +162,24 @@ License ------- For license information see the file [COPYING](COPYING). + + +NOTE TO EXCHANGES: +https://bitcointalk.org/index.php?topic=1605144.msg17732151#msg17732151 +There is a small chance that an outbound transaction will give an error due to mismatched values in wallet calculations. There is a -exchange option that you can run komodod with, but make sure to have the entire transaction history under the same -exchange mode. Otherwise you will get wallet conflicts. + +To change modes: +a) backup all privkeys (launch komodod with -exportdir= and dumpwallet) +b) start a totally new sync including wallet.dat, launch with same exportdir +c) stop it before it gets too far and import all the privkeys from a) using komodo-cli importwallet filename +d) resume sync till it gets to chaintip + +For example: +./komodod -exportdir=/tmp & +./komodo-cli dumpwallet example +./komodo-cli stop +mv ~/.komodo ~/.komodo.old && mkdir ~/.komodo && cp ~/.komodo.old/komodo.conf ~/.komodo.old/peers.dat ~/.komodo +./komodod -exchange -exportdir=/tmp & +./komodo-cli importwallet /tmp/example + + diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 706bde70f..e0f5f6e1a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -653,7 +653,7 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *non duplicate++; } } - if ( i == 66 && duplicate == 0 && *nonzpkeysp > 0 ) + if ( i == 66 && duplicate == 0 && (height > 186233 || *nonzpkeysp > 0) ) return(1); else return(0); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index afe589e21..833169626 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 100 +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/miner.cpp b/src/miner.cpp index f7851e75d..486251435 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -616,11 +616,12 @@ void static BitcoinMiner(CWallet *pwallet) // // Search // - uint8_t pubkeys[66][33]; int mids[66],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); + uint8_t pubkeys[66][33]; int mids[66],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { + j = 65; if ( (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight); @@ -645,19 +646,23 @@ void static BitcoinMiner(CWallet *pwallet) printf("%02x",pubkeys[i][j]); printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i])); } - for (j=0; j<65; j++) + for (j=gpucount=0; j<65; j++) + { fprintf(stderr,"%d ",mids[j]); - fprintf(stderr," <- prev minerids from ht.%d notary.%d\n",pindexPrev->nHeight,notaryid); + if ( mids[j] == -1 ) + gpucount++; + } + fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%%\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) break; - if ( j == 65 ) - { - hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); - fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); - } //else fprintf(stderr,"duplicate at j.%d\n",j); } else fprintf(stderr,"no nonz pubkeys\n"); + if ( j == 65 ) + { + hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); + fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); + } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; while (true) @@ -684,6 +689,7 @@ void static BitcoinMiner(CWallet *pwallet) crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size()); // (x_1, x_2, ...) = A(I, V, n, k) LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); + //fprintf(stderr,"running solver\n"); std::function)> validBlock = [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams] (std::vector soln) 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..e1bb80a08 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -14,6 +14,7 @@ #include "util.h" #include "utilmoneystr.h" #include "version.h" +#define _COINBASE_MATURITY 100 using namespace std; @@ -166,6 +167,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 e7034f851..419f9dec3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1639,8 +1639,7 @@ void CWalletTx::GetAmounts(list& listReceived, CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) { - LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n", - this->GetHash().ToString()); + //LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",this->GetHash().ToString()); complains on the opreturns address = CNoDestination(); } @@ -2449,7 +2448,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int LogPrint("selectcoins", "SelectCoins() best subset: "); for (unsigned int i = 0; i < vValue.size(); i++) if (vfBest[i]) - LogPrint("selectcoins", "%s ", FormatMoney(vValue[i].first)); + LogPrint("selectcoins", "%s + %s, ", FormatMoney(vValue[i].first),FormatMoney(interests[i])); LogPrint("selectcoins", "total %s\n", FormatMoney(nBest)); } @@ -2480,6 +2479,8 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; + if ( KOMODO_EXCHANGEWALLET == 0 ) + value += out.tx->vout[out.i].interest; } if (value <= nTargetValue) { CAmount valueWithCoinbase = 0; @@ -2488,12 +2489,13 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; + if ( KOMODO_EXCHANGEWALLET == 0 ) + valueWithCoinbase += out.tx->vout[out.i].interest; } fNeedCoinbaseCoinsRet = (valueWithCoinbase >= nTargetValue); } } // coin control -> return all selected outputs (we want all to go into the transaction for sure) - *interestp = 0; if (coinControl && coinControl->HasSelected()) { BOOST_FOREACH(const COutput& out, vCoins) @@ -2654,7 +2656,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, interest = 0; } CAmount nChange = (nValueIn - nValue + interest); -//fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest/COIN,(double)nTotalValue/COIN); +fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest/COIN,(double)nTotalValue/COIN); if (nSubtractFeeFromAmount == 0) nChange -= nFeeRet; @@ -3590,6 +3592,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..c790198df 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -58,7 +58,8 @@ 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; +#define _COINBASE_MATURITY 100 +static const unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+1; class CAccountingEntry; class CBlockIndex;