From 8bcd895c73f7ed6af73916fd6c582f543ffc24be Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 1 Jul 2018 23:10:13 -1100 Subject: [PATCH 1/7] GLXT change --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index b8658ab24..dd5c5d813 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -32,7 +32,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & -./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 & +./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 & ./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 & ./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=78.47.196.146 & From 36f9e6d6d581addb1bb29754b61287929673832f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 2 Jul 2018 07:09:29 -1100 Subject: [PATCH 2/7] -ac_private --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 1 + src/main.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b4f886e4b..c46486430 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,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; 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 c8c2e35b1..c6ffe4cdd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1541,6 +1541,7 @@ void komodo_args(char *argv0) } ASSETCHAINS_CC = GetArg("-ac_cc",0); ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); + ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); diff --git a/src/main.cpp b/src/main.cpp index a7565e0ab..13a3121c6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1090,6 +1090,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for negative or overflow output values CAmount nValueOut = 0; + int32_t iscoinbase = tx.IsCoinBase(); BOOST_FOREACH(const CTxOut& txout, tx.vout) { if (txout.nValue < 0) @@ -1100,6 +1101,10 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio fprintf(stderr,"%.8f > max %.8f\n",(double)txout.nValue/COIN,(double)MAX_MONEY/COIN); return state.DoS(100, error("CheckTransaction(): txout.nValue too high"),REJECT_INVALID, "bad-txns-vout-toolarge"); } + if ( txout.nValue > 0 && ASSETCHAINS_PRIVATE != 0 && iscoinbase == 0 ) + { + return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); + } nValueOut += txout.nValue; if (!MoneyRange(nValueOut)) return state.DoS(100, error("CheckTransaction(): txout total out of range"), @@ -1742,7 +1747,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; +extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { From 2f151c301925c9959d62d52a82d6ddcbe7971f00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jul 2018 01:34:08 -1100 Subject: [PATCH 3/7] Prevent taddr outputs in most places for -ac_private --- src/komodo_utils.h | 5 +++++ src/wallet/rpcwallet.cpp | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c6ffe4cdd..0c1ea8f18 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1558,6 +1558,11 @@ void komodo_args(char *argv0) ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; + if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) + { + printf("-ac_private chains cant have any PoS\n"); + exit(0); + } if ( ASSETCHAINS_HALVING != 0 && ASSETCHAINS_HALVING < 1440 ) { ASSETCHAINS_HALVING = 1440; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 22fe7fba1..a1773f43b 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); +extern uint8_t ASSETCHAINS_PRIVATE; uint32_t komodo_segid32(char *coinaddr); int64_t nWalletUnlockTime; @@ -453,6 +454,9 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) + HelpExampleRpc("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", 0.1, \"donation\", \"seans outpost\"") ); + if ( ASSETCHAINS_PRIVATE != 0 && AmountFromValue(params[1]) > 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); + LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); @@ -1071,6 +1075,8 @@ UniValue getunconfirmedbalance(const UniValue ¶ms, bool fHelp) UniValue movecmd(const UniValue& params, bool fHelp) { + if ( ASSETCHAINS_PRIVATE != 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1144,6 +1150,8 @@ UniValue movecmd(const UniValue& params, bool fHelp) UniValue sendfrom(const UniValue& params, bool fHelp) { + if ( ASSETCHAINS_PRIVATE != 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1209,6 +1217,8 @@ UniValue sendfrom(const UniValue& params, bool fHelp) UniValue sendmany(const UniValue& params, bool fHelp) { + if ( ASSETCHAINS_PRIVATE != 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -3762,7 +3772,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) string address = find_value(o, "address").get_str(); bool isZaddr = false; CBitcoinAddress taddr(address); - if (!taddr.IsValid()) { + if (!taddr.IsValid()) + { try { CZCPaymentAddress zaddr(address); zaddr.Get(); @@ -3771,6 +3782,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); } } + else if ( ASSETCHAINS_PRIVATE != 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+address); @@ -4229,6 +4242,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress ); } } + else if ( ASSETCHAINS_PRIVATE != 0 ) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); // Convert fee from currency format to zatoshis CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE; From 4addff14a06e97baa64b592f7558751bf9b8aac7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jul 2018 05:09:43 -1100 Subject: [PATCH 4/7] Make ac_private change magic --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0c1ea8f18..f61fd05ea 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1585,7 +1585,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 || ASSETCHAINS_PUBLIC != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 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; @@ -1594,7 +1594,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 & 0xffff) << 40) | (ASSETCHAINS_PUBLIC & 0xff); + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } addn = GetArg("-seednode",""); From afaeb54b98ef5ae509751168a5528ba8dca59570 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jul 2018 05:16:45 -1100 Subject: [PATCH 5/7] -print --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5ed1c5af7..421e9bab3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1190,7 +1190,7 @@ void static BitcoinMiner() delete minerThreads; minerThreads = NULL; } - fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); + //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); if ( nThreads == 0 ) nThreads = 1; if (nThreads == 0 || !fGenerate) From 361e75f6f97579e009bd8dc91bf4f04d2fd033a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jul 2018 05:22:51 -1100 Subject: [PATCH 6/7] +print --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 421e9bab3..755b7439e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1009,7 +1009,7 @@ void static BitcoinMiner() 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"); + fprintf(stderr," mined block %d!\n",Mining_height); } CValidationState state; if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) From 471f1b83888a52164e17737b21c3114fba6edc31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jul 2018 06:12:21 -1100 Subject: [PATCH 7/7] +print --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 13a3121c6..8d1649d3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1101,9 +1101,11 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio fprintf(stderr,"%.8f > max %.8f\n",(double)txout.nValue/COIN,(double)MAX_MONEY/COIN); return state.DoS(100, error("CheckTransaction(): txout.nValue too high"),REJECT_INVALID, "bad-txns-vout-toolarge"); } - if ( txout.nValue > 0 && ASSETCHAINS_PRIVATE != 0 && iscoinbase == 0 ) + if ( ASSETCHAINS_PRIVATE != 0 ) { - return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); + fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase); + if ( txout.nValue > 0 && iscoinbase == 0 ) + return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); } nValueOut += txout.nValue; if (!MoneyRange(nValueOut))