diff --git a/.gitignore b/.gitignore index 03f81cc82..a3f474a14 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,14 @@ src/komodo-cli.exe src/komodod.exe src/komodo-tx.exe +src/hush-cli +src/hushd +src/hush-tx +src/hush-test +src/hush-cli.exe +src/hushd.exe +src/hush-tx.exe + #output during builds, symbol tables? *.dSYM diff --git a/Makefile.am b/Makefile.am index 7b4d44e2d..90085c5e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,7 @@ +# Copyright 2016-2021 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html + ACLOCAL_AMFLAGS = -I build-aux/m4 SUBDIRS = src if ENABLE_MAN diff --git a/configure.ac b/configure.ac index 35da30d2a..4f369aebd 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) define(_CLIENT_VERSION_MINOR, 8) -define(_CLIENT_VERSION_REVISION, 0) +define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_BUILD, 50) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) @@ -14,9 +14,9 @@ AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux/m4]) -BITCOIN_DAEMON_NAME=komodod -BITCOIN_CLI_NAME=komodo-cli -BITCOIN_TX_NAME=komodo-tx +BITCOIN_DAEMON_NAME=hushd +BITCOIN_CLI_NAME=hush-cli +BITCOIN_TX_NAME=hush-tx dnl Unless the user specified ARFLAGS, force it to be cr AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to if not set]) @@ -231,7 +231,7 @@ CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" AC_ARG_WITH([utils], [AS_HELP_STRING([--with-utils], - [build komodo-cli komodo-tx wallet-utility (default=yes)])], + [build hush-cli hush-tx wallet-utility (default=yes)])], [build_bitcoin_utils=$withval], [build_bitcoin_utils=yes]) @@ -766,11 +766,11 @@ AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS - LIBZCASH_LIBS="-lgmp -lgmpxx $BOOST_SYSTEM_LIB -lwolfssl -lsodium $RUST_LIBS" -AC_MSG_CHECKING([whether to build komodod]) +AC_MSG_CHECKING([whether to build hushd]) AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) AC_MSG_RESULT($build_bitcoind) -AC_MSG_CHECKING([whether to build utils (komodo-cli komodo-tx wallet-utility)]) +AC_MSG_CHECKING([whether to build utils (hush-cli hush-tx wallet-utility)]) AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes]) AC_MSG_RESULT($build_bitcoin_utils) diff --git a/src/Makefile.am b/src/Makefile.am index 0711b52cc..027a0232e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,11 +98,11 @@ noinst_PROGRAMS = TESTS = #if BUILD_BITCOIND - bin_PROGRAMS += komodod + bin_PROGRAMS += hushd #endif if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += hush-cli hush-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -333,7 +333,7 @@ libbitcoin_zmq_a_SOURCES = \ zmq/zmqpublishnotifier.cpp endif -# wallet: komodod, but only linked when wallet enabled +# wallet: hushd, but only linked when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_wallet_a_SOURCES = \ @@ -481,17 +481,17 @@ libbitcoin_cli_a_SOURCES = \ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h # -# komodod binary # -komodod_SOURCES = bitcoind.cpp -komodod_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -komodod_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS) -komodod_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +# hushd binary # +hushd_SOURCES = bitcoind.cpp +hushd_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +hushd_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS) +hushd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_WINDOWS -komodod_SOURCES += bitcoind-res.rc +hushd_SOURCES += bitcoind-res.rc endif -komodod_LDADD = \ +hushd_LDADD = \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_COMMON) \ $(LIBUNIVALUE) \ @@ -506,10 +506,10 @@ komodod_LDADD = \ $(LIBCRYPTOCONDITIONS) if ENABLE_WALLET -komodod_LDADD += $(LIBBITCOIN_WALLET) +hushd_LDADD += $(LIBBITCOIN_WALLET) endif -komodod_LDADD += \ +hushd_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ $(SSL_LIBS) \ @@ -521,27 +521,27 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib $(LIBSECP256K1) +hushd_LDADD += libcc.dylib $(LIBSECP256K1) endif if TARGET_WINDOWS -komodod_LDADD += libcc.dll $(LIBSECP256K1) +hushd_LDADD += libcc.dll $(LIBSECP256K1) endif if TARGET_LINUX -komodod_LDADD += libcc.so $(LIBSECP256K1) +hushd_LDADD += libcc.so $(LIBSECP256K1) endif # [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib if TARGET_DARWIN -komodod_LDFLAGS += -static-libgcc +hushd_LDFLAGS += -static-libgcc endif -# komodo-cli binary # -komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +# hush-cli binary # +hush_cli_SOURCES = bitcoin-cli.cpp +hush_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) +hush_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +hush_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_DARWIN -komodo_cli_LDFLAGS += -static-libgcc +hush_cli_LDFLAGS += -static-libgcc endif # wallet-utility binary # @@ -553,10 +553,10 @@ wallet_utility_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) endif if TARGET_WINDOWS -komodo_cli_SOURCES += bitcoin-cli-res.rc +hush_cli_SOURCES += bitcoin-cli-res.rc endif -komodo_cli_LDADD = \ +hush_cli_LDADD = \ $(LIBBITCOIN_CLI) \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ @@ -584,17 +584,17 @@ wallet_utility_LDADD = \ $(LIBCRYPTOCONDITIONS) endif -# komodo-tx binary # -komodo_tx_SOURCES = komodo-tx.cpp -komodo_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -komodo_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +# hush-tx binary # +hush_tx_SOURCES = hush-tx.cpp +hush_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +hush_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +hush_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_WINDOWS -komodo_tx_SOURCES += bitcoin-tx-res.rc +hush_tx_SOURCES += bitcoin-tx-res.rc endif -komodo_tx_LDADD = \ +hush_tx_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ @@ -605,7 +605,7 @@ komodo_tx_LDADD = \ $(LIBZCASH_LIBS) \ $(LIBCRYPTOCONDITIONS) -komodo_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) +hush_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) # Zcash Protocol Primitives libzcash_a_SOURCES = \ diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index dbf2e82e9..b804e26bc 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -28,7 +28,7 @@ #include #include #include "support/events.h" -uint16_t BITCOIND_RPCPORT = 7771; +uint16_t BITCOIND_RPCPORT = 18031; char SMART_CHAIN_SYMBOL[65]; #include @@ -43,13 +43,13 @@ std::string HelpMessageCli() std::string strUsage; strUsage += HelpMessageGroup(_("Options:")); strUsage += HelpMessageOpt("-?", _("This help message")); - strUsage += HelpMessageOpt("-conf=", strprintf(_("Specify configuration file (default: %s)"), "komodo.conf")); + strUsage += HelpMessageOpt("-conf=", strprintf(_("Specify configuration file (default: %s)"), "HUSH3.conf")); strUsage += HelpMessageOpt("-datadir=", _("Specify data directory")); strUsage += HelpMessageOpt("-testnet", _("Use the test network")); strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be " "solved instantly. This is intended for regression testing tools and app development.")); strUsage += HelpMessageOpt("-rpcconnect=", strprintf(_("Send commands to node running on (default: %s)"), "127.0.0.1")); - strUsage += HelpMessageOpt("-rpcport=", strprintf(_("Connect to JSON-RPC on (default: %u or testnet: %u)"), 8232, 18232)); + strUsage += HelpMessageOpt("-rpcport=", strprintf(_("Connect to JSON-RPC on (default: %u )"), 18030)); strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start")); strUsage += HelpMessageOpt("-rpcuser=", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=", _("Password for JSON-RPC connections")); @@ -82,7 +82,10 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters ParseParameters(argc, argv); std:string name; - name = GetArg("-ac_name",""); + + // default HSC is HUSH3 itself, which to the internals, is also an HSC + name = GetArg("-ac_name","HUSH3"); + if ( !name.empty() ) strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1); diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 91e4cef56..b9dd4723b 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -109,10 +109,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) } } -////////////////////////////////////////////////////////////////////////////// -// // Start -// extern int32_t IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY; extern uint32_t ASSETCHAIN_INIT; extern std::string NOTARY_PUBKEY; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 9e9ccc765..e40698ac6 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -675,7 +675,7 @@ int32_t hush_get_current_height() else return chainActive.LastTip()->GetHeight(); } -bool komodo_txnotarizedconfirmed(uint256 txid) +bool hush_txnotarizedconfirmed(uint256 txid) { char str[65]; int32_t confirms,notarized=0,txheight=0,currentheight=0;; @@ -688,17 +688,17 @@ bool komodo_txnotarizedconfirmed(uint256 txid) { if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 ) { - fprintf(stderr,"komodo_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str()); + fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str()); return(0); } else if (txheight<=0) { - fprintf(stderr,"komodo_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str()); + fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str()); return(0); } else if (txheight>currentheight) { - fprintf(stderr,"komodo_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight); + fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight); return(0); } confirms=1 + currentheight - txheight; @@ -707,22 +707,22 @@ bool komodo_txnotarizedconfirmed(uint256 txid) { if ( myGetTransaction(txid,tx,hashBlock) == 0 ) { - fprintf(stderr,"komodo_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str()); + fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str()); return(0); } else if ( hashBlock == zeroid ) { - fprintf(stderr,"komodo_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str()); + fprintf(stderr,"hush_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str()); return(0); } else if ( (pindex= hush_blockindex(hashBlock)) == 0 || (txheight= pindex->GetHeight()) <= 0 ) { - fprintf(stderr,"komodo_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str()); + fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str()); return(0); } else if ( (pindex= chainActive.LastTip()) == 0 || pindex->GetHeight() < txheight ) { - fprintf(stderr,"komodo_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight()); + fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight()); return(0); } confirms=1 + pindex->GetHeight() - txheight; diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 97728d1e7..135d0dc9d 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -249,7 +249,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); - else if (komodo_txnotarizedconfirmed(opentxid) == 0) + else if (hush_txnotarizedconfirmed(opentxid) == 0) return eval->Invalid("channelopen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for channelpayment!"); @@ -310,7 +310,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); - else if (komodo_txnotarizedconfirmed(opentxid) == 0) + else if (hush_txnotarizedconfirmed(opentxid) == 0) return eval->Invalid("channelopen is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for channelclose!"); @@ -351,9 +351,9 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vout.1 is CC marker to srcpub or invalid amount for channelopen!"); else if ( ConstrainVout(channelOpenTx.vout[2],1,destmarker,CC_MARKER_VALUE)==0 ) return eval->Invalid("vout.2 is CC marker to destpub or invalid amount for channelopen!"); - else if (komodo_txnotarizedconfirmed(opentxid) == 0) + else if (hush_txnotarizedconfirmed(opentxid) == 0) return eval->Invalid("channelopen is not yet confirmed(notarised)!"); - else if (komodo_txnotarizedconfirmed(param3) == 0) + else if (hush_txnotarizedconfirmed(param3) == 0) return eval->Invalid("channelClose is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for channelrefund!"); @@ -537,7 +537,7 @@ UniValue ChannelPayment(const CPubKey& pk, uint64_t txfee,uint256 opentxid,int64 } else CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx"); - if (komodo_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized"); + if (hush_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized"); if (AddNormalinputs(mtx,mypk,txfee+CC_MARKER_VALUE,3,pk.IsValid()) > 0) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) @@ -612,7 +612,7 @@ UniValue ChannelClose(const CPubKey& pk, uint64_t txfee,uint256 opentxid) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open txid"); if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain)!='O') CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx"); - if (komodo_txnotarizedconfirmed(opentxid)==false) + if (hush_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream <<"channelsopen tx not yet confirmed/notarized"); if (mypk != srcpub) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "cannot close, you are not channel owner"); @@ -650,13 +650,13 @@ UniValue ChannelRefund(const CPubKey& pk, uint64_t txfee,uint256 opentxid,uint25 CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel close txid"); if ((numvouts=channelCloseTx.vout.size()) < 1 || DecodeChannelsOpRet(channelCloseTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,param1,param2,param3)!='C') CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel close tx"); - if (komodo_txnotarizedconfirmed(closetxid)==false) + if (hush_txnotarizedconfirmed(closetxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsclose tx not yet confirmed/notarized"); if (txid!=opentxid) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "open and close txid are not from same channel"); if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open txid"); - if (komodo_txnotarizedconfirmed(opentxid)==false) + if (hush_txnotarizedconfirmed(opentxid)==false) CCERR_RESULT("channelscc",CCLOG_INFO, stream << "channelsopen tx not yet confirmed/notarized"); if ((numvouts=channelOpenTx.vout.size()) < 1 || DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey,tokenid,txid,srcpub,destpub,numpayments,payment,hashchain)!='O') CCERR_RESULT("channelscc",CCLOG_INFO, stream << "invalid channel open tx"); diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 98475c4f5..286aea5f6 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -669,7 +669,7 @@ uint16_t hush_userpass(char *userpass,char *symbol) #define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) -char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port) { //static void *cHandle; char url[512],*retstr=0,*retstr2=0,postdata[8192]; @@ -691,7 +691,7 @@ int32_t games_sendrawtransaction(char *rawtx) char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,(char *)"sendrawtransaction",params,GAMES_PORT)) != 0 ) { if ( 0 ) // causes 4th level crash { @@ -768,7 +768,7 @@ int32_t games_progress(struct games_state *rs,int32_t waitflag,uint64_t seed,gam if ( fp == 0 ) fp = fopen("keystrokes.log","a"); sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( fp != 0 ) { @@ -978,7 +978,7 @@ int32_t games_setplayerdata(struct games_state *rs,char *gametxidstr) else { sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); - filestr = komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT); + filestr = hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT); } if ( filestr != 0 ) { diff --git a/src/cc/games/prices.c b/src/cc/games/prices.c index f23a4ccea..dc046d667 100644 --- a/src/cc/games/prices.c +++ b/src/cc/games/prices.c @@ -206,7 +206,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid); else if ( sizeof(c) == 8 ) sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { @@ -237,7 +237,7 @@ int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize) x >>= 8; } sprintf(params,"[\"bet\",\"17\",\"[%.8f,%%22%s%%22]\"]",dstr(betsize),hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { diff --git a/src/cc/games/tetris.c b/src/cc/games/tetris.c index c0a3633f2..848e9aacc 100644 --- a/src/cc/games/tetris.c +++ b/src/cc/games/tetris.c @@ -822,7 +822,7 @@ int32_t issue_games_events(struct games_state *rs,char *gametxidstr,uint32_t eve sprintf(params,"[\"events\",\"17\",\"[%%22%08x%%22,%%22%s%%22,%u]\"]",(uint32_t)c&0xffffffff,gametxidstr,eventid); else if ( sizeof(c) == 8 ) sprintf(params,"[\"events\",\"17\",\"[%%22%016llx%%22,%%22%s%%22,%u]\"]",(long long)c,gametxidstr,eventid); - if ( (retstr= komodo_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,(char *)"cclib",params,GAMES_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index fe70b4625..fdd304a05 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -612,7 +612,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & sprintf(validationError,"illegal format %s != Ihh\n",format.c_str()); return eval->Invalid(validationError); } - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (myGetTransaction(deposittxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysdeposittxid!"); @@ -630,7 +630,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("bindtxid does not match to bindtxid from gatewaysdeposit"); else if (tmpamount>totalsupply) return eval->Invalid("deposit amount greater then bind total supply"); - else if (komodo_txnotarizedconfirmed(deposittxid) == false) + else if (hush_txnotarizedconfirmed(deposittxid) == false) return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); else if (tx.vin.size()>0) { @@ -704,7 +704,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("invalid marker vout for gatewaysWithdraw!"); else if ( ConstrainVout(tmptx.vout[1],1,gatewaystokensaddr,amount)==0) return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -714,7 +714,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("refcoin different than in bind tx"); else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("vin.0 is normal for gatewayspartialsign!"); @@ -746,7 +746,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); else if (tmptx.vout[1].nValue!=amount) return eval->Invalid("amount in opret not matching tx tokens amount!"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -756,7 +756,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("refcoin different than in bind tx"); else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); @@ -777,7 +777,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("invalid gatewayscompletesigning txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeGatewaysCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); - else if (komodo_txnotarizedconfirmed(completetxid) == false) + else if (hush_txnotarizedconfirmed(completetxid) == false) return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!"); else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid withdraw txid!"); @@ -785,7 +785,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -795,7 +795,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction & return eval->Invalid("refcoin different than in bind tx"); else if (tmptokenid!=tokenid) return eval->Invalid("tokenid does not match tokenid from gatewaysbind"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); @@ -946,7 +946,7 @@ UniValue GatewaysDeposit(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,int3 CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex()); if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin); - if (komodo_txnotarizedconfirmed(bindtxid)==false) + if (hush_txnotarizedconfirmed(bindtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized"); n = (int32_t)pubkeys.size(); merkleroot = zeroid; @@ -997,13 +997,13 @@ UniValue GatewaysClaim(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,std::s CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex()); if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin); - if (komodo_txnotarizedconfirmed(bindtxid)==false) + if (hush_txnotarizedconfirmed(bindtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized"); if ( myGetTransaction(deposittxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find deposittxid " << bindtxid.GetHex()); if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - deposittxid " << bindtxid.GetHex() << " coin." << coin); - if (komodo_txnotarizedconfirmed(deposittxid)==false) + if (hush_txnotarizedconfirmed(deposittxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysdeposit tx not yet confirmed/notarized"); if (tmpdestpub!=destpub) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "different destination pubkey from desdeposit tx"); @@ -1038,7 +1038,7 @@ UniValue GatewaysWithdraw(const CPubKey& pk, uint64_t txfee,uint256 bindtxid,std CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cant find bindtxid " << bindtxid.GetHex()); if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin ) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid coin - bindtxid " << bindtxid.GetHex() << " coin." << coin); - if (komodo_txnotarizedconfirmed(bindtxid)==false) + if (hush_txnotarizedconfirmed(bindtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewaysbind tx not yet confirmed/notarized"); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); SetCCunspents(unspentOutputs,coinaddr,true); @@ -1097,7 +1097,7 @@ UniValue GatewaysPartialSign(const CPubKey& pk, uint64_t txfee,uint256 lasttxid, withdrawtxid=lasttxid; if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << lasttxid.GetHex()); - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized"); else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex()); @@ -1114,7 +1114,7 @@ UniValue GatewaysPartialSign(const CPubKey& pk, uint64_t txfee,uint256 lasttxid, else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << withdrawtxid.GetHex()); - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized"); else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex()); @@ -1151,7 +1151,7 @@ UniValue GatewaysCompleteSigning(const CPubKey& pk, uint64_t txfee,uint256 lastt withdrawtxid=lasttxid; if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << lasttxid.GetHex()); - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized"); else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex()); @@ -1168,7 +1168,7 @@ UniValue GatewaysCompleteSigning(const CPubKey& pk, uint64_t txfee,uint256 lastt else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw tx " << withdrawtxid.GetHex()); - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayswithdraw tx not yet confirmed/notarized"); else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "can't find bind tx " << bindtxid.GetHex()); @@ -1200,7 +1200,7 @@ UniValue GatewaysMarkDone(const CPubKey& pk, uint64_t txfee,uint256 completetxid CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid completesigning txid " << completetxid.GetHex()); else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "cannot decode completesigning tx opret " << completetxid.GetHex()); - if (komodo_txnotarizedconfirmed(completetxid)==false) + if (hush_txnotarizedconfirmed(completetxid)==false) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "gatewayscompletesigning tx not yet confirmed/notarized"); else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0) CCERR_RESULT("gatewayscc",CCLOG_INFO, stream << "invalid withdraw txid " << withdrawtxid.GetHex()); @@ -1266,7 +1266,7 @@ UniValue GatewaysPendingDeposits(const CPubKey& pk, uint256 bindtxid,std::string pub=HexStr(destpub); obj.push_back(Pair("claim_pubkey",pub)); obj.push_back(Pair("amount",(double)amount/COIN)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid))); pending.push_back(obj); } } @@ -1340,7 +1340,7 @@ UniValue GatewaysPendingWithdraws(const CPubKey& pk, uint256 bindtxid,std::strin obj.push_back(Pair("withdrawaddr",withaddr)); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); obj.push_back(Pair("amount",numstr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash()))); + obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(tx.GetHash()))); if ( queueflag != 0 ) { obj.push_back(Pair("depositaddr",depositaddr)); @@ -1415,7 +1415,7 @@ UniValue GatewaysProcessedWithdraws(const CPubKey& pk, uint256 bindtxid,std::str obj.push_back(Pair("withdrawtxidaddr",txidaddr)); GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); obj.push_back(Pair("withdrawaddr",withaddr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid))); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); obj.push_back(Pair("amount",numstr)); obj.push_back(Pair("hex",hex)); diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 06fc75dff..61e901e84 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -395,7 +395,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport not enough pubkeys for given N " << std::endl); return(-1); } - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) { LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport bindtx not yet confirmed/notarized" << std::endl); return(-1); diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index b2cd169f7..499721909 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -362,7 +362,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); else if (tmptx.vout[1].nValue!=amount) return eval->Invalid("amount in opret not matching tx tokens amount!"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -370,7 +370,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("vin.0 is normal for gatewayspartialsign!"); @@ -404,7 +404,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid tokens to gateways vout for gatewaysWithdraw!"); else if (tmptx.vout[1].nValue!=amount) return eval->Invalid("amount in opret not matching tx tokens amount!"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -412,7 +412,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if (IsCCInput(tx.vin[0].scriptSig) != 0) return eval->Invalid("vin.0 is normal for gatewayscompletesigning!"); @@ -433,7 +433,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid gatewayscompletesigning txid!"); else if ((numvouts=tmptx.vout.size()) > 0 && DecodeImportGatewayCompleteSigningOpRet(tmptx.vout[numvouts-1].scriptPubKey,withdrawtxid,tmprefcoin,K,hex)!='S') return eval->Invalid("invalid gatewayscompletesigning OP_RETURN data!"); - else if (komodo_txnotarizedconfirmed(completetxid) == false) + else if (hush_txnotarizedconfirmed(completetxid) == false) return eval->Invalid("gatewayscompletesigning tx is not yet confirmed(notarised)!"); else if (myGetTransaction(withdrawtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid withdraw txid!"); @@ -441,7 +441,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid gatewayswithdraw OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); - else if (komodo_txnotarizedconfirmed(withdrawtxid) == false) + else if (hush_txnotarizedconfirmed(withdrawtxid) == false) return eval->Invalid("gatewayswithdraw tx is not yet confirmed(notarised)!"); else if (myGetTransaction(bindtxid,tmptx,hashblock) == 0) return eval->Invalid("invalid gatewaysbind txid!"); @@ -449,7 +449,7 @@ bool ImportGatewayValidate(struct CCcontract_info *cp,Eval *eval,const CTransact return eval->Invalid("invalid gatewaysbind OP_RETURN data!"); else if (tmprefcoin!=refcoin) return eval->Invalid("refcoin different than in bind tx"); - else if (komodo_txnotarizedconfirmed(bindtxid) == false) + else if (hush_txnotarizedconfirmed(bindtxid) == false) return eval->Invalid("gatewaysbind tx is not yet confirmed(notarised)!"); else if ( IsCCInput(tx.vin[0].scriptSig) != 0 ) return eval->Invalid("vin.0 is normal for gatewaysmarkdone!"); @@ -597,7 +597,7 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height, LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if (komodo_txnotarizedconfirmed(bindtxid)==false) + if (hush_txnotarizedconfirmed(bindtxid)==false) { CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -673,7 +673,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if (komodo_txnotarizedconfirmed(bindtxid)==false) + if (hush_txnotarizedconfirmed(bindtxid)==false) { CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -754,7 +754,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -801,7 +801,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -872,7 +872,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -918,7 +918,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (komodo_txnotarizedconfirmed(withdrawtxid)==false) + else if (hush_txnotarizedconfirmed(withdrawtxid)==false) { CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -972,7 +972,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if (komodo_txnotarizedconfirmed(completetxid)==false) + if (hush_txnotarizedconfirmed(completetxid)==false) { CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized"); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1084,7 +1084,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) obj.push_back(Pair("withdrawaddr",withaddr)); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); obj.push_back(Pair("amount",numstr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(tx.GetHash()))); + obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(tx.GetHash()))); if ( queueflag != 0 ) { obj.push_back(Pair("depositaddr",burnaddr)); @@ -1159,7 +1159,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) obj.push_back(Pair("withdrawtxidaddr",txidaddr)); GetCustomscriptaddress(withaddr,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG,taddr,prefix,prefix2); obj.push_back(Pair("withdrawaddr",withaddr)); - obj.push_back(Pair("confirmed_or_notarized",komodo_txnotarizedconfirmed(txid))); + obj.push_back(Pair("confirmed_or_notarized",hush_txnotarizedconfirmed(txid))); sprintf(numstr,"%.8f",(double)tx.vout[1].nValue/COIN); obj.push_back(Pair("amount",numstr)); obj.push_back(Pair("hex",hex)); diff --git a/src/cc/musig.cpp b/src/cc/musig.cpp index 4019f2962..363cca280 100644 --- a/src/cc/musig.cpp +++ b/src/cc/musig.cpp @@ -18,7 +18,7 @@ /* first make a combined pk: -./komodo-cli -ac_name=MUSIG cclib combine 18 '["02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28","0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4"]' +./hush-cli -ac_name=MUSIG cclib combine 18 '["02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28","0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4"]' { "pkhash": "5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b", "combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b", @@ -28,7 +28,7 @@ the combined_pk and pkhash will be needed for various other rpc calls second, send 1 coin to the combined_pk - ./komodo-cli -ac_name=MUSIG cclib send 18 '["03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",1]' + ./hush-cli -ac_name=MUSIG cclib send 18 '["03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b",1]' { "hex": "0400008085202f8901a980664dffc810725a79ffb89ac48be4c7b6bade9b789732fcf871acf8e81a2e010000006a47304402207e52763661ecd2c34a65d6623950be11794825db71576dc11894c606ddc317800220028fef46dc20630d0fdf22647b5d4ff0f1c47cf75f48702d0a91d5589eff99d001210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ffffffff031008f60500000000302ea22c8020c71ddb3aac7f9b9e4bdacf032aaa8b8e4433c4ff9f8a43cebb9c1f5da96928a48103120c008203000401cce09aa4350000000023210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac0000000000000000266a2412782103f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b00000000920500000000000000000000000000", "txid": "5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c", @@ -36,7 +36,7 @@ } sendrawtransaction of the above hex. - ./komodo-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1 + ./hush-cli -ac_name=MUSIG getrawtransaction 5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c 1 "vout": [ { "value": 1.00010000, @@ -72,7 +72,7 @@ get the msg we need to sign: - ./komodo-cli -ac_name=MUSIG cclib calcmsg 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac"]' + ./hush-cli -ac_name=MUSIG cclib calcmsg 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac"]' { "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", @@ -85,7 +85,7 @@ the "msg" is what needs to be signed to create a valid spend 5 args: ind, numsigners, combined_pk, pkhash, message to be signed on node with pubkey: 02fb6aa0b96cad24d46b5da93eba3864c45ce07a73bba12da530ae841e140fcf28 - ./komodo-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' + ./hush-cli -ac_name=MUSIG cclib session 18 '[0,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' { "myind": 0, "numsigners": 2, @@ -94,7 +94,7 @@ the "msg" is what needs to be signed to create a valid spend } on node with pubkey: 0255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4 - ./komodo-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' + ./hush-cli -ac_name=MUSIG cclib session 18 '[1,2,"03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75"]' { "myind": 1, "numsigners": 2, @@ -103,7 +103,7 @@ the "msg" is what needs to be signed to create a valid spend } now we need to get the commitment from each node to the other one. the session already put the commitment for each node into the global struct. Keep in mind there is a single global struct with session unique to each cclib session call. that means no restarting any deamon in the middle of the process on any of the nodes and only call cclib session a single time. this is an artificial restriction just to simplify the initial implementation of musig - ./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851"]' + ./hush-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","c2291acb747a75b1a40014d8eb0cc90a1360f74d413f65f78e20a7de45eda851"]' { "added_index": 1, "myind": 0, @@ -111,7 +111,7 @@ the "msg" is what needs to be signed to create a valid spend "result": "success" } - ./komodo-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"d242cff13fa8c9b83248e4219fda459ada146b885f2171481f1b0f66c66d94ad"]' + ./hush-cli -ac_name=MUSIG cclib commit 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"d242cff13fa8c9b83248e4219fda459ada146b885f2171481f1b0f66c66d94ad"]' { "added_index": 0, "myind": 1, @@ -120,7 +120,7 @@ the "msg" is what needs to be signed to create a valid spend } Now exchange the revealed nonces to each node: - ./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c"]' + ./hush-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","039365deaaaea089d509ba4c9f846de2baf4aa04cf6b26fa2c1cd818553e47f80c"]' { "added_index": 1, "myind": 0, @@ -128,7 +128,7 @@ the "msg" is what needs to be signed to create a valid spend "result": "success" } -./komodo-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b"]' +./hush-cli -ac_name=MUSIG cclib nonce 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"02fec7a9310c959a0a97b86bc3f8c30d392d1fb51793915898c568f73f1f70476b"]' { "added_index": 0, "myind": 1, @@ -137,14 +137,14 @@ the "msg" is what needs to be signed to create a valid spend } Almost there! final step is to exchange the partial sigs between signers - ./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e"]' + ./hush-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b","1","4a3795e6801b355102c617390cf5a462061e082e35dc2ed8f8b1fab54cc0769e"]' { "added_index": 1, "result": "success", "combinedsig": "a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9" } - ./komodo-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b"]' + ./hush-cli -ac_name=MUSIG cclib partialsig 18 '["5cb5a225064ca6ffc1438cb2a6ac2ac65fe2d5055dc7f6c7ebffb9a231f8912b",0,"1d65c09cd9bffe4f0604227e66cd7cd221480bbb08262fe885563a9df7cf8f5b"]' { "added_index": 0, "result": "success", @@ -155,7 +155,7 @@ the "msg" is what needs to be signed to create a valid spend Now for a sanity test, we can use the verify call to make sure this sig will work with the msg needed for the spend: - ./komodo-cli -ac_name=MUSIG cclib verify 18 '["f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75","03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' + ./hush-cli -ac_name=MUSIG cclib verify 18 '["f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75","03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' { "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", "combined_pk": "03f016c348437c7422eed92d865aa9789614f75327cada463eefc566126b54785b", @@ -165,7 +165,7 @@ the "msg" is what needs to be signed to create a valid spend and finally the spend: sendtxid, scriptPubKey, musig - ./komodo-cli -ac_name=MUSIG cclib spend 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' + ./hush-cli -ac_name=MUSIG cclib spend 18 '["5ce74037a153ee210413b48d4e88638b99825a2de1a1f1aa0d36ebf93019824c","210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac","a76f2790747ed2436a281f2660bdbee21bad9ee130b9cab6e542fa618fba1512679d568359db33a008ca39b773c32134276613e93e025ec17e083553449005f9"]' { "scriptpubkey": "210255c46dbce584e3751081b39d7fc054fc807100557e73fc444481618b5706afb4ac", "msg": "f7fb85d1412814e3c2f98b990802af6ee33dad368c6ba05c2050e9e5506fcd75", diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 3052b72ee..e627f751f 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -620,7 +620,7 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -uint16_t _komodo_userpass(char *username, char *password, FILE *fp) +uint16_t _hush_userpass(char *username, char *password, FILE *fp) { char *rpcuser,*rpcpassword,*str,*ipaddress,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; @@ -695,23 +695,17 @@ uint16_t _komodo_userpass(char *username, char *password, FILE *fp) //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); }*/ -uint16_t komodo_userpass(char *userpass,char *symbol) +uint16_t hush_userpass(char *userpass,char *symbol) { FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN]; userpass[0] = 0; - if ( strcmp("KMD",symbol) == 0 ) - { -#ifdef __APPLE__ - sprintf(confname,"Komodo.conf"); -#else - sprintf(confname,"komodo.conf"); -#endif - } - else sprintf(confname,"%s.conf",symbol); + + sprintf(confname,"%s.conf",symbol); + //hush_statefname(fname,symbol,confname); if ( (fp= fopen(confname,"rb")) != 0 ) { - port = _komodo_userpass(username,password,fp); + port = _hush_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 ) strcpy(USERPASS,userpass); @@ -722,7 +716,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol) #define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True) -char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port) { //static void *cHandle; char url[512],*retstr=0,*retstr2=0,postdata[8192]; @@ -746,7 +740,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) char *params,*retstr,*hexstr; cJSON *retjson,*resobj; int32_t retval = -1; params = (char *)malloc(strlen(rawtx) + 16); sprintf(params,"[\"%s\"]",rawtx); - if ( (retstr= komodo_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,"sendrawtransaction",params,ROGUE_PORT)) != 0 ) { if ( 0 ) // causes 4th level crash { @@ -811,7 +805,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha if ( 0 && (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) { sprintf(params,"[\"extract\",\"17\",\"[%%22%s%%22]\"]",Gametxidstr); - if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { @@ -843,7 +837,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha hexstr[i<<1] = 0; if ( 0 ) { - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr); + sprintf(cmd,"./hush-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr); if ( system(cmd) != 0 ) fprintf(stderr,"error issuing (%s)\n",cmd); } @@ -853,7 +847,7 @@ int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,cha if ( fp == 0 ) fp = fopen("keystrokes.log","a"); sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr); - if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) + if ( (retstr= hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 ) { if ( fp != 0 ) { @@ -903,7 +897,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) if ( 0 ) { sprintf(fname,"%s.gameinfo",gametxidstr); - sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); + sprintf(cmd,"./hush-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname); if ( system(cmd) != 0 ) fprintf(stderr,"error issuing (%s)\n",cmd); else filestr = (char *)OS_fileptr(&allocsize,fname); @@ -911,7 +905,7 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) else { sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr); - filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); + filestr = hush_issuemethod(USERPASS,"cclib",params,ROGUE_PORT); } if ( filestr != 0 ) { @@ -1007,7 +1001,7 @@ int main(int argc, char **argv, char **envp) #endif #endif - ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL); + ROGUE_PORT = hush_userpass(userpass,ASSETCHAINS_SYMBOL); if ( IPADDRESS[0] == 0 ) strcpy(IPADDRESS,"127.0.0.1"); printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1); @@ -1035,7 +1029,7 @@ int main(int argc, char **argv, char **envp) fclose(fp); if ( ROGUE_PORT == 0 ) { - printf("you must copy ROGUE.conf from ~/.komodo/ROGUE/ROGUE.conf (or equivalent location) to current dir\n"); + printf("you must copy ROGUE.conf from ~/.hush/ROGUE/ROGUE.conf (or equivalent location) to current dir\n"); return(-1); } return(rogue(argc,argv,envp)); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 36ff0c26b..a26f8955c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -521,11 +521,15 @@ void hush_setactivation(int32_t height) void *chainparams_commandline() { CChainParams::CCheckpointData checkpointData; - if(fDebug) { + //if(fDebug) { fprintf(stderr,"chainparams_commandline called with port=%u\n", ASSETCHAINS_P2PPORT); - } + //} if ( SMART_CHAIN_SYMBOL[0] != 0 ) { + if (strcmp(SMART_CHAIN_SYMBOL,"HUSH3") == 0) { + ASSETCHAINS_P2PPORT = 18030; + } + if ( ASSETCHAINS_BLOCKTIME != 60 ) { pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks diff --git a/src/hush-cli b/src/hush-cli deleted file mode 100755 index ecd45bd74..000000000 --- a/src/hush-cli +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# Copyright (c) 2016-2021 The Hush developers -# Released under the GPLv3 - -# set working directory to the location of this script -# readlink -f does not always exist -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR -DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" -cd $DIR - -NAME=HUSH3 - -CLI=${KOMODOCLI:-./komodo-cli} -if [ -f $CLI ]; then - $CLI -ac_name=$NAME "$@" -else - # We prefix our binary when installed - # system wide on Debain systems, to prevent clashes, - # because we are classy like that. Fuck jl777, The KYC Traitor. - CLI=hush-komodo-cli - $CLI -ac_name=$NAME "$@" -fi diff --git a/src/hush-cli.bat b/src/hush-cli.bat deleted file mode 100644 index 802315b44..000000000 --- a/src/hush-cli.bat +++ /dev/null @@ -1,14 +0,0 @@ -@call :GET_CURRENT_DIR -@cd %THIS_DIR% -komodo-cli.exe -ac_name=HUSH3 %1 %2 %3 %4 %5 %6 %7 %8 %9 -@goto :EOF - -:GET_CURRENT_DIR -@pushd %~dp0 -@set THIS_DIR=%CD% -@popd -@goto :EOF - - - - diff --git a/src/hush-smart-chain b/src/hush-smart-chain index 537fdc9a3..c5543b221 100755 --- a/src/hush-smart-chain +++ b/src/hush-smart-chain @@ -7,18 +7,8 @@ cd $DIR DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" cd $DIR -NAME=HUSH3 -CLIENTNAME="GoldenSandtrout" -DEFAULTS="-ac_sapling=1 -clientname=$CLIENTNAME" +DEFAULTS="" -# This is a Hush-flavored KMD that allows us to pass in arbitary CLI -# flags, since hushd is specific to Hush mainnet -KMD=${KOMODOD:-./komodod} -if [ -f $KMD ]; then - $KMD $DEFAULTS "$@" -else - # We prefix our binary when installed - # system wide on Debain system, to prevent clashes - KMD=hush-komodod - $KMD $DEFAULTS "$@" -fi +# People should just use hushd going forward +HUSH="./hushd" +$HUSH $DEFAULTS "$@" diff --git a/src/hush-tx b/src/hush-tx deleted file mode 100755 index cbad82fc7..000000000 --- a/src/hush-tx +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Copyright (c) 2016-2021 The Hush developers -# Released under the GPLv3 - -# set working directory to the location of this script -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR - -NAME=HUSHT - -./komodo-tx -ac_name=$NAME "$@" diff --git a/src/hush-tx.bat b/src/hush-tx.bat deleted file mode 100644 index f3e24881d..000000000 --- a/src/hush-tx.bat +++ /dev/null @@ -1,14 +0,0 @@ -@call :GET_CURRENT_DIR -@cd %THIS_DIR% -komodo-tx.exe -ac_name=HUSH3 %1 %2 %3 %4 %5 %6 %7 %8 %9 -@goto :EOF - -:GET_CURRENT_DIR -@pushd %~dp0 -@set THIS_DIR=%CD% -@popd -@goto :EOF - - - - diff --git a/src/komodo-tx.cpp b/src/hush-tx.cpp similarity index 100% rename from src/komodo-tx.cpp rename to src/hush-tx.cpp diff --git a/src/hush.h b/src/hush.h index 14e8fd2f7..f4a871947 100644 --- a/src/hush.h +++ b/src/hush.h @@ -510,7 +510,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie } } -int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) +int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height) { static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; if ( (sp= hush_stateptr(symbol,dest)) == 0 ) @@ -535,7 +535,7 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) } else return(1); } -int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) +int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) { static uint256 zero; static FILE *signedfp; int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto555[33]; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; @@ -598,11 +598,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar matched = 0; if ( SMART_CHAIN_SYMBOL[0] == 0 ) { - if ( strcmp("KMD",(char *)&scriptbuf[len+32 * 2 + 4]) == 0 ) - matched = 1; - } - else - { + } else { if ( scriptbuf[len] == 'K' ) { //fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value)); @@ -631,7 +627,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( matched != 0 ) len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( matched != 0 ) - validated = komodo_validate_chain(srchash,*notarizedheightp); + validated = hush_validate_chain(srchash,*notarizedheightp); else validated = 1; // Any notarization that is matched and has a decodable op_return is enough to pay notaries. Otherwise bugs! if ( fJustCheck && matched != 0 ) @@ -775,12 +771,6 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar return(notaryid); } -/*int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) -{ - if ( isspecial != 0 && numvalid >= HUSH_MINRATIFY ) - return(1); - else return(0); -}*/ // Special tx have vout[0] -> CRYPTO555 address // with more than HUSH_MINRATIFY pay2pubkey outputs -> ratify @@ -818,7 +808,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(0); } memset(&zero,0,sizeof(zero)); - komodo_init(pindex->GetHeight()); + hush_init(pindex->GetHeight()); HUSH_INITDONE = (uint32_t)time(NULL); if ( (sp= hush_stateptr(symbol,dest)) == 0 ) { @@ -938,7 +928,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); - notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + notaryid = hush_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); if ( fJustCheck && notaryid == -2 ) { // We see a valid notarisation here, save its location. diff --git a/src/hush_bitcoind.h b/src/hush_bitcoind.h index 4b6af7e53..b41d3b85a 100644 --- a/src/hush_bitcoind.h +++ b/src/hush_bitcoind.h @@ -25,8 +25,8 @@ #include "sietch.h" int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); -int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); +int32_t hush_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); +int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); bool EnsureWalletIsAvailable(bool avoidException); extern bool fRequestShutdown; extern CScript HUSH_EARLYTXID_SCRIPTPUB; @@ -367,9 +367,8 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) +char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port) { - //static void *cHandle; char url[512],*retstr=0,*retstr2=0,postdata[8192]; if ( params == 0 || params[0] == 0 ) params = (char *)"[]"; @@ -384,11 +383,11 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } -int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp) +int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp) { char *jsonstr,params[256],*userpass; uint16_t port; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0; params[0] = 0; - *kmdnotarized_heightp = 0; + *hushnotarized_heightp = 0; if ( strcmp(dest,"HUSH3") == 0 ) { port = HUSH3_PORT; userpass = HUSHUSERPASS; @@ -401,7 +400,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig } if ( userpass[0] != 0 ) { - if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 ) + if ( (jsonstr= hush_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 ) { //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) @@ -409,14 +408,14 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig if ( (item= jobj(json,(char *)"result")) != 0 ) { height = jint(item,(char *)"blocks"); - *kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height; + *hushnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height; } free_json(json); } free(jsonstr); } sprintf(params,"[\"%s\", 1]",txidstr); - if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 ) + if ( (jsonstr= hush_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 ) { //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) @@ -437,7 +436,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig return(txid_height); } -int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) +int32_t hush_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) { int32_t i; uint256 hash; char params[256]; for (i=0; i<32; i++) @@ -453,19 +452,19 @@ int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len, return(-1); } -void komodo_reconsiderblock(uint256 blockhash) +void hush_reconsiderblock(uint256 blockhash) { char params[256],*jsonstr,*hexstr; sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); - if ( (jsonstr= komodo_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 ) + if ( (jsonstr= hush_issuemethod(ASSETCHAINS_USERPASS,(char *)"reconsiderblock",params,ASSETCHAINS_RPCPORT)) != 0 ) { - //fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr); + //fprintf(stderr,"hush_reconsiderblock.(%s) (%s %u) -> (%s)\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT,jsonstr); free(jsonstr); } - //fprintf(stderr,"komodo_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT); + //fprintf(stderr,"hush_reconsiderblock.(%s) (%s %u) -> NULL\n",params,ASSETCHAINS_USERPASS,ASSETCHAINS_RPCPORT); } -int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) +int32_t hush_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { char params[256],*jsonstr,*hexstr; uint8_t *script,_script[8192]; int32_t n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; script = _script; @@ -475,34 +474,30 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - if ( strcmp(symbol,SMART_CHAIN_SYMBOL[0]==0?(char *)"KMD":SMART_CHAIN_SYMBOL) != 0 ) + if ( strcmp(symbol,SMART_CHAIN_SYMBOL[0]==0?(char *)"HUSH3":SMART_CHAIN_SYMBOL) != 0 ) return(0); if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 ) printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",SMART_CHAIN_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); - if ( strcmp(dest,"KMD") == 0 ) + if ( strcmp(dest,"HUSH3") == 0 ) { if ( HUSHUSERPASS[0] != 0 ) { if ( SMART_CHAIN_SYMBOL[0] != 0 ) { - jsonstr = komodo_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT); + jsonstr = hush_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT); //printf("userpass.(%s) got (%s)\n",HUSHUSERPASS,jsonstr); } }//else jsonstr = _dex_getrawtransaction(); else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok - } - else if ( strcmp(dest,"BTC") == 0 ) - { + } else if ( strcmp(dest,"BTC") == 0 ) { if ( BTCUSERPASS[0] != 0 ) { //printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); - jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); + jsonstr = hush_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); } //else jsonstr = _dex_getrawtransaction(); else return(0); - } - else - { + } else { printf("[%s] verifynotarization error unexpected dest.(%s)\n",SMART_CHAIN_SYMBOL,dest); return(-1); } @@ -532,7 +527,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t script += 2; len -= 2; } - retval = komodo_verifynotarizedscript(height,script,len,NOTARIZED_HASH); + retval = hush_verifynotarizedscript(height,script,len,NOTARIZED_HASH); } } } @@ -543,7 +538,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t return(retval); } -CScript komodo_makeopret(CBlock *pblock, bool fNew) +CScript hush_makeopret(CBlock *pblock, bool fNew) { std::vector vLeaves; vLeaves.push_back(pblock->hashPrevBlock); @@ -560,7 +555,7 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew) uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32]; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); - if ( (jsonstr= komodo_issuemethod(HUSHUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 ) + if ( (jsonstr= hush_issuemethod(HUSHUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 ) { if ( (result= cJSON_Parse(jsonstr)) != 0 ) { @@ -613,7 +608,7 @@ uint64_t komodo_seed(int32_t height) return(seed); } -uint32_t komodo_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr) +uint32_t hush_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr) { CTxDestination address; CTransaction tx; uint256 hashBlock; int32_t numvouts; *valuep = 0; @@ -644,36 +639,10 @@ CBlockIndex *hush_getblockindex(uint256 hash) return((it != mapBlockIndex.end()) ? it->second : NULL); } -uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr) -{ - CTxDestination address; CBlockIndex *pindex; CTransaction tx; uint256 hashBlock; uint32_t txtime = 0; - *valuep = 0; - if (!GetTransaction(hash, tx, -#ifndef HUSH_ZCASH - Params().GetConsensus(), -#endif - hashBlock, true)) - { - //fprintf(stderr,"ERROR: %s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime); - return(0); - } - if ( (pindex= hush_getblockindex(hashBlock)) != 0 ) - txtime = pindex->nTime; - else txtime = tx.nLockTime; - //fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime); - if ( n < tx.vout.size() ) - { - *valuep = tx.vout[n].nValue; - if (ExtractDestination(tx.vout[n].scriptPubKey, address)) - strcpy(destaddr,CBitcoinAddress(address).ToString().c_str()); - } - return(txtime); -} - bool hush_checkopret(CBlock *pblock, CScript &merkleroot) { merkleroot = pblock->vtx.back().vout.back().scriptPubKey; - return(merkleroot.IsOpReturn() && merkleroot == komodo_makeopret(pblock, false)); + return(merkleroot.IsOpReturn() && merkleroot == hush_makeopret(pblock, false)); } @@ -699,7 +668,7 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block) { char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; //fprintf(stderr,"disconnect ht.%d\n",pindex->GetHeight()); - komodo_init(pindex->GetHeight()); + hush_init(pindex->GetHeight()); if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { //sp->rewinding = pindex->GetHeight(); @@ -754,7 +723,7 @@ int32_t hush_block2height(CBlock *block) } //printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height); } - //komodo_init(height); + //hush_init(height); } if ( height != height2 ) { @@ -913,7 +882,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) } } fprintf(stderr,"komodo_minerid height.%d null pindex\n",height); - return(komodo_electednotary(&numnotaries,pubkey33,height,timestamp)); + return(hush_electednotary(&numnotaries,pubkey33,height,timestamp)); }*/ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height) @@ -1029,7 +998,7 @@ int32_t hush_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex; if ( (pindex= chainActive.LastTip()) == 0 ) return(-1); - notarized_height = komodo_notarizeddata(pindex->GetHeight(),¬arized_hash,¬arized_desttxid); + notarized_height = hush_notarizeddata(pindex->GetHeight(),¬arized_hash,¬arized_desttxid); *notarized_heightp = notarized_height; BlockMap::const_iterator it; if ( notarized_height >= 0 && notarized_height <= pindex->GetHeight() && (it = mapBlockIndex.find(notarized_hash)) != mapBlockIndex.end() && (notary = it->second) != NULL ) @@ -1282,7 +1251,7 @@ int8_t hush_segid(int32_t nocache,int32_t height) { txid = block.vtx[txn_count-1].vin[0].prevout.hash; vout = block.vtx[txn_count-1].vin[0].prevout.n; - txtime = komodo_txtime(opret,&value,txid,vout,destaddr); + txtime = hush_txtime(opret,&value,txid,vout,destaddr); if ( ExtractDestination(block.vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); @@ -1493,7 +1462,7 @@ int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *scri if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,script,len); - if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) != -2 ) + if ( hush_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) != -2 ) { fprintf(stderr, "<<<<<len = len; ep->height = height; @@ -35,7 +35,7 @@ struct hush_event *hush_eventadd(struct hush_state *sp,int32_t height,char *symb memcpy(ep->space,data,datalen); sp->Hush_events = (struct hush_event **)realloc(sp->Hush_events,(1 + sp->Hush_numeventss) * sizeof(*sp->Hush_events)); sp->Hush_events[sp->Hush_numeventss++] = ep; - portable_mutex_unlock(&komodo_mutex); + portable_mutex_unlock(&hush_mutex); } return(ep); } @@ -43,8 +43,8 @@ struct hush_event *hush_eventadd(struct hush_state *sp,int32_t height,char *symb void hush_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth) { static uint32_t counter; int32_t verified=0; char *coin; struct hush_event_notarized N; - coin = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL; - if ( IS_HUSH_NOTARY != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + coin = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL; + if ( IS_HUSH_NOTARY != 0 && (verified= hush_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { if ( counter++ < 100 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",SMART_CHAIN_SYMBOL,height,notarizedheight,dest); @@ -62,7 +62,7 @@ void hush_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,c strncpy(N.dest,dest,sizeof(N.dest)-1); hush_eventadd(sp,height,symbol,HUSH_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); if ( sp != 0 ) - komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid,MoM,MoMdepth); + hush_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid,MoM,MoMdepth); } } @@ -75,7 +75,7 @@ void hush_eventadd_pubkeys(struct hush_state *sp,char *symbol,int32_t height,uin memcpy(P.pubkeys,pubkeys,33 * num); hush_eventadd(sp,height,symbol,HUSH_EVENT_RATIFY,(uint8_t *)&P,(int32_t)(sizeof(P.num) + 33 * num)); if ( sp != 0 ) - komodo_notarysinit(height,pubkeys,num); + hush_notarysinit(height,pubkeys,num); } void hush_eventadd_pricefeed(struct hush_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num) diff --git a/src/hush_gateway.h b/src/hush_gateway.h index 9beabb6fb..8b28c9b8c 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -32,7 +32,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, { int32_t baseid; struct hush_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; - if ( (baseid= komodo_baseid(base)) >= 0 ) + if ( (baseid= hush_baseid(base)) >= 0 ) { if ( (sp= hush_stateptrget(base)) != 0 ) { @@ -65,10 +65,10 @@ void pax_keyset(uint8_t *buf,uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) { struct pax_transaction *pax; uint8_t buf[35]; - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); pax_keyset(buf,txid,vout,type); HASH_FIND(hh,PAX,buf,sizeof(buf),pax); - pthread_mutex_unlock(&komodo_mutex); + pthread_mutex_unlock(&hush_mutex); return(pax); } @@ -84,7 +84,7 @@ struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,uint8_t type,int32_t mark) { struct pax_transaction *pax; uint8_t buf[35]; - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); pax_keyset(buf,txid,vout,type); HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) @@ -104,16 +104,16 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); } - pthread_mutex_unlock(&komodo_mutex); + pthread_mutex_unlock(&hush_mutex); return(pax); } void komodo_paxdelete(struct pax_transaction *pax) { return; // breaks when out of order - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); HASH_DELETE(hh,PAX,pax); - pthread_mutex_unlock(&komodo_mutex); + pthread_mutex_unlock(&hush_mutex); } void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context @@ -124,7 +124,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t //if ( strcmp(symbol,SMART_CHAIN_SYMBOL) != 0 ) // return; sp = hush_stateptr(str,dest); - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); pax_keyset(buf,txid,vout,type); HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) @@ -143,7 +143,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%s\n",vout,SMART_CHAIN_SYMBOL,height,otherheight,pax,symbol,source); } } - pthread_mutex_unlock(&komodo_mutex); + pthread_mutex_unlock(&hush_mutex); if ( coinaddr != 0 ) { strcpy(pax->coinaddr,coinaddr); @@ -241,7 +241,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); - baseids[n] = komodo_baseid(p.source); + baseids[n] = hush_baseid(p.source); if ( 0 ) { char coinaddr[64]; @@ -261,7 +261,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; - baseids[n] = komodo_baseid(base); + baseids[n] = hush_baseid(base); if ( (pax= komodo_paxfinds(txids[n],vouts[n])) != 0 ) { values[n] = (strcmp("KMD",base) == 0) ? pax->komodoshis : pax->fiatoshis; @@ -483,7 +483,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to struct hush_state *kmdsp = hush_stateptrget((char *)"KMD"); sp = hush_stateptr(symbol,dest); strcpy(symbol,base); - if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 ) + if ( SMART_CHAIN_SYMBOL[0] != 0 && hush_baseid(SMART_CHAIN_SYMBOL) < 0 ) return(0); PENDING_HUSH_TX = 0; for (i=0; i<3; i++) @@ -556,7 +556,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { if ( kmdsp != 0 ) { - if ( (baseid= komodo_baseid(pax->symbol)) < 0 || ((1LL << baseid) & sp->RTmask) == 0 ) + if ( (baseid= hush_baseid(pax->symbol)) < 0 || ((1LL << baseid) & sp->RTmask) == 0 ) { printf("not RT for (%s) %llx baseid.%d %llx\n",pax->symbol,(long long)sp->RTmask,baseid,(long long)(1LL< 814000 ) { script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; - //int32_t notary = komodo_electednotary(&num,script+1,height,0); - //if ( (-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)) < 0 ) + //int32_t notary = hush_electednotary(&num,script+1,height,0); + //if ( (-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)) < 0 ) // fprintf(stderr, ">>>>>>> FAILED BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC); //else // fprintf(stderr, "<<<<<<< VALID BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC); - return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); + return(-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); } } else @@ -832,7 +832,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct hush_state *basesp; double diff; const char *typestr = "unknown"; - if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 && opretbuf[0] != 'K' ) + if ( SMART_CHAIN_SYMBOL[0] != 0 && hush_baseid(SMART_CHAIN_SYMBOL) < 0 && opretbuf[0] != 'K' ) { //printf("komodo_opreturn skip %s\n",SMART_CHAIN_SYMBOL); return("assetchain"); @@ -991,7 +991,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( height < 236000 && opretbuf[0] == 'W' && strncmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 )//&& opretlen >= 38 ) { - if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 ) + if ( hush_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 ) { for (i=0; isymbol); + baseids[i] = hush_baseid(pax->symbol); printf("override neg1 with (%s)\n",pax->symbol); } if ( baseids[i] < 0 ) @@ -1444,7 +1444,7 @@ void hush_passport_iteration() limit = 10000000; } else { limit = 10000000; - refid = komodo_baseid(SMART_CHAIN_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 + refid = hush_baseid(SMART_CHAIN_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 if ( refid == 0 ) { HUSH_PASSPORT_INITDONE = 1; @@ -1753,10 +1753,10 @@ CScript komodo_mineropret(int32_t nHeight) } /* - komodo_opretvalidate() is the entire price validation! + hush_opretvalidate() is the entire price validation! it prints out some useful info for debugging, like the lag from current time and prev block and the prices encoded in the opreturn. - The only way komodo_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. + The only way hush_opretvalidate() doesnt return an error is if maxflag is set or it is within tolerance of both the prior block and the local data. The local data validation only happens if it is a recent block and not a block from the past as the local node is only getting the current price data. */ @@ -1772,7 +1772,7 @@ void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint25 ExtremePrice.pricebits = pricebits; } -int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) +int32_t hush_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey) { int32_t testchain_exemption = 0; std::vector vopret; char maxflags[HUSH_MAXPRICES]; uint256 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[HUSH_MAXPRICES],pricebits[HUSH_MAXPRICES],prevbits[HUSH_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now; @@ -2228,7 +2228,7 @@ void hush_cbopretupdate(int32_t forceflag) if ( Queued_reconsiderblock != zeroid ) { fprintf(stderr,"Queued_reconsiderblock %s\n",Queued_reconsiderblock.GetHex().c_str()); - komodo_reconsiderblock(Queued_reconsiderblock); + hush_reconsiderblock(Queued_reconsiderblock); Queued_reconsiderblock = zeroid; } if ( forceflag != 0 && pending != 0 ) diff --git a/src/hush_globals.h b/src/hush_globals.h index 7bd1222b8..295f848b1 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -20,11 +20,11 @@ void hush_prefetch(FILE *fp); uint32_t hush_heightstamp(int32_t height); void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth); -void komodo_init(int32_t height); +void hush_init(int32_t height); int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); -char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port); -void komodo_init(int32_t height); +int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); +char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port); +void hush_init(int32_t height); int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); @@ -32,7 +32,7 @@ int32_t hush_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts); -pthread_mutex_t komodo_mutex,staked_mutex; +pthread_mutex_t hush_mutex; #define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100) #define HUSH_SMART_CHAIN_MAXLEN 65 @@ -111,7 +111,7 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "KMD" }; -int32_t komodo_baseid(char *origbase) +int32_t hush_baseid(char *origbase) { int32_t i; char base[64]; for (i=0; origbase[i]!=0&&i= 0 && baseid < 32 ) + //if ( (baseid = hush_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 ) // cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; //else { diff --git a/src/hush_kv.h b/src/hush_kv.h index 3fdde30ff..b64522f36 100644 --- a/src/hush_kv.h +++ b/src/hush_kv.h @@ -104,7 +104,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) { static uint256 zeroes; uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; - if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV for KMD + if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV return; dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); dragon_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize); diff --git a/src/hush_nSPV.h b/src/hush_nSPV.h index b2576f7ea..f8e1645d1 100644 --- a/src/hush_nSPV.h +++ b/src/hush_nSPV.h @@ -578,7 +578,7 @@ int32_t NSPV_notarizationextract(int32_t verifyntz,int32_t *ntzheightp,uint256 * int32_t numsigs=0; uint8_t elected[64][33]; char *symbol; std::vector opret; uint32_t nTime; if ( tx.vout.size() >= 2 ) { - symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL; + symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL; GetOpReturnData(tx.vout[1].scriptPubKey,opret); if ( opret.size() >= 32*2+4 ) { diff --git a/src/hush_nSPV_fullnode.h b/src/hush_nSPV_fullnode.h index 53770f430..a33013b6a 100644 --- a/src/hush_nSPV_fullnode.h +++ b/src/hush_nSPV_fullnode.h @@ -38,7 +38,7 @@ struct NSPV_ntzargs int32_t NSPV_notarization_find(struct NSPV_ntzargs *args,int32_t height,int32_t dir) { int32_t ntzheight = 0; uint256 hashBlock; CTransaction tx; Notarization nota; char *symbol; std::vector opret; - symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL; + symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"HUSH3" : SMART_CHAIN_SYMBOL; memset(args,0,sizeof(*args)); if ( dir > 0 ) height += 10; diff --git a/src/hush_notary.h b/src/hush_notary.h index 53a4c0a33..311ed782e 100644 --- a/src/hush_notary.h +++ b/src/hush_notary.h @@ -120,7 +120,7 @@ int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) return(-1); } -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +int32_t hush_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) { int32_t i,n; uint8_t pubkeys[64][33]; n = hush_notaries(pubkeys,height,timestamp); @@ -133,22 +133,7 @@ int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t hei return(-1); } -int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) -{ - int32_t htind,numnotaries,i,wt = 0; - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +void hush_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) { static int32_t hwmheight; int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; @@ -165,7 +150,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,SMART_CHAIN_SYMBOL); } else htind = 0; - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); for (k=0; k hwmheight ) hwmheight = origheight; } @@ -207,7 +192,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui } if ( height >= HUSH_NOTARIES_HARDCODED || SMART_CHAIN_SYMBOL[0] != 0 ) { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + if ( (*notaryidp= hush_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) { modval = ((height % numnotaries) == *notaryidp); return(modval); @@ -216,13 +201,13 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui if ( height >= 250000 ) return(-1); if ( Pubkeys == 0 ) - komodo_init(0); + hush_init(0); htind = height / KOMODO_ELECTION_GAP; if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP ) htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); + pthread_mutex_lock(&hush_mutex); HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); + pthread_mutex_unlock(&hush_mutex); if ( kp != 0 ) { if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) @@ -355,7 +340,7 @@ int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int3 return(0); } -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) { struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; if ( (sp= hush_stateptr(symbol,dest)) != 0 ) @@ -411,17 +396,17 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n return(0); } -void komodo_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +void hush_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { struct notarized_checkpoint *np; if ( notarized_height >= nHeight ) { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + fprintf(stderr,"hush_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",SMART_CHAIN_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); + fprintf(stderr,"[%s] hush_notarized_update nHeight.%d notarized_height.%d\n",SMART_CHAIN_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&hush_mutex); sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); @@ -431,18 +416,18 @@ void komodo_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notar sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; sp->MoM = np->MoM = MoM; sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); + portable_mutex_unlock(&hush_mutex); } -void komodo_init(int32_t height) +void hush_init(int32_t height) { static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); + printf("hush_init ht.%d didinit.%d\n",height,didinit); memset(&zero,0,sizeof(zero)); if ( didinit == 0 ) { - pthread_mutex_init(&komodo_mutex,NULL); + pthread_mutex_init(&hush_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); if ( height >= 0 ) { @@ -453,7 +438,7 @@ void komodo_init(int32_t height) break; decode_hex(pubkeys[k],33,(char *)Notaries_genesis[k][1]); } - komodo_notarysinit(0,pubkeys,k); + hush_notarysinit(0,pubkeys,k); } //for (i=0; i 10 ) height -= 10; - if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 ) + if ( (baseid= hush_baseid(base)) >= 0 && (relid= hush_baseid(rel)) >= 0 ) { - //portable_mutex_lock(&komodo_mutex); + //portable_mutex_lock(&hush_mutex); for (i=NUM_PRICES-1; i>=0; i--) { ptr = &PVALS[36 * i]; @@ -516,13 +516,13 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha *kmdbtcp = pvals[MAX_CURRENCIES] / 539; *btcusdp = pvals[MAX_CURRENCIES + 1] / 539; } - //portable_mutex_unlock(&komodo_mutex); + //portable_mutex_unlock(&hush_mutex); if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(height,pvals,baseid,relid,basevolume,kmdbtc,btcusd)); else return(0); } } - //portable_mutex_unlock(&komodo_mutex); + //portable_mutex_unlock(&hush_mutex); } //else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid); return(0); } @@ -607,7 +607,7 @@ uint64_t _komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uin uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume) { - uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base); + uint64_t baseusd,basekmd,usdkmd; int32_t baseid = hush_baseid(base); if ( height >= 236000 && strcmp(rel,"kmd") == 0 ) { usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN); @@ -623,7 +623,7 @@ uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint /*uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume) { - uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base); + uint64_t baseusd,basekmd,usdkmd; int32_t baseid = hush_baseid(base); //if ( strcmp(rel,"KMD") != 0 || baseid < 0 || MINDENOMS[baseid] == MINDENOMS[USD] ) // return(_komodo_paxpriceB(seed,height,base,rel,basevolume)); //else @@ -651,7 +651,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin return(0); } *seedp = komodo_seed(height); - portable_mutex_lock(&komodo_mutex); + portable_mutex_lock(&hush_mutex); for (i=0; i<17; i++) { if ( (price= komodo_paxpriceB(*seedp,height-i,base,rel,basevolume)) != 0 ) @@ -682,7 +682,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( height < 165000 || height > 236000 ) break; } - portable_mutex_unlock(&komodo_mutex); + portable_mutex_unlock(&hush_mutex); if ( nonz != 0 ) sum /= nonz; //printf("-> %lld %s/%s i.%d ht.%d\n",(long long)sum,base,rel,i,height); @@ -692,7 +692,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) { int32_t baseid=-1,relid=-1,i,num = 0; uint32_t *ptr; - if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 ) + if ( (baseid= hush_baseid(base)) >= 0 && (relid= hush_baseid(rel)) >= 0 ) { for (i=NUM_PRICES-1; i>=0; i--) { @@ -726,7 +726,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu { uint8_t shortflag = 0; char base[4]; int32_t i,baseid; uint8_t addrtype,rmd160[20]; int64_t komodoshis = 0; *seedp = komodo_seed(height); - if ( (baseid= komodo_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES ) + if ( (baseid= hush_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES ) { if ( 0 && origbase[0] != 0 ) printf("[%s] PAX_fiatdest illegal base.(%s)\n",SMART_CHAIN_SYMBOL,origbase); diff --git a/src/hush_utils.h b/src/hush_utils.h index 439d85eab..d7f56ea87 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -811,7 +811,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160, int32_t komodo_is_issuer() { - if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) >= 0 ) + if ( SMART_CHAIN_SYMBOL[0] != 0 && hush_baseid(SMART_CHAIN_SYMBOL) >= 0 ) return(1); else return(0); } @@ -1295,7 +1295,7 @@ void dragon_initQ(queue_t *Q,char *name) free(item); } -uint16_t _komodo_userpass(char *username,char *password,FILE *fp) +uint16_t _hush_userpass(char *username,char *password,FILE *fp) { char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; @@ -1366,10 +1366,10 @@ void hush_statefname(char *fname,char *symbol,char *str) //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,SMART_CHAIN_SYMBOL,symbol,fname); } -void komodo_configfile(char *symbol,uint16_t rpcport) +void hush_configfile(char *symbol,uint16_t rpcport) { static char myusername[512],mypassword[8192]; - FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i; + FILE *fp; uint16_t hushport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i; if ( symbol != 0 && rpcport != 0 ) { r = (uint32_t)time(NULL); @@ -1398,13 +1398,13 @@ void komodo_configfile(char *symbol,uint16_t rpcport) #ifndef FROM_CLI if ( (fp= fopen(fname,"wb")) != 0 ) { - fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=256\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport); + fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=4096\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport); fclose(fp); printf("Created (%s)\n",fname); } else printf("Couldnt create (%s)\n",fname); #endif } else { - _komodo_userpass(myusername,mypassword,fp); + _hush_userpass(myusername,mypassword,fp); mapArgs["-rpcpassword"] = mypassword; mapArgs["-rpcusername"] = myusername; //fprintf(stderr,"myusername.(%s)\n",myusername); @@ -1415,43 +1415,39 @@ void komodo_configfile(char *symbol,uint16_t rpcport) #ifdef _WIN32 while ( fname[strlen(fname)-1] != '\\' ) fname[strlen(fname)-1] = 0; - strcat(fname,"komodo.conf"); + strcat(fname,"HUSH3.conf"); #else while ( fname[strlen(fname)-1] != '/' ) fname[strlen(fname)-1] = 0; #ifdef __APPLE__ - strcat(fname,"Komodo.conf"); + strcat(fname,"HUSH3.conf"); #else - strcat(fname,"komodo.conf"); + strcat(fname,"HUSH3.conf"); #endif #endif if ( (fp= fopen(fname,"rb")) != 0 ) { - if ( (kmdport= _komodo_userpass(username,password,fp)) != 0 ) - HUSH3_PORT = kmdport; + if ( (hushport= _hush_userpass(username,password,fp)) != 0 ) + HUSH3_PORT = hushport; sprintf(HUSHUSERPASS,"%s:%s",username,password); fclose(fp); //printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS); - } //else printf("couldnt open.(%s)\n",fname); + } else { + printf("could not open.(%s)\n",fname); + } } -uint16_t komodo_userpass(char *userpass,char *symbol) +uint16_t hush_userpass(char *userpass,char *symbol) { FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN]; userpass[0] = 0; - if ( strcmp("SPECIAL",symbol) == 0 ) - { -#ifdef __APPLE__ - sprintf(confname,"Something.conf"); -#else - sprintf(confname,"Something.conf"); -#endif - } - else sprintf(confname,"%s.conf",symbol); + + sprintf(confname,"%s.conf",symbol); + hush_statefname(fname,symbol,confname); if ( (fp= fopen(fname,"rb")) != 0 ) { - port = _komodo_userpass(username,password,fp); + port = _hush_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); if ( strcmp(symbol,SMART_CHAIN_SYMBOL) == 0 ) strcpy(ASSETCHAINS_USERPASS,userpass); @@ -1477,7 +1473,14 @@ uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t fprintf(stderr,"%02x",extraptr[i]); fprintf(stderr," extralen=%d crc0=%x\n",extralen,crc0); } - return(calc_crc32(crc0,buf,len)); + + //TODO: why is this needed? + bool ishush3 = strncmp(symbol, "HUSH3",5) == 0 ? true : false; + if(ishush3) { + return HUSH_MAGIC; + } else { + return(calc_crc32(crc0,buf,len)); + } } uint16_t hush_smartport(uint32_t magic,int32_t extralen) @@ -1494,13 +1497,9 @@ uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extrap { if(fDebug) fprintf(stderr,"%s: extralen=%d\n",__func__,extralen); - if ( strcmp("SPECIAL",symbol) == 0 ) - { - *magicp = 0xdeadbeef; - return(6969); - } + *magicp = hush_smartmagic(symbol,supply,extraptr,extralen); - if(fDebug) + //if(fDebug) fprintf(stderr,"%s: extralen=%d, supply=%lu\n",__func__,extralen, supply); return(hush_smartport(*magicp,extralen)); @@ -1739,7 +1738,7 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k) * EhBasicSolve * EhOptimisedSolve * EhIsValidSolution - * Alternatively change ASSETCHAINS_N and ASSETCHAINS_K in komodo_nk.h for fast testing. + * Alternatively change ASSETCHAINS_N and ASSETCHAINS_K in hush_nk.h for fast testing. */ if ( k == 9 && (n == 200 || n == 210) ) return(0); @@ -1750,8 +1749,6 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k) return(-1); } -char *dragonfmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"dragon\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\""; - void hush_args(char *argv0) { std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; @@ -1767,15 +1764,9 @@ void hush_args(char *argv0) { HUSH_MININGTHREADS = GetArg("-genproclimit",-1); } - if ( (GetBoolArg("-exchange", false)) != 0 ) { - printf("The KMD-only feature -exchange is not supported by HUSH!\n"); - printf("jl777 uses this \"feature\" to steal from his own users!\n"); - printf("Learn more at https://duke.hush.is :)\n"); - StartShutdown(); - } DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); - HUSH_DEALERNODE = GetArg("-dealer",0); + HUSH_DEALERNODE = GetArg("-dealer",0); HUSH_TESTNODE = GetArg("-testnode",0); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) @@ -1801,7 +1792,7 @@ void hush_args(char *argv0) } } - name = GetArg("-ac_name",""); + name = GetArg("-ac_name","HUSH3"); if ( argv0 != 0 ) { len = (int32_t)strlen(argv0); @@ -1816,12 +1807,17 @@ void hush_args(char *argv0) } } } + vector HUSH_nodes= {"node1.hush.is","node2.hush.is","node3.hush.is", + "node4.hush.is","node5.hush.is","node6.hush.is", + "node7.hush.is","node8.hush.is"}; + mapMultiArgs["-addnode"] = HUSH_nodes; HUSH_STOPAT = GetArg("-stopat",0); MAX_REORG_LENGTH = GetArg("-maxreorg",MAX_REORG_LENGTH); WITNESS_CACHE_SIZE = MAX_REORG_LENGTH+10; ASSETCHAINS_CC = GetArg("-ac_cc",0); HUSH_CCACTIVATE = GetArg("-ac_ccactivate",0); ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60); + // We do not support ac_public=1 chains, Hush is a platform for privacy ASSETCHAINS_PUBLIC = 0; ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); HUSH_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0); @@ -1886,7 +1882,14 @@ void hush_args(char *argv0) printf("ASSETCHAINS_ALGO, %s not supported. using equihash\n", selectedAlgo.c_str()); } + // Set our symobl from -ac_name value + strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1); + bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1); + if(ishush3) { + ASSETCHAINS_LASTERA = 3; + } if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS ) { ASSETCHAINS_LASTERA = 1; @@ -1910,10 +1913,29 @@ void hush_args(char *argv0) Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0); Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); - bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + MAX_BLOCK_SIGOPS = 60000; + ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; + ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); + ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); + ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + + fprintf(stderr,"%s: Setting custom %s reward HUSH3=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, ishush3); if(ishush3) { - fprintf(stderr,"%s: Setting custom HUSH3 reward,halving,subsidy chain values...\n",__func__); + // Migrated from hushd script + ASSETCHAINS_CC = 2; + ASSETCHAINS_BLOCKTIME = 150; // this will change to 75 at the correct block + ASSETCHAINS_COMMISSION = 11111111; + // 6250000 - (Sprout pool at block 500,000) + ASSETCHAINS_SUPPLY = 6178674; + ASSETCHAINS_FOUNDERS = 1; + ASSETCHAINS_SAPLING = 1; + // this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn + ASSETCHAINS_SCRIPTPUB = "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac"; + // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things ASSETCHAINS_REWARD[0] = 0; ASSETCHAINS_REWARD[1] = 1125000000; @@ -1944,11 +1966,6 @@ void hush_args(char *argv0) } } - MAX_BLOCK_SIGOPS = 60000; - ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; - ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; - ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); - ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); if ( ASSETCHAINS_SUPPLY > (uint64_t)90*1000*1000000 ) { fprintf(stderr,"-ac_supply must be less than 90 billion, derpz\n"); @@ -1957,9 +1974,6 @@ void hush_args(char *argv0) if(fDebug) fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY); - ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); - ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); - ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); @@ -1998,8 +2012,10 @@ void hush_args(char *argv0) if ( ASSETCHAINS_CC != 0 ) { uint8_t prevCCi = 0; - ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); - Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); + ASSETCHAINS_CCLIB = GetArg("-ac_cclib","hush3"); + + // these are the enabled CCs on HUSH3 mainnet + Split(GetArg("-ac_ccenable","228,234,235,236,241"), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); for (i=nonz=0; i<0x100; i++) { if ( ccenables[i] != prevCCi && ccenables[i] != 0 ) @@ -2080,7 +2096,7 @@ void hush_args(char *argv0) } // HUSH will always be The First Pure Sapling Coin, no Sprout JoinSplits in our history! ;) - ASSETCHAINS_SAPLING = GetArg("-ac_sapling", -1); + ASSETCHAINS_SAPLING = GetArg("-ac_sapling", 1); if (ASSETCHAINS_SAPLING == -1) { ASSETCHAINS_OVERWINTER = GetArg("-ac_overwinter", -1); @@ -2298,11 +2314,9 @@ void hush_args(char *argv0) if ( strlen(addn.c_str()) > 0 ) ASSETCHAINS_SEED = 1; - strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1); - MAX_MONEY = hush_max_money(); - if ( (baseid = komodo_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 ) + if ( (baseid = hush_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 ) { //komodo_maxallowed(baseid); if(fDebug) @@ -2320,6 +2334,10 @@ void hush_args(char *argv0) if ( GetArg("-port",0) != 0 ) { ASSETCHAINS_P2PPORT = GetArg("-port",0); + if(ishush3) { + fprintf(stderr,"set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT); + ASSETCHAINS_P2PPORT = 18030; + } if(fDebug) fprintf(stderr,"set p2pport.%u\n",ASSETCHAINS_P2PPORT); } else ASSETCHAINS_P2PPORT = tmpport; @@ -2336,15 +2354,11 @@ void hush_args(char *argv0) //fprintf(stderr,"Got datadir.(%s)\n",dirname); if ( SMART_CHAIN_SYMBOL[0] != 0 ) { - int32_t komodo_baseid(char *origbase); + int32_t hush_baseid(char *origbase); extern int COINBASE_MATURITY; - if ( strcmp(SMART_CHAIN_SYMBOL,"KMD") == 0 ) - { - fprintf(stderr,"Oh hellz yezzz\n"); - } - if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,SMART_CHAIN_SYMBOL)) != 0 ) + if ( (port= hush_userpass(ASSETCHAINS_USERPASS,SMART_CHAIN_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; - else komodo_configfile(SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT + 1); + else hush_configfile(SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT + 1); if (ASSETCHAINS_CBMATURITY != 0) COINBASE_MATURITY = ASSETCHAINS_CBMATURITY; @@ -2365,21 +2379,7 @@ void hush_args(char *argv0) for (i=0; i<4; i++) sprintf(&magicstr[i<<1],"%02x",magic[i]); magicstr[8] = 0; -#ifndef FROM_CLI - /* - sprintf(fname,"%s_7776",SMART_CHAIN_SYMBOL); - // TODO: why are we doing this again? Most users do not need this - if ( (fp= fopen(fname,"wb")) != 0 ) - { - int8_t notarypay = 0; - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) - notarypay = 1; - fprintf(fp,dragonfmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay); - fclose(fp); - //printf("created (%s)\n",fname); - } else printf("error creating (%s)\n",fname); - */ -#endif + if ( ASSETCHAINS_CC < 2 ) { if ( HUSH_CCACTIVATE != 0 ) @@ -2402,24 +2402,24 @@ void hush_args(char *argv0) while ( fname[strlen(fname)-1] != '\\' ) fname[strlen(fname)-1] = 0; if ( iter == 0 ) - strcat(fname,"Komodo\\komodo.conf"); + strcat(fname,"Hush\\HUSH3\\HUSH3.conf"); else strcat(fname,"Bitcoin\\bitcoin.conf"); #else while ( fname[strlen(fname)-1] != '/' ) fname[strlen(fname)-1] = 0; #ifdef __APPLE__ if ( iter == 0 ) - strcat(fname,"Komodo/Komodo.conf"); + strcat(fname,"Hush/HUSH3/HUSH3.conf"); else strcat(fname,"Bitcoin/Bitcoin.conf"); #else if ( iter == 0 ) - strcat(fname,".komodo/komodo.conf"); + strcat(fname,".hush/HUSH3/HUSH3.conf"); else strcat(fname,".bitcoin/bitcoin.conf"); #endif #endif if ( (fp= fopen(fname,"rb")) != 0 ) { - _komodo_userpass(username,password,fp); + _hush_userpass(username,password,fp); sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password); fclose(fp); //printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS); @@ -2463,7 +2463,7 @@ struct hush_state *hush_stateptrget(char *base) int32_t baseid; if ( base == 0 || base[0] == 0 || strcmp(base,(char *)"KYCSELLOUTS") == 0 ) return(&HUSH_STATES[33]); - else if ( (baseid= komodo_baseid(base)) >= 0 ) + else if ( (baseid= hush_baseid(base)) >= 0 ) return(&HUSH_STATES[baseid+1]); else return(&HUSH_STATES[0]); } diff --git a/src/hushd b/src/hushd deleted file mode 100755 index 7aa99aeb0..000000000 --- a/src/hushd +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# Copyright (c) 2016-2021 The Hush developers -# Distributed under the GPLv3 software license, see the accompanying -# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -# set working directory to the location of this script -# readlink -f does not always exist -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR -DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" -cd $DIR - -# Chain parameters -NAME=HUSH3 - -# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn -SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac - -# Hush was and will always be: -# The First Pure Sapling Zcash Protocol chain! -SAPLING=1 - -# We use 3 "eras" of different supply curves -ERAS=3 - -# These values are historical and over-ridden by internals! -# Do not change these values, change internals. -BLOCKTIME=150 # Hush goes to 75s blocktime at Block 340K -REWARD=0,1125000000,562500000 -HALVING=129,340000,840000 -PERC=11111111 -END=128,340000,5422111 - -# 6250000 - (Sprout pool at block 500,000) -SUPPLY=6178674 -FOUNDERS=1 -CLIENTNAME=GoldenSandtrout -NODE1=node1.hush.is -NODE2=node2.hush.is -NODE3=node3.hush.is -NODE4=node4.hush.is -NODE5=node5.hush.is -NODE6=node6.hush.is -NODE7=node7.hush.is -NODE8=node8.hush.is -CCLIB=hush3 - -# CryptoConditions/Custom Consensus params -# CCs will effectively be turned off at Block 340K -# since transparent outputs will not be allowed, except -# for mining and dpow. CCs can be used on Hush Smart -# Chains that do not define ac_private=1 -FAUCET=228 -HEIR=234 -CHANNEL=235 -ORACLE=236 -GATEWAY=241 -CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY - -KMD=${KOMODOD:-./komodod} -if [ -f $KMD ]; then - HUSH="TheFuture" - # echo "Found binary: $KMD" -else - KMD=hush-komodod - if [ -f $KMD ]; then - echo "Found binary: $KMD" - else - echo "ERROR: Could not find Komodo binary!!!" - exit 1 - fi -fi - -# jl777 dishonored his village and so Duke The Elder journeys on -# with the True Extreme Privacy Cypherpunks -$KMD -ac_name=$NAME \ - -ac_sapling=$SAPLING \ - -ac_reward=$REWARD \ - -ac_halving=$HALVING \ - -ac_end=$END \ - -ac_eras=$ERAS \ - -ac_blocktime=$BLOCKTIME \ - -ac_cc=2 \ - -ac_ccenable=$CCENABLE \ - -ac_founders=$FOUNDERS \ - -ac_supply=$SUPPLY \ - -ac_perc=$PERC \ - -clientname=$CLIENTNAME \ - -asmap \ - -addnode=$NODE1 \ - -addnode=$NODE2 \ - -addnode=$NODE3 \ - -addnode=$NODE4 \ - -addnode=$NODE5 \ - -addnode=$NODE6 \ - -addnode=$NODE7 \ - -addnode=$NODE8 \ - -ac_cclib=$CCLIB \ - -ac_script=$SCRIPT "$@" diff --git a/src/hushd.bat b/src/hushd.bat deleted file mode 100644 index 5f578d6b6..000000000 --- a/src/hushd.bat +++ /dev/null @@ -1,10 +0,0 @@ -@call :GET_CURRENT_DIR -@cd %THIS_DIR% -komodod.exe -ac_name=HUSH3 -ac_sapling=1 -ac_reward=0,1125000000,562500000 -ac_halving=129,340000,840000 -ac_end=128,340000,5422111 -ac_eras=3 -ac_blocktime=150 -ac_cc=2 -ac_ccenable=228,234,235,236,241 -ac_founders=1 -ac_supply=6178674 -ac_perc=11111111 -clientname=GoldenSandtrout -asmap -addnode=node1.hush.is -addnode=node2.hush.is -addnode=node3.hush.is -addnode=node4.hush.is -addnode=node5.hush.is -addnode=node6.hush.is -addnode=node7.hush.is -addnode=node8.hush.is -ac_cclib=hush3 -ac_script=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac -daemon %1 %2 %3 %4 %5 %6 %7 %8 %9 -@goto :EOF - -:GET_CURRENT_DIR -@pushd %~dp0 -@set THIS_DIR=%CD% -@popd -@goto :EOF diff --git a/src/init.cpp b/src/init.cpp index 01916ee76..3e699a7cf 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -94,7 +94,7 @@ extern bool hush_dailysnapshot(int32_t height); extern int32_t HUSH_LOADINGBLOCKS; extern char SMART_CHAIN_SYMBOL[]; extern int32_t HUSH_SNAPSHOT_INTERVAL; -extern void komodo_init(int32_t height); +extern void hush_init(int32_t height); #ifdef ENABLE_WALLET CWallet* pwalletMain = NULL; @@ -412,7 +412,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zindex", strprintf(_("Maintain extra statistics about shielded transactions and payments (default: %u)"), 0)); strUsage += HelpMessageGroup(_("Connection options:")); strUsage += HelpMessageOpt("-addnode=", _("Add a node to connect to and attempt to keep the connection open")); - strUsage += HelpMessageOpt("-asmap=", strprintf("Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME)); + strUsage += HelpMessageOpt("-asmap=", strprintf("Specify ASN mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME)); strUsage += HelpMessageOpt("-banscore=", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100)); strUsage += HelpMessageOpt("-bantime=", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), 86400)); strUsage += HelpMessageOpt("-bind=", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6")); @@ -1092,8 +1092,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); } - // Read asmap file if configured - if (mapArgs.count("-asmap")) { + // Read asmap file by default for HUSH3 and all Hush Smart Chains + if (GetArg("-asmap",1)) { fs::path asmap_path = fs::path(GetArg("-asmap", "")); char cwd[1024]; @@ -1577,7 +1577,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt)); uacomments.push_back(SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)); } - strSubVersion = FormatSubVersion(GetArg("-clientname","jl777sRemorse"), CLIENT_VERSION, uacomments); + strSubVersion = FormatSubVersion(GetArg("-clientname","GoldenSandrout"), CLIENT_VERSION, uacomments); if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) { return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.", strSubVersion.size(), MAX_SUBVERSION_LENGTH)); @@ -1840,7 +1840,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // (we're likely using a testnet datadir, or the other way around). if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0) return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?")); - komodo_init(1); + hush_init(1); // Initialize the block index (no-op if non-empty database was already loaded) if (!InitBlockIndex()) { strLoadError = _("Error initializing block database"); diff --git a/src/main.cpp b/src/main.cpp index ec02f3a79..e33ec9065 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1201,7 +1201,7 @@ bool ContextualCheckCoinbaseTransaction(int32_t slowflag,const CBlock *block,CBl { if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 ) { - if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) + if ( hush_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 ) return(false); } return(true); diff --git a/src/miner.cpp b/src/miner.cpp index 7ce7cf404..93f019d7f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -138,7 +138,7 @@ uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize); -int32_t komodo_baseid(char *origbase); +int32_t hush_baseid(char *origbase); int32_t hush_longestchain(); int64_t hush_block_unlocktime(uint32_t nHeight); uint64_t the_commission(const CBlock *block,int32_t height); @@ -955,7 +955,7 @@ static bool ProcessBlockFound(CBlock* pblock) return true; } -int32_t komodo_baseid(char *origbase); +int32_t hush_baseid(char *origbase); int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height); arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); int32_t FOUND_BLOCK,HUSH_MAYBEMINED; @@ -1055,7 +1055,7 @@ void static BitcoinMiner() while ( (ASSETCHAIN_INIT == 0 || HUSH_INITDONE == 0) ) { sleep(1); - if ( komodo_baseid(SMART_CHAIN_SYMBOL) < 0 ) + if ( hush_baseid(SMART_CHAIN_SYMBOL) < 0 ) break; } if ( SMART_CHAIN_SYMBOL[0] == 0 ) diff --git a/src/net.cpp b/src/net.cpp index d7833b4a0..def0145ab 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2283,7 +2283,7 @@ bool CAddrDB::Read(CAddrMan& addr) // ... verify the network matches ours if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) - return error("%s: Invalid network magic number", __func__); + return error("%s: Invalid network magic number in %s", __func__, pathAddr.string()); // de-serialize address data into one CAddrMan object ssPeers >> addr; diff --git a/src/pow.cpp b/src/pow.cpp index 703deb765..0838f6e2b 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -674,7 +674,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui int32_t hush_currentheight(); void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height); bool hush_checkopret(CBlock *pblock, CScript &merkleroot); -CScript komodo_makeopret(CBlock *pblock, bool fNew); +CScript hush_makeopret(CBlock *pblock, bool fNew); extern int32_t HUSH_CHOSEN_ONE; extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN]; #define KOMODO_ELECTION_GAP 2000 diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index d4f797b0e..fb1b3116c 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -59,7 +59,7 @@ using namespace std; int32_t hush_longestchain(); int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); -bool komodo_txnotarizedconfirmed(uint256 txid); +bool hush_txnotarizedconfirmed(uint256 txid); uint32_t hush_chainactive_timestamp(); int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC; @@ -230,7 +230,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); if ( HUSH_NSPV_FULLNODE ) { - txid_height = notarizedtxid_height(SMART_CHAIN_SYMBOL[0] != 0 ? (char *)"HUSH" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height); + txid_height = notarizedtxid_height(SMART_CHAIN_SYMBOL[0] != 0 ? (char *)"HUSH3" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height); if ( txid_height > 0 ) obj.push_back(Pair("notarizedtxid_height", txid_height)); else obj.push_back(Pair("notarizedtxid_height", "mempool")); @@ -1463,7 +1463,7 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& if (fHelp || params.size() < 1 || params.size() > 1) { string msg = "txnotarizedconfirmed txid\n" - "\nReturns true if transaction is notarized on chain that has dPoW or if confirmation number is greater than 60 on chain taht does not have dPoW.\n" + "\nReturns true if transaction is notarized on chain that has dPoW or if confirmation number is greater than 60 on chain that does not have dPoW.\n" "\nArguments:\n" "1. txid (string, required) Transaction id.\n" @@ -1476,7 +1476,7 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& throw runtime_error(msg); } txid = uint256S((char *)params[0].get_str().c_str()); - notarizedconfirmed=komodo_txnotarizedconfirmed(txid); + notarizedconfirmed=hush_txnotarizedconfirmed(txid); UniValue result(UniValue::VOBJ); result.push_back(Pair("result", notarizedconfirmed)); return result; diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 82fcfdf97..69e614f3b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -651,7 +651,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey& " ,...\n" " }\n" "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" - "4. expiryheight (numeric, optional, default=" + strprintf("%d", DEFAULT_TX_EXPIRY_DELTA) + ") Expiry height of transaction (if Overwinter is active)\n" + "4. expiryheight (numeric, optional, default=" + strprintf("%d", DEFAULT_TX_EXPIRY_DELTA) + ") Expiry height of transaction\n" "\nResult:\n" "\"transaction\" (string) hex string of the transaction\n" diff --git a/src/txmempool.cpp b/src/txmempool.cpp index b780d15d6..4c30fdfcb 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -487,21 +487,7 @@ std::vector CTxMemPool::removeExpired(unsigned int nBlockHeight) // Remove expired txs from the mempool LOCK(cs); list transactionsToRemove; - for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) - { - const CTransaction& tx = it->GetTx(); - tipindex = chainActive.LastTip(); - /* - bool fInterestNotValidated = SMART_CHAIN_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0) < 0; - if (IsExpiredTx(tx, nBlockHeight) || fInterestNotValidated) - { - if (fInterestNotValidated && tipindex != 0) - LogPrintf("Removing interest violate txid.%s nHeight.%d nTime.%u vs locktime.%u\n",tx.GetHash().ToString(),tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,tx.nLockTime); - transactionsToRemove.push_back(tx); - } - */ - } std::vector ids; for (const CTransaction& tx : transactionsToRemove) { list removed; diff --git a/src/util.cpp b/src/util.cpp index 71152f2bd..7834630ba 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -497,15 +497,30 @@ boost::filesystem::path GetDefaultDataDir() if ( SMART_CHAIN_SYMBOL[0] != 0 ) strcpy(symbol,SMART_CHAIN_SYMBOL); else symbol[0] = 0; + // OLD NAMES: // Windows < Vista: C:\Documents and Settings\Username\Application Data\Komodo // Windows >= Vista: C:\Users\Username\AppData\Roaming\Komodo // Mac: ~/Library/Application Support/Komodo // Unix: ~/.komodo + + // NEW NAMES: + // Windows < Vista: C:\Documents and Settings\Username\Application Data\Hush + // Windows >= Vista: C:\Users\Username\AppData\Roaming\Hush + // Mac: ~/Library/Application Support/Hush + // Unix: ~/.hush + + // ~/.hush was actually used by the original 1.x version of Hush, but we will + // only make subdirectories inside of it, so we won't be able to overwrite + // an old wallet.dat from the Ice Ages :) #ifdef _WIN32 // Windows - if ( symbol[0] == 0 ) - return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo"; - else return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol; + pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol; + if(fs::is_directory(pathRet)) { + // legacy directory, use that + } else { + pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol; + } + return pathRet; #else fs::path pathRet; char* pszHome = getenv("HOME"); @@ -517,19 +532,31 @@ boost::filesystem::path GetDefaultDataDir() // Mac pathRet /= "Library/Application Support"; TryCreateDirectory(pathRet); - if ( symbol[0] == 0 ) - return pathRet / "Komodo"; - else - { - pathRet /= "Komodo"; - TryCreateDirectory(pathRet); - return pathRet / symbol; + fs::path tmppath; + tmppath = pathRet; + tmppath /= "Komodo"; + if(fs::is_directory(pathRet)) { + //legacy directory, use that + TryCreateDirectory(tmppath); + return tmppath / symbol; + } else { + // New directory :) + tmppath = pathRet; + tmppath /= "Hush"; + TryCreateDirectory(tmppath); + return tmppath / symbol; } #else // Unix - if ( symbol[0] == 0 ) - return pathRet / ".komodo"; - else return pathRet / ".komodo" / symbol; + fs::path tmppath = pathRet / ".komodo" / symbol; + if(fs::is_directory(tmppath)) { + // legacy directory, use that for backward compat + return tmppath; + } else { + // New directory :) + tmppath = pathRet / ".hush" / symbol; + return tmppath; + } #endif #endif } @@ -638,8 +665,6 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path /= BaseParams().DataDir(); fs::create_directories(path); - //std::string assetpath = path + "/assets"; - //boost::filesystem::create_directory(assetpath); return path; } @@ -652,15 +677,10 @@ void ClearDatadirCache() boost::filesystem::path GetConfigFile() { char confname[512]; - if ( SMART_CHAIN_SYMBOL[0] != 0 ) + if ( SMART_CHAIN_SYMBOL[0] != 0 ) { sprintf(confname,"%s.conf",SMART_CHAIN_SYMBOL); - else - { -#ifdef __APPLE__ - strcpy(confname,"Komodo.conf"); -#else - strcpy(confname,"komodo.conf"); -#endif + } else { + strcpy(confname,"HUSH3.conf"); } boost::filesystem::path pathConfigFile(GetArg("-conf",confname)); if (!pathConfigFile.is_complete()) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4da6204e6..42589b38e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -683,7 +683,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&sig)[i]); //printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize); - ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "KMD" : SMART_CHAIN_SYMBOL))); + ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH3" : SMART_CHAIN_SYMBOL))); height = chainActive.LastTip()->GetHeight(); if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) ret.push_back(Pair("owner",refpubkey.GetHex())); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3bc3b99cd..233851d64 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2717,10 +2717,12 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100)))); CBlock block; + bool involvesMe = false; ReadBlockFromDisk(block, pindex,1); BOOST_FOREACH(CTransaction& tx, block.vtx) { if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) { + involvesMe = true; ret++; } } @@ -2734,8 +2736,11 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } - // Build initial witness caches - BuildWitnessCache(pindex, true); + // Build initial witness caches for blocks involving one of our addresses + if (involvesMe) { + LogPrintf("%s: block has one of our transactions, building witness cache", __func__); + BuildWitnessCache(pindex, true); + } //Delete Transactions if (fTxDeleteEnabled) {