@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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<bool(std::vector<unsigned char>)> validBlock =
|
||||
[&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams]
|
||||
(std::vector<unsigned char> soln)
|
||||
|
||||
@@ -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 += "<br>" + 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)) + "<br>";
|
||||
}
|
||||
|
||||
@@ -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<CTransaction>& 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<CTransaction> transactionsToRemove;
|
||||
for (std::map<uint256, CTxMemPoolEntry>::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
|
||||
|
||||
@@ -1639,8 +1639,7 @@ void CWalletTx::GetAmounts(list<COutputEntry>& 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, set<pair<const CWalletTx*
|
||||
continue;
|
||||
}
|
||||
value += out.tx->vout[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, set<pair<const CWalletTx*
|
||||
continue;
|
||||
}
|
||||
valueWithCoinbase += out.tx->vout[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<CRecipient>& 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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user