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/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0e8d8ddfd..5cd88d7de 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; } } @@ -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; @@ -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 4b7d09252..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) { @@ -1187,7 +1190,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; 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/rpcserver.cpp b/src/rpcserver.cpp index bc1ba5b37..ed5110114 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -383,7 +383,9 @@ 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", "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 40cb96288..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); @@ -220,6 +221,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/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/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 255f74a19..22fe7fba1 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; @@ -4673,3 +4674,41 @@ 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); CTxDestination address; + 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 ( ExtractDestination(out.tx->vout[out.i].scriptPubKey, address) ) + { + 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("mature",(double)total/COIN)); + ret.push_back(Pair("immature",(double)total2/COIN)); + for (i=0; i<64; i++) + { + a.push_back((uint64_t)nValues[i]); + b.push_back((uint64_t)nValues2[i]); + } + ret.push_back(Pair("staking", a)); + ret.push_back(Pair("notstaking", b)); + return ret; +} 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 }