From b81701543b7f91c90c8b3c7388576602596d949c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 05:41:03 -1100 Subject: [PATCH 01/23] Increase size of KMD/BTCUSERPASS[] to avoid overflow --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 342d28fe8..947b84671 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -58,7 +58,7 @@ uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; -char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; +char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; uint64_t PENDING_KOMODO_TX; extern int32_t KOMODO_LOADINGBLOCKS; unsigned int MAX_BLOCK_SIGOPS = 20000; From 4d0683677d8fadb23272101c69886529a7c192ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 21:37:47 -1100 Subject: [PATCH 02/23] fix staking destination, enable staking with genproclimit=0, enable cross chain notarization checks for notary nodes --- src/komodo.h | 10 +++++----- src/komodo_events.h | 6 +++--- src/komodo_globals.h | 2 +- src/komodo_utils.h | 10 ++++++++++ src/main.cpp | 4 ++-- src/miner.cpp | 36 ++++++++++++++---------------------- src/wallet/rpcwallet.cpp | 2 +- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 690e91248..ae0898ed3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -538,7 +538,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr return(-1); if ( scriptlen == 35 && scriptbuf[0] == 33 && scriptbuf[34] == 0xac ) { - if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 && NOTARY_PUBKEY33[0] != 0 ) + if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 && IS_KOMODO_NOTARY != 0 ) { printf("%s KOMODO_LASTMINED.%d -> %d\n",ASSETCHAINS_SYMBOL,KOMODO_LASTMINED,height); prevKOMODO_LASTMINED = KOMODO_LASTMINED; @@ -879,7 +879,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } notarized = 1; } - if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("(tx.%d: ",i); for (j=0; j= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) @@ -916,7 +916,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf(") "); if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification); @@ -959,7 +959,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%s ht.%d\n",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL,height); if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0); diff --git a/src/komodo_events.h b/src/komodo_events.h index d3eab4902..d4ea17ce5 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -41,14 +41,14 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 814000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + if ( IS_KOMODO_NOTARY != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 814000 && counter++ < 10 ) + if ( counter++ < 100 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); } else if ( strcmp(symbol,coin) == 0 ) { - if ( 0 && NOTARY_PUBKEY33[0] != 0 && verified != 0 ) + if ( 0 && IS_KOMODO_NOTARY != 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/komodo_globals.h b/src/komodo_globals.h index 342d28fe8..947b84671 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -58,7 +58,7 @@ uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; -char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; +char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; uint64_t PENDING_KOMODO_TX; extern int32_t KOMODO_LOADINGBLOCKS; unsigned int MAX_BLOCK_SIGOPS = 20000; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 119c4d6f4..40dabd4e5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1510,6 +1510,16 @@ void komodo_args(char *argv0) if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { USE_EXTERNAL_PUBKEY = 1; + if ( IS_KOMODO_NOTARY == 0 ) + { + for (i=0; inHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward),dstr(sum)); } if (!control.Wait()) @@ -6110,7 +6110,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->PushMessage("headers", vHeaders); } - /*else if ( NOTARY_PUBKEY33[0] != 0 ) + /*else if ( IS_KOMODO_NOTARY != 0 ) { static uint32_t counter; if ( counter++ < 3 ) diff --git a/src/miner.cpp b/src/miner.cpp index 6008fd5d9..257627b47 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0 ) { uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid,revtxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); @@ -475,14 +475,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashReserved = uint256(); - if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || NOTARY_PUBKEY33[0] == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || GetArg("-genproclimit", 0) > 0 ) { UpdateTime(pblock, Params().GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); } pblock->nSolution.clear(); pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && My_notaryid >= 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) { uint32_t r; CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); @@ -875,7 +875,7 @@ void static BitcoinMiner() if ( i == 33 ) externalflag = 1; else externalflag = 0; - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( IS_KOMODO_NOTARY != 0 ) { for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) @@ -909,7 +909,7 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - if ( ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] == 0 ) + if ( ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0 ) { int32_t percPoS,z; /*if ( Mining_height <= 100 ) @@ -947,7 +947,7 @@ void static BitcoinMiner() // (x_1, x_2, ...) = A(I, V, n, k) LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; - if ( NOTARY_PUBKEY33[0] == 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) + if ( GetArg("-genproclimit", 0) > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; std::function)> validBlock = @@ -975,7 +975,7 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( h > hashTarget ) return false; - if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) + if ( B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime-2 ) @@ -990,7 +990,7 @@ void static BitcoinMiner() } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( IS_KOMODO_NOTARY != 0 ) { int32_t r; if ( (r= ((Mining_height + NOTARY_PUBKEY33[16]) % 64) / 8) > 0 ) @@ -999,18 +999,12 @@ void static BitcoinMiner() } else { - if ( NOTARY_PUBKEY33[0] != 0 ) - { - while ( GetAdjustedTime() < B.nTime ) - sleep(1); - } - else - { - uint256 tmp = B.GetHash(); - int32_t z; for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&tmp)[z]); - fprintf(stderr," mined block!\n"); - } + while ( GetAdjustedTime() < B.nTime ) + sleep(1); + uint256 tmp = B.GetHash(); + int32_t z; for (z=31; z>=0; z--) + fprintf(stderr,"%02x",((uint8_t *)&tmp)[z]); + fprintf(stderr," mined block!\n"); } CValidationState state; if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) @@ -1043,8 +1037,6 @@ void static BitcoinMiner() ehSolverRuns.increment(); throw boost::thread_interrupted(); } - //if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) - // sleep(1800); return true; }; std::function cancelled = [&m_cs, &cancelSolver](EhSolverCancelCheck pos) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bbbc9d897..255f74a19 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4652,7 +4652,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt ((uint8_t *)&revtxid)[i] = ((uint8_t *)utxotxidp)[31 - i]; txNew.vin[0].prevout.hash = revtxid; txNew.vin[0].prevout.n = *utxovoutp; - txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].scriptPubKey = best_scriptPubKey;// CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = *utxovaluep - txfee; txNew.nLockTime = earliest; CTransaction txNewConst(txNew); From 626179f166b8aa7789ac6fc98cadd69ec9e7ad3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 21:46:16 -1100 Subject: [PATCH 03/23] -ac_public -> disable z transactions if you want to prevent privacy --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 5 +++-- src/main.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 947b84671..cd476830f 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -48,7 +48,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 40dabd4e5..181d07989 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,6 +1538,7 @@ void komodo_args(char *argv0) } } ASSETCHAINS_CC = GetArg("-ac_cc",0); + ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); @@ -1576,7 +1577,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 0; printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } - if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); extraptr = extrabuf; @@ -1585,7 +1586,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY); - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffffff) << 40); + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | (ASSETCHAINS_PUBLIC & 0xff); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } addn = GetArg("-seednode",""); diff --git a/src/main.cpp b/src/main.cpp index 5659a3c6f..a7565e0ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1109,6 +1109,11 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Ensure that joinsplit values are well-formed BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) { + if ( ASSETCHAINS_PUBLIC != 0 ) + { + return state.DoS(100, error("CheckTransaction(): this is a public chain, no privacy allowed"), + REJECT_INVALID, "bad-txns-acprivacy-chain"); + } if (joinsplit.vpub_old < 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old negative"), REJECT_INVALID, "bad-txns-vpub_old-negative"); @@ -1737,6 +1742,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; +extern uint8_t ASSETCHAINS_PUBLIC; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { From 1bc74c28cf61d5eb3a3abd9dd5e0f6d7395f86e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 21:58:03 -1100 Subject: [PATCH 04/23] -donation option to donate 5% rewards to a pubkey --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 1 + src/wallet/wallet.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index cd476830f..b4f886e4b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 181d07989..9a8c3c5e0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1506,6 +1506,7 @@ void komodo_args(char *argv0) IS_KOMODO_NOTARY = GetBoolArg("-notary", false); if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 ) fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); + DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 550cba683..b0b5669ce 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -43,6 +43,7 @@ bool fPayAtLeastCustomFee = true; extern int32_t KOMODO_EXCHANGEWALLET; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern std:string DONATION_PUBKEY; /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) @@ -2789,6 +2790,11 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); //interest = 0; // interest2 also //} + if ( ASSETCHAINS_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) + { + txNew.vout.insert(txNew.vout.size(), newTxOut(interest2, CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG)); + interest2 = 0; + } CAmount nChange = (nValueIn - nValue + interest2); //fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)nTotalValue/COIN); if (nSubtractFeeFromAmount == 0) From e0bc68e669693b8971dbe6ded4d008a61d0f6eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 22:06:12 -1100 Subject: [PATCH 05/23] Fix burn of 5000 sats from notary vin --- src/miner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 257627b47..4b7d09252 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -443,6 +443,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,chainparams.GetConsensus()); + if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) + txNew.vout[0].nValue += 5000; txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); txNew.nExpiryHeight = 0; // Add fees From 055ee43334352f0647371fd6b7cc3e75da1dc512 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:27:24 -1100 Subject: [PATCH 06/23] Syntax --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9a8c3c5e0..a29245ac2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1502,6 +1502,7 @@ char *argv0names[] = void komodo_args(char *argv0) { extern int64_t MAX_MONEY; + extern const char *Notaries_elected1[][2]; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 ) @@ -1513,7 +1514,7 @@ void komodo_args(char *argv0) USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) { - for (i=0; i Date: Thu, 28 Jun 2018 23:28:23 -1100 Subject: [PATCH 07/23] syntax --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a29245ac2..c8c2e35b1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1518,7 +1518,7 @@ void komodo_args(char *argv0) if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 ) { IS_KOMODO_NOTARY = 1; - fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]) + fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } } From a55973aeea4bb3b60d1aa9fbd26452646b128eed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:31:32 -1100 Subject: [PATCH 08/23] :: --- 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 b0b5669ce..ef7391912 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -43,7 +43,7 @@ bool fPayAtLeastCustomFee = true; extern int32_t KOMODO_EXCHANGEWALLET; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern std:string DONATION_PUBKEY; +extern std::string DONATION_PUBKEY; /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) From 76471d5658903fb6d376a04d3e19c2cf30727ad4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:32:14 -1100 Subject: [PATCH 09/23] CTxOut --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ef7391912..00ae77e0f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2792,6 +2792,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //} if ( ASSETCHAINS_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) { + CTxOut newTxOut; txNew.vout.insert(txNew.vout.size(), newTxOut(interest2, CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG)); interest2 = 0; } From 85df50842b0ead86730176773492baec74ed2853 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:33:52 -1100 Subject: [PATCH 10/23] syntax --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 00ae77e0f..0d1c442e0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2792,8 +2792,8 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //} if ( ASSETCHAINS_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) { - CTxOut newTxOut; - txNew.vout.insert(txNew.vout.size(), newTxOut(interest2, CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG)); + CTxOut newTxOut(interest2, CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG); + txNew.vout.insert(txNew.vout.size(),newTxOut) ; interest2 = 0; } CAmount nChange = (nValueIn - nValue + interest2); From 817ad14d08f8dc6f75e7d39b55f7956ca2eefdc0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:39:32 -1100 Subject: [PATCH 11/23] Fix --- src/wallet/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0d1c442e0..68224c1a8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2792,8 +2792,11 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //} if ( ASSETCHAINS_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) { - CTxOut newTxOut(interest2, CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG); - txNew.vout.insert(txNew.vout.size(),newTxOut) ; + CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG; + CTxOut newTxOut(interest2,scriptDonation); + nDonationPosRet = txNew.vout.size() - 1; // dont change first or last + vector::iterator position = txNew.vout.begin()+nChangePosRet; + txNew.vout.insert(position, newTxOut); interest2 = 0; } CAmount nChange = (nValueIn - nValue + interest2); From 719aa8b19e97291d6bc30bc0996eff792b221155 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 28 Jun 2018 23:42:32 -1100 Subject: [PATCH 12/23] Test --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 68224c1a8..10bf93598 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2794,8 +2794,8 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt { CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG; CTxOut newTxOut(interest2,scriptDonation); - nDonationPosRet = txNew.vout.size() - 1; // dont change first or last - vector::iterator position = txNew.vout.begin()+nChangePosRet; + int32_t nDonationPosRet = txNew.vout.size() - 1; // dont change first or last + vector::iterator position = txNew.vout.begin()+nDonationPosRet; txNew.vout.insert(position, newTxOut); interest2 = 0; } From 94f9918f9d085bfdabbcdf1ce60af1115894d096 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 01:18:10 -1100 Subject: [PATCH 13/23] Default genproclimit to 0 --- src/init.cpp | 6 +++--- src/rpcmining.cpp | 4 ++-- src/wallet/asyncrpcoperation_mergetoaddress.cpp | 4 ++-- src/wallet/asyncrpcoperation_sendmany.cpp | 4 ++-- src/wallet/asyncrpcoperation_shieldcoinbase.cpp | 4 ++-- src/zcbenchmarks.cpp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 52c919421..1b8018b56 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -499,7 +499,7 @@ std::string HelpMessage(HelpMessageMode mode) #ifdef ENABLE_MINING strUsage += HelpMessageGroup(_("Mining options:")); strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), 0)); - strUsage += HelpMessageOpt("-genproclimit=", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 1)); + strUsage += HelpMessageOpt("-genproclimit=", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 0)); strUsage += HelpMessageOpt("-equihashsolver=", _("Specify the Equihash solver to be used if enabled (default: \"default\")")); strUsage += HelpMessageOpt("-mineraddress=", _("Send mined coins to a specific single address")); strUsage += HelpMessageOpt("-minetolocalwallet", strprintf( @@ -1766,9 +1766,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Generate coins in the background #ifdef ENABLE_WALLET if (pwalletMain || !GetArg("-mineraddress", "").empty()) - GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0)); #else - GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 0)); #endif #endif diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 7f66f23f6..afe4e5a33 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -319,8 +319,8 @@ UniValue setgenerate(const UniValue& params, bool fHelp) if (params.size() > 1) { nGenProcLimit = params[1].get_int(); - if (nGenProcLimit == 0) - fGenerate = false; + //if (nGenProcLimit == 0) + // fGenerate = false; } mapArgs["-gen"] = (fGenerate ? "1" : "0"); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index a85f3315c..fa41c87d4 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -152,9 +152,9 @@ void AsyncRPCOperation_mergetoaddress::main() #ifdef ENABLE_MINING #ifdef ENABLE_WALLET - GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0)); #else - GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 0)); #endif #endif diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 6f33b514e..3652f7d0d 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -158,9 +158,9 @@ void AsyncRPCOperation_sendmany::main() { #ifdef ENABLE_MINING #ifdef ENABLE_WALLET - GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0)); #else - GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0)); #endif #endif diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 1bc82fdbe..f48cf8dcd 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -137,9 +137,9 @@ void AsyncRPCOperation_shieldcoinbase::main() { #ifdef ENABLE_MINING #ifdef ENABLE_WALLET - GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0)); #else - GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0)); #endif #endif diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 2c7e99a67..b3fbddf88 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -61,7 +61,7 @@ void post_wallet_load(){ #ifdef ENABLE_MINING // Generate coins in the background if (pwalletMain || !GetArg("-mineraddress", "").empty()) - GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0)); #endif } From 3a446d9f249c706a0cad398b4d69a8955deaa6bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 01:26:23 -1100 Subject: [PATCH 14/23] +print --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4b7d09252..5903dd825 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1187,7 +1187,9 @@ void static BitcoinMiner() delete minerThreads; minerThreads = NULL; } - + fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); + if ( nThreads == 0 ) + nThreads = 1; if (nThreads == 0 || !fGenerate) return; From 8daf7cafe6b495752d24e7540da7ef6d16c6b0f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 01:33:40 -1100 Subject: [PATCH 15/23] 100 easy PoW blocks for staked=100 --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0e8d8ddfd..ca02f2a00 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1165,7 +1165,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { CBlockIndex *pindex; arith_uint256 bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); sum = arith_uint256(0); ave = sum; From db178ad2baa5d1dacafe28d5461f1db42907e0e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 01:43:36 -1100 Subject: [PATCH 16/23] -print --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ca02f2a00..4ff810723 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1136,12 +1136,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh } if ( validateflag != 0 ) { - for (i=31; i>=24; i--) + /*for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs target "); for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d gap.%d %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,(int32_t)(blocktime - prevtime),dstr(value),(int32_t)diff); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d gap.%d %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,(int32_t)(blocktime - prevtime),dstr(value),(int32_t)diff);*/ break; } } From 4f02fc40094f8f894072f6379ca279d3b95be569 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 02:52:29 -1100 Subject: [PATCH 17/23] Getbalance64 --- src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 45 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index bc1ba5b37..1cfab13d0 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -383,6 +383,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, { "wallet", "getbalance", &getbalance, false }, + { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, { "wallet", "getrawchangeaddress", &getrawchangeaddress, true }, { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 40cb96288..e6edc3949 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -220,6 +220,7 @@ extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); +extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); extern UniValue movecmd(const UniValue& params, bool fHelp); extern UniValue sendfrom(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 255f74a19..a25b5f4bb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4673,3 +4673,48 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else fprintf(stderr,"no earliest utxo for staking\n"); return(siglen); } + +UniValue getbalance64(const UniValue& params, bool fHelp) +{ + set setAddress; vector vecOutputs; + UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); + const CKeyStore& keystore = *pwalletMain; + CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; + assert(pwalletMain != NULL); + if (fHelp || params.size() > 0) + throw runtime_error("getbalance64\n"); + total = total2 = 0; + memset(nValues,0,sizeof(nValues)); + memset(nValues2,0,sizeof(nValues2)); + LOCK2(cs_main, pwalletMain->cs_wallet); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + BOOST_FOREACH(const COutput& out, vecOutputs) + { + nValue = out.tx->vout[out.i].nValue; + if ( setAddress.size() ) + { + CTxDestination address; + if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + continue; + if (!setAddress.count(address)) + continue; + segid = komodo_segid((char *)CBitcoinAddress(address).ToString().c_str()); + if ( out.nDepth < 100 ) + nValues2[segid] += nValue, total2 += nValue; + else nValues[segid] += nValue, total += nValue; + } + } + ret.push_back(Pair("staking",(double)total/COIN)); + ret.push_back(Pair("immature",(double)total2/COIN)); + for (i=0; i<64; i++) + { + UniValue item(UniValue::VOBJ); + item.push_back(double)nValues[i] / COIN); + a.push_back(item); + item.push_back(double)nValues2[i] / COIN); + b.push_back(item); + } + ret.push_back(Pair("staking", a)); + ret.push_back(Pair("immature", b)); + return ret; +} From 890e708b8749dec60df38a7050f0cfbfbfb18040 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:10:41 -1100 Subject: [PATCH 18/23] Test --- src/wallet/rpcwallet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a25b5f4bb..a16fc77e4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -44,6 +44,7 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); +uint32_t komodo_segid32(char *coinaddr); int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -4709,9 +4710,9 @@ UniValue getbalance64(const UniValue& params, bool fHelp) for (i=0; i<64; i++) { UniValue item(UniValue::VOBJ); - item.push_back(double)nValues[i] / COIN); + item.push_back((double)nValues[i] / COIN); a.push_back(item); - item.push_back(double)nValues2[i] / COIN); + item.push_back((double)nValues2[i] / COIN); b.push_back(item); } ret.push_back(Pair("staking", a)); From ca76a7dfcd7ed4a145e9f7129986e05ad4378ba5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:13:18 -1100 Subject: [PATCH 19/23] Test --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a16fc77e4..deb49e94a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4699,7 +4699,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) continue; if (!setAddress.count(address)) continue; - segid = komodo_segid((char *)CBitcoinAddress(address).ToString().c_str()); + segid = (komodo_segid32((char *)CBitcoinAddress(address).ToString().c_str()) & 0x3f); if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; @@ -4710,9 +4710,9 @@ UniValue getbalance64(const UniValue& params, bool fHelp) for (i=0; i<64; i++) { UniValue item(UniValue::VOBJ); - item.push_back((double)nValues[i] / COIN); + item.push_back((uint64_t)nValues[i]); a.push_back(item); - item.push_back((double)nValues2[i] / COIN); + item.push_back((uint64_t)nValues2[i]); b.push_back(item); } ret.push_back(Pair("staking", a)); From 5e0b330de9dd0de4be072e0520481b3f831ec9e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:19:39 -1100 Subject: [PATCH 20/23] Test --- src/wallet/rpcwallet.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index deb49e94a..7c76eb691 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4678,7 +4678,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt UniValue getbalance64(const UniValue& params, bool fHelp) { set setAddress; vector vecOutputs; - UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); + UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); CTxDestination address; const CKeyStore& keystore = *pwalletMain; CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; assert(pwalletMain != NULL); @@ -4692,30 +4692,23 @@ UniValue getbalance64(const UniValue& params, bool fHelp) BOOST_FOREACH(const COutput& out, vecOutputs) { nValue = out.tx->vout[out.i].nValue; - if ( setAddress.size() ) + if ( ExtractDestination(out.tx->vout[out.i].scriptPubKey, address) ) { - CTxDestination address; - if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) - continue; - if (!setAddress.count(address)) - continue; segid = (komodo_segid32((char *)CBitcoinAddress(address).ToString().c_str()) & 0x3f); if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - } + fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + } else fprintf(stderr,"no destination\n"); } - ret.push_back(Pair("staking",(double)total/COIN)); + ret.push_back(Pair("mature",(double)total/COIN)); ret.push_back(Pair("immature",(double)total2/COIN)); for (i=0; i<64; i++) { - UniValue item(UniValue::VOBJ); - item.push_back((uint64_t)nValues[i]); - a.push_back(item); - item.push_back((uint64_t)nValues2[i]); - b.push_back(item); + a.push_back((uint64_t)nValues[i]); + b.push_back((uint64_t)nValues2[i]); } ret.push_back(Pair("staking", a)); - ret.push_back(Pair("immature", b)); + ret.push_back(Pair("notstaking", b)); return ret; } From d979952f3a0a73c706d7453d8cdce6017f809a5c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:25:42 -1100 Subject: [PATCH 21/23] -print --- 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 7c76eb691..22fe7fba1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4698,7 +4698,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + //fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); } else fprintf(stderr,"no destination\n"); } ret.push_back(Pair("mature",(double)total/COIN)); From 2732d384f4b64a414da008aede956c506c8009d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:37:42 -1100 Subject: [PATCH 22/23] Stub getnewaddress64 --- src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 1cfab13d0..ed5110114 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -385,6 +385,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, +// { "wallet", "getnewaddress64", &getnewaddress64, true }, { "wallet", "getrawchangeaddress", &getrawchangeaddress, true }, { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false }, { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false }, diff --git a/src/rpcserver.h b/src/rpcserver.h index e6edc3949..5bb949299 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -209,6 +209,7 @@ extern UniValue estimatefee(const UniValue& params, bool fHelp); extern UniValue estimatepriority(const UniValue& params, bool fHelp); extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp +//extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp extern UniValue getaccountaddress(const UniValue& params, bool fHelp); extern UniValue getrawchangeaddress(const UniValue& params, bool fHelp); extern UniValue setaccount(const UniValue& params, bool fHelp); From f2c1ac067116dfe6b16413e50a7d72a9afb10117 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jun 2018 03:40:02 -1100 Subject: [PATCH 23/23] -print --- src/komodo_bitcoind.h | 13 ++++++++----- src/miner.cpp | 9 ++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4ff810723..5cd88d7de 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1181,22 +1181,25 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he hashval = UintToArith256(pindex->GetBlockHash()); if ( hashval <= bnTarget ) // PoW is never as easy as PoS/16, some PoS will be counted as PoW { - fprintf(stderr,"1"); + if ( ASSETCHAINS_STAKED < 100 ) + fprintf(stderr,"1"); sum += hashval; n++; } else { percPoS++; - fprintf(stderr,"0"); + if ( ASSETCHAINS_STAKED < 100 ) + fprintf(stderr,"0"); } - if ( (i % 10) == 9 ) + if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } } if ( n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; - fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); + if ( ASSETCHAINS_STAKED < 100 ) + fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; target = (target / arith_uint256(KOMODO_POWMINMULT)); if ( n > 0 ) @@ -1208,7 +1211,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget { bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc); - if ( 1 ) + if ( ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); diff --git a/src/miner.cpp b/src/miner.cpp index 5903dd825..5ed1c5af7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -920,9 +920,12 @@ void static BitcoinMiner() continue; }*/ HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + if ( ASSETCHAINS_STAKED < 100 ) + { + for (z=31; z>=0; z--) + fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); + fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + } } while (true) {