From 38215324fe75fb4b9ae97e2ddbbc52408ae4e120 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 6 May 2018 20:08:56 +0300 Subject: [PATCH 01/52] Skip interest check for AC --- src/txmempool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index dd985f500..5fa19fb5f 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -413,7 +413,7 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight) { const CTransaction& tx = it->GetTx(); tipindex = chainActive.Tip(); - if (IsExpiredTx(tx, nBlockHeight) || (tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0) + if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0) { transactionsToRemove.push_back(tx); } From f839d3f52eda30d63b1a6161e601d88d6d24be19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:07:44 +0300 Subject: [PATCH 02/52] Fix --- src/txmempool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 5fa19fb5f..7a5110aa8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -402,6 +402,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list } int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); +extern char ASSETCHAINS_SYMBOL[]; void CTxMemPool::removeExpired(unsigned int nBlockHeight) { From 496f1fd267f31640680b2e5c2d8faeca5611d849 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:57:43 +0300 Subject: [PATCH 03/52] Test --- src/miner.cpp | 18 ++++++++--- src/wallet/rpcwallet.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index a62f39846..e7062270a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,6 +121,7 @@ int32_t komodo_baseid(char *origbase); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); uint64_t komodo_commission(const CBlock *block); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); +int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { @@ -478,12 +479,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } pblock->nSolution.clear(); pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) { - pblock->nTime = pindexPrev->nTime + 65; - //while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) - // sleep(1); - //fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60)); + CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); + if ( pblock->nTime < pindexPrev->nTime+60 ) + pblock->nTime = pindexPrev->nTime + 65; + if ( (siglen= komodo_notaryvin(txNotary,NOTARY_PUBKEY33)) > 0 ) + { + CAmount txfees = 0; + pblock->vtx.push_back(txNotary); + pblocktemplate->vTxFees.push_back(txfees); + pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); + nFees += txfees; + } } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 627ffe550..0ea12f63b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4465,6 +4465,74 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); extern std::string NOTARY_PUBKEY; uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 hash,int32_t n,uint32_t blocktime,uint32_t prevtime,char *destaddr); +int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) +{ + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + assert(pwalletMain != NULL); + LOCK2(cs_main, pwalletMain->cs_wallet); + utxovalue = 0; + memset(&utxotxid,0,sizeof(utxotxid)); + memset(&utxovout,0,sizeof(utxovout)); + memset(utxosig,0,sizeof(utxosig)); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + continue; + if ( setAddress.size() ) + { + CTxDestination address; + if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + continue; + if (!setAddress.count(address)) + continue; + } + CAmount nValue = out.tx->vout[out.i].nValue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + CTxDestination address; + if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + { + //entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); + //if (pwalletMain->mapAddressBook.count(address)) + // entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); + } + script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data(); + if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 ) + continue; + utxovalue = (uint64_t)nValue; + decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxovout = out.i; + + bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; + auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + const CKeyStore& keystore = *pwalletMain; + txNew.vin.resize(1); + txNew.vout.resize(1); + txfee = 0; + for (i=0; i<32; i++) + ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; + txNew.vin[0].prevout.n = utxovout; + txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = utxovalue - txfee; + CTransaction txNewConst(txNew); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + if (!signSuccess) + fprintf(stderr,"notaryvin failed to create signature\n"); + else + { + UpdateTransaction(txNew,0,sigdata); + ptr = (uint8_t *)sigdata.scriptSig.data(); + siglen = sigdata.scriptSig.size(); + for (i=0; i setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; From a893e994999d2dee18802d7e158d192deedb179a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:59:44 +0300 Subject: [PATCH 04/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e7062270a..6063e2ea0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -484,7 +484,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) pblock->nTime = pindexPrev->nTime + 65; - if ( (siglen= komodo_notaryvin(txNotary,NOTARY_PUBKEY33)) > 0 ) + if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; pblock->vtx.push_back(txNotary); From 469e1de39f5dd8cdcc3c3b275efb38a3fa937e96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:04:18 +0300 Subject: [PATCH 05/52] 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 0ea12f63b..9abf741ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4468,7 +4468,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; - bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS, &fNegative, &fOverflow); assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; From f8fb4922dafa66ba988ae7c76f216f13df7bb860 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:14:12 +0300 Subject: [PATCH 06/52] Test --- src/miner.cpp | 3 ++- src/wallet/rpcwallet.cpp | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6063e2ea0..e113571dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - } + fprintf(stderr,"add notaryvin\n"); + } else fprintf(stderr,"error adding notaryvin\n"); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9abf741ff..fef435f1e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,8 +4467,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS, &fNegative, &fOverflow); + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; From 39fefa6be968ca9da5a87e4171a4151cb3184837 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:34:20 +0300 Subject: [PATCH 07/52] 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 fef435f1e..f08368ba8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4488,6 +4488,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } CAmount nValue = out.tx->vout[out.i].nValue; + if ( nValue != 10000 ) + continue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; CTxDestination address; if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) @@ -4508,7 +4510,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); - txfee = 0; + txfee = utxovalue / 2;; for (i=0; i<32; i++) ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = revtxid; From c4eb1abbfcd68204d673dbb607686e36bbfcd3bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:12:34 +0300 Subject: [PATCH 08/52] Test --- src/wallet/rpcwallet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f08368ba8..e4a4f71e9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4500,10 +4500,14 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) } script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data(); if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 ) + { + fprintf(stderr,"scriptsize.%d [0] %02x\n",(int32_t)out.tx->vout[out.i].scriptPubKey.size(),script[0]); continue; + } utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; + fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue) bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 0b18f1230c928223382963266c6c17c42028c821 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:16:20 +0300 Subject: [PATCH 09/52] 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 e4a4f71e9..7b2ebe31b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4507,7 +4507,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; - fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue) + fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From ff1ee86e6ad9c22868cbff6a1ca525cc0101085a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:31:23 +0300 Subject: [PATCH 10/52] Test --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7b2ebe31b..499484b01 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4507,6 +4507,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; + best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; @@ -4533,6 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) for (i=0; i Date: Mon, 7 May 2018 15:47:18 +0300 Subject: [PATCH 11/52] test --- src/coins.cpp | 1 + src/komodo_gateway.h | 13 ++++++++++--- src/main.cpp | 3 ++- src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 15 ++++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index bb40af9cc..ba55d174e 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -462,6 +462,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = AccessCoins(prevout.hash); if (!coins || !coins->IsAvailable(prevout.n)) { + fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str()); return false; } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7eb5d9ab8..dcb5d2483 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -683,18 +683,21 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } n = block.vtx[0].vout.size(); - script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); + //script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,prevtotal = 0; int32_t overflow = 0; + int64_t val,strangeout=0,prevtotal = 0; int32_t overflow = 0; total = 0; for (i=1; i= MAX_MONEY ) { overflow = 1; break; } + if ( script[0] != 0x6a && val == 0 ) + strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) { @@ -719,10 +722,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } + if ( height > 800000 && strangeout != 0 ) + { + fprintf(stderr,"ht.%d strangout.%d\n",height,strangeout); + } } else { - if ( overflow != 0 || total > 0 ) + if ( overflow != 0 || total > 0 || strangeout != 0 ) return(-1); } return(0); diff --git a/src/main.cpp b/src/main.cpp index 511a7413c..cdb0b3f3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2684,9 +2684,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!tx.IsCoinBase()) { if (!view.HaveInputs(tx)) + { return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); - + } // are the JoinSplit's requirements met? if (!view.HaveJoinSplitRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), diff --git a/src/miner.cpp b/src/miner.cpp index e113571dd..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - fprintf(stderr,"add notaryvin\n"); + //fprintf(stderr,"add notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 499484b01..673cca17a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4505,10 +4505,11 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); + //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); @@ -4516,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; + //for (i=0; i<32; i++) + // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; @@ -4532,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 15:51:39 +0300 Subject: [PATCH 12/52] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dcb5d2483..e7048fd1f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -686,7 +686,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim //script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,strangeout=0,prevtotal = 0; int32_t overflow = 0; + int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; total = 0; for (i=1; i Date: Mon, 7 May 2018 15:53:05 +0300 Subject: [PATCH 13/52] Test --- src/coins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coins.cpp b/src/coins.cpp index ba55d174e..42939ccac 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -462,7 +462,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = AccessCoins(prevout.hash); if (!coins || !coins->IsAvailable(prevout.n)) { - fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str()); + fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str(),prevout.n); return false; } } From 05f8c237675b028acaa94ba64af7cbf292be4706 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:07:04 +0300 Subject: [PATCH 14/52] Test --- src/komodo_events.h | 2 +- src/miner.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 53e72ae95..d3eab4902 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -48,7 +48,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig } else if ( strcmp(symbol,coin) == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 && verified != 0 ) + if ( 0 && NOTARY_PUBKEY33[0] != 0 && verified != 0 ) fprintf(stderr,"validated [%s] ht.%d notarized %d\n",coin,height,notarizedheight); memset(&N,0,sizeof(N)); N.blockhash = notarized_hash; diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..5c99f9537 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -893,6 +893,7 @@ void static BitcoinMiner() } else fprintf(stderr,"no nonz pubkeys\n"); if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) ) { + pblock->nBits = KOMODO_MINDIFF_NBITS; 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); From d6e4204114e2b8b4e8bdc68ffc91d276bebc07ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:10:45 +0300 Subject: [PATCH 15/52] Test --- src/miner.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5c99f9537..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -893,7 +893,6 @@ void static BitcoinMiner() } else fprintf(stderr,"no nonz pubkeys\n"); if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) ) { - pblock->nBits = KOMODO_MINDIFF_NBITS; 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); From 5ea06d80dee8a5d405c8d97730e37b3c85529d4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:11:07 +0300 Subject: [PATCH 16/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..0899f4396 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + pblock->nTime = pindexPrev->nTime + 65/2; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From 79e1814e1ce4311a4293281b70283ef66bd8530c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:11:30 +0300 Subject: [PATCH 17/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0899f4396..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65/2; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From bce6dbb37cba42550528b76ea95f3a2c03496e43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:20:13 +0300 Subject: [PATCH 18/52] Test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index bd2410616..817dcc1fe 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -202,7 +202,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int fprintf(stderr," hash vs "); for (i=31; i>=0; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," ht.%d special.%d notaryid.%d mod.%d error\n",height,special,notaryid,(height % 35)); + fprintf(stderr," ht.%d special.%d special2.%d flag.%d notaryid.%d mod.%d error\n",height,special,special2,flag,notaryid,(height % 35)); for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); fprintf(stderr," <- pubkey\n"); From ff2277af4e685bf8b41c9093d11831792d58c9a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:25:44 +0300 Subject: [PATCH 19/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..0899f4396 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + pblock->nTime = pindexPrev->nTime + 65/2; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From f4eece4ae1d90343fb2264f65022c04b7f634069 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:26:03 +0300 Subject: [PATCH 20/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0899f4396..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65/2; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From e6a3570c42061be10166275e0f6ad8fbfe14d9e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:48:04 +0300 Subject: [PATCH 21/52] Test --- src/wallet/rpcwallet.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 673cca17a..8d1f0386e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4505,8 +4505,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); - utxotxid = out.tx->GetHash(); + decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); @@ -4517,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - //for (i=0; i<32; i++) - // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = utxotxid; //revtxid; + for (i=0; i<32; i++) + ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; From 6d04359865351b51983a757e842c4485a08cacf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:00:35 +0300 Subject: [PATCH 22/52] 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 8d1f0386e..fca98ef53 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:07:38 +0300 Subject: [PATCH 23/52] Test --- src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..07f5081e4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - //fprintf(stderr,"add notaryvin\n"); + fprintf(stderr,"added notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fca98ef53..c39b24b0b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4509,7 +4509,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); + fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 0eb15e9463cc7ef0a158909133ad1979fb4e75d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:08:28 +0300 Subject: [PATCH 24/52] 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 c39b24b0b..730d592cf 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4509,7 +4509,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.c_str(),utxovout,(long long)utxovalue); + fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 1500012776d73a4c13382bcac2c0c37442697f03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:13:49 +0300 Subject: [PATCH 25/52] Test --- src/wallet/rpcwallet.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 730d592cf..58c19f4cd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,7 +4467,10 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid,revtxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; + auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; @@ -4505,15 +4508,12 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); - //utxotxid = out.tx->GetHash(); + //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); + //fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); - bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; - auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; @@ -4534,7 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:26:20 +0300 Subject: [PATCH 26/52] Test --- src/wallet/rpcwallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 58c19f4cd..8894cefe5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4517,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; + //for (i=0; i<32; i++) + // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; @@ -4534,7 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:39:01 +0300 Subject: [PATCH 27/52] Test --- src/komodo_gateway.h | 6 +++--- src/miner.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e7048fd1f..5a660ab33 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -696,7 +696,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim overflow = 1; break; } - if ( script[0] != 0x6a && val == 0 ) + if ( script[0] != 0x6a && val < 5000 ) strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) @@ -722,9 +722,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } - if ( height > 800000 && strangeout != 0 ) + if ( strangeout != 0 ) { - fprintf(stderr,"ht.%d strangout.%d\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); } } else diff --git a/src/miner.cpp b/src/miner.cpp index 07f5081e4..eda55daa3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -482,8 +482,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + if ( pblock->nTime < pindexPrev->nTime+65 ) + pblock->nTime = pindexPrev->nTime + 58;//65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - fprintf(stderr,"added notaryvin\n"); + //fprintf(stderr,"added notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8894cefe5..53ae9ddd7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,7 +4467,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid,revtxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); const CKeyStore& keystore = *pwalletMain; @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:39:31 +0300 Subject: [PATCH 28/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index eda55daa3..466968e1b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+65 ) - pblock->nTime = pindexPrev->nTime + 58;//65; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From 56c6c06b3980d26aa428c3c538a4c42ea5c1d0e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:48:32 +0300 Subject: [PATCH 29/52] Test --- src/komodo_gateway.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5a660ab33..e190b3986 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -696,7 +696,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim overflow = 1; break; } - if ( script[0] != 0x6a && val < 5000 ) + if ( i > 1 && script[0] != 0x6a && val < 5000 ) strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53ae9ddd7..47d8010c9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 19:08:15 +0300 Subject: [PATCH 30/52] Test --- src/miner.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 466968e1b..aed085639 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,7 +492,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; //fprintf(stderr,"added notaryvin\n"); - } else fprintf(stderr,"error adding notaryvin\n"); + } + else + { + fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); + return(0); + } } else { From db4b45a62b8e68b6cc9f0e09b87e775ab915fd7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 19:08:49 +0300 Subject: [PATCH 31/52] 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 47d8010c9..53ae9ddd7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 19:14:54 +0300 Subject: [PATCH 32/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index aed085639..f94ff1d04 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -309,7 +309,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize) + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx { //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; From 97d58e8c23400e51a1354cbf64518f78383f08f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 20:41:56 +0300 Subject: [PATCH 33/52] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e190b3986..238447a42 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -724,7 +724,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } if ( strangeout != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); } } else From 6ff3cabc314232f30addf6dbbde08a1f7d5d482a Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:50:42 +0100 Subject: [PATCH 34/52] removed VOTE2018 --- src/assetchains | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 517687097..b54987942 100755 --- a/src/assetchains +++ b/src/assetchains @@ -47,7 +47,6 @@ komodo_asset MNZ 257142858 komodo_asset AXO 200000000 komodo_asset ETOMIC 100000000 komodo_asset BTCH 20998641 -komodo_asset VOTE2018 600000000 komodo_asset PIZZA 100000000 komodo_asset BEER 100000000 komodo_asset NINJA 100000000 From b79d1ecda5e35daa08c00e53cf1cd95028b155eb Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:52:13 +0100 Subject: [PATCH 35/52] removed VOTE2018 --- src/assetchains.old | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index c025e0430..d41b64766 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -24,7 +24,6 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=VOTE2018 -ac_supply=600000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & From 872338fa62f10bd4c664405736c75e675ce69014 Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:53:50 +0100 Subject: [PATCH 36/52] removed VOTE2018 --- src/assetchains_stop | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains_stop b/src/assetchains_stop index 29e1ab325..ba314e1c9 100644 --- a/src/assetchains_stop +++ b/src/assetchains_stop @@ -30,7 +30,6 @@ komodo_stop MNZ komodo_stop AXO komodo_stop ETOMIC komodo_stop BTCH -komodo_stop VOTE2018 komodo_stop PIZZA komodo_stop BEER komodo_stop NINJA From 3611134826b08ded4aec2a15a3e602a3451fa64c Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:54:50 +0100 Subject: [PATCH 37/52] delete vote2018 --- src/fiat/vote2018 | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 src/fiat/vote2018 diff --git a/src/fiat/vote2018 b/src/fiat/vote2018 deleted file mode 100755 index 4e385d76f..000000000 --- a/src/fiat/vote2018 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6 From 9e44b3ce6f37a31f211068c9ceb7935fc8139edb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:01:57 +0300 Subject: [PATCH 38/52] Test --- src/komodo_gateway.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 238447a42..e51d0a115 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txid,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -680,6 +680,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } } + if ( i == 0 ) + { + txid = block.vtx[txn_count-1].vin[0].prevout.hash; + if ( GetTransaction(txid,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) + notmatched = 1; + } } } n = block.vtx[0].vout.size(); @@ -722,9 +728,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } - if ( strangeout != 0 ) + if ( strangeout != 0 || notmatched != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); } } else From dd249664314b576aa78bb25415b8388a206287e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:07:05 +0300 Subject: [PATCH 39/52] Test --- src/komodo_gateway.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e51d0a115..b91e4af86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txid,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -668,6 +668,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i Date: Tue, 8 May 2018 12:07:29 +0300 Subject: [PATCH 40/52] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b91e4af86..27cee3a23 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -670,7 +670,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( i == 0 ) { - if ( block.vtx[txn_count-1].vin.size() == 1 && block.vtx[txn_count-1].vout.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) + if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) notmatched = 1; } n = block.vtx[i].vin.size(); From 51f0e5008de36c8a9016cda45ff20d3cf10d4fec Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:17:48 +0300 Subject: [PATCH 41/52] Test --- src/komodo_gateway.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 27cee3a23..6660a4932 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -730,6 +730,16 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( strangeout != 0 || notmatched != 0 ) { fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + if ( height > 1000000 && strangeout != 0 ) + return(-1); + } + else + { + script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); + n = komodo_electednotary(&num,script+1,height,0); + fprintf(stderr,">>>>>>>>>>>>> matched ht.%d notmatched.%d n.%d <<<<<<<<<\n",height,notmatched,n); + if ( height > 1000000 ) + return(-1 * (n >= 0)); } } else From 9c72a5cbb77fdb4e2f4e35db97519c807e7cbabb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:23:58 +0300 Subject: [PATCH 42/52] Test --- src/komodo_gateway.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6660a4932..18dabfb1d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -729,17 +729,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } if ( strangeout != 0 || notmatched != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + if ( strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); if ( height > 1000000 && strangeout != 0 ) return(-1); } else { script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); - n = komodo_electednotary(&num,script+1,height,0); - fprintf(stderr,">>>>>>>>>>>>> matched ht.%d notmatched.%d n.%d <<<<<<<<<\n",height,notmatched,n); - if ( height > 1000000 ) - return(-1 * (n >= 0)); + return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); } } else From 99e304630768bb9aa7203928eb5a53fc6758644e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:02:57 +0300 Subject: [PATCH 43/52] Test --- src/miner.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f94ff1d04..6d0b29b33 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -984,22 +984,11 @@ void static BitcoinMiner() } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) - { - MilliSleep((rand() % 2700) + 1000); - } - /*if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) + if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) { - //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+roundrobin_delay-time(NULL))); - //int32_t nseconds = Mining_start+roundrobin_delay-time(NULL); - //if ( nseconds > 0 ) - // sleep(nseconds); - MilliSleep((rand() % 1700) + 1); + if ( (i= ((Mining_height + notaryid) % 64) / 8) > 0 ) + MilliSleep((rand() % (i * 1000)) + 500); } - else if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - sleep(rand() % 30); - }*/ } else { From 26810a265b43af78699edf351afb6aa34c789c77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:03:43 +0300 Subject: [PATCH 44/52] Test --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6d0b29b33..de6024caf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -986,8 +986,9 @@ void static BitcoinMiner() { if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) { - if ( (i= ((Mining_height + notaryid) % 64) / 8) > 0 ) - MilliSleep((rand() % (i * 1000)) + 500); + int32_t r; + if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) + MilliSleep((rand() % (r * 1000)) + 500); } } else From 596b05baf216a0aface873c8be011030419b2ff2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:05:21 +0300 Subject: [PATCH 45/52] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index de6024caf..2632e71dc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -972,7 +972,7 @@ void static BitcoinMiner() if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); - while ( GetAdjustedTime() < B.nTime ) + while ( GetAdjustedTime() < B.nTime-2 ) { sleep(1); if ( chainActive.Tip()->nHeight >= Mining_height ) @@ -988,7 +988,7 @@ void static BitcoinMiner() { int32_t r; if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) - MilliSleep((rand() % (r * 1000)) + 500); + MilliSleep((rand() % (r * 1000)) + 1000); } } else From bed8cd1f4978e5241bcaee85d878567ede481f61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:38:51 +0300 Subject: [PATCH 46/52] Test --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 3 ++- src/wallet/rpcwallet.cpp | 14 +------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2174a8d80..8ca20d329 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1084,12 +1084,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh { CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; txtime = komodo_txtime(&value,txid,vout,address); + if ( blocktime < prevtime+57 ) + blocktime = prevtime+57; if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) return(0); if ( (minage= nHeight*3) > 6000 ) minage = 6000; - if ( blocktime < prevtime+57 ) - blocktime = prevtime+57; if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) { vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); diff --git a/src/miner.cpp b/src/miner.cpp index 2632e71dc..1fe8c511e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -419,7 +419,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + printf("PoS ht.%d t%u\n",(int32_t)pblock->nHeight,blocktime); + if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53ae9ddd7..702466c74 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4574,23 +4574,11 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt //if (pwalletMain->mapAddressBook.count(address)) // entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); } - /*entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end()))); - if (pk.IsPayToScriptHash()) - { - CTxDestination address; - if (ExtractDestination(pk, address)) { - const CScriptID& hash = boost::get(address); - CScript redeemScript; - if (pwalletMain->GetCScript(hash, redeemScript)) - entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); - } - } - entry.push_back(Pair("amount",ValueFromAmount(nValue)));*/ //BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *tipindex; if ( (tipindex= chainActive.Tip()) != 0 ) { - eligible = komodo_stake(0,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,*blocktimep,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()); + eligible = komodo_stake(0,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,0,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()); if ( eligible > 0 ) { if ( eligible != komodo_stake(1,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,eligible,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()) ) From 9703f8a03d894ee8af0d1d565d398c6915aa7d40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:43:08 +0300 Subject: [PATCH 47/52] Test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1fe8c511e..c2ba5e78e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -419,8 +419,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - printf("PoS ht.%d t%u\n",(int32_t)pblock->nHeight,blocktime); - if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); + if ( 0 && GetAdjustedTime() < pblock->nTime ) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -985,10 +985,10 @@ void static BitcoinMiner() } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { int32_t r; - if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) + if ( (r= ((Mining_height + NOTARY_PUBKEY33[16]) % 64) / 8) > 0 ) MilliSleep((rand() % (r * 1000)) + 1000); } } From ba1587fd3772dd50e3fee95a760e1df513d334a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:55:16 +0300 Subject: [PATCH 48/52] Test --- src/miner.cpp | 2 ++ src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c2ba5e78e..a33085820 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,6 +414,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; + if ( GetAdjustedTime() < pblock->nTime-30 ) + return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 702466c74..4cc79cfdb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4625,7 +4625,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i Date: Tue, 8 May 2018 19:00:21 +0300 Subject: [PATCH 49/52] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a33085820..9c84f5f28 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,7 +414,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; - if ( GetAdjustedTime() < pblock->nTime-30 ) + if ( GetAdjustedTime() < blocktime-30 ) return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); From de230f5e7579d59480440e73e5adf89697b4f1da Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 19:05:38 +0300 Subject: [PATCH 50/52] Test --- src/miner.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9c84f5f28..264a6e2d4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,25 +414,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; - if ( GetAdjustedTime() < blocktime-30 ) + if ( GetAdjustedTime() < blocktime-13 ) return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); - if ( 0 && GetAdjustedTime() < pblock->nTime ) - { - fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( GetAdjustedTime()+30 < pblock->nTime ) - { - sleep(30); - fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); - } - fprintf(stderr,"finished waiting\n"); - //sleep(pblock->nTime - GetAdjustedTime()); - } + //printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } From 0afe191c041089f1dfc6cff7ef1115d7394e2405 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 19:11:58 +0300 Subject: [PATCH 51/52] Test --- src/komodo_gateway.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 18dabfb1d..c6441977c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -743,7 +743,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { if ( overflow != 0 || total > 0 || strangeout != 0 ) + { + if ( strangeout != 0 ) + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); return(-1); + } } return(0); } From 58d3618754005afc3ed81095cb7d6278e82578bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 20:18:34 +0300 Subject: [PATCH 52/52] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c6441977c..8daa0d32a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -734,7 +734,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > 1000000 && strangeout != 0 ) return(-1); } - else + else if ( height > 814000 ) { script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000));