diff --git a/asmap.dat b/asmap.dat index aaf3fdada..03eac1146 100644 Binary files a/asmap.dat and b/asmap.dat differ diff --git a/configure.ac b/configure.ac index c9cf3e6a9..2e0c8bd1f 100644 --- a/configure.ac +++ b/configure.ac @@ -3,12 +3,12 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) dnl Must be kept in sync with src/clientversion.h , ugh! define(_CLIENT_VERSION_MINOR, 10) -define(_CLIENT_VERSION_REVISION, 3) +define(_CLIENT_VERSION_REVISION, 4) 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))) define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2024) +define(_COPYRIGHT_YEAR, 2025) AC_INIT([Hush],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://git.hush.is/hush/hush3],[hush]) AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) diff --git a/contrib/asmap/README.md b/contrib/asmap/README.md index c23d8da74..cbb6f7526 100644 --- a/contrib/asmap/README.md +++ b/contrib/asmap/README.md @@ -2,4 +2,5 @@ Files relating to -asmap=... feature, to use ASNs -Originally from https://github.com/sipa/asmap/blob/master/demo.map +From https://github.com/asmap/asmap-data/blob/main/1730210400_asmap.dat +[Upstream Commit dcce69e48211facdbd52a461cfce333d5800b7de](https://github.com/asmap/asmap-data/commit/dcce69e48211facdbd52a461cfce333d5800b7de) diff --git a/contrib/asmap/asmap.dat b/contrib/asmap/asmap.dat index aaf3fdada..03eac1146 100644 Binary files a/contrib/asmap/asmap.dat and b/contrib/asmap/asmap.dat differ diff --git a/contrib/avg_blocktime.pl b/contrib/avg_blocktime.pl new file mode 100755 index 000000000..adfa25427 --- /dev/null +++ b/contrib/avg_blocktime.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl +# Copyright (c) 2016-2022 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 + +use warnings; +use strict; +my $cli = "./src/hush-cli"; +my $coin = shift || ''; +unless (-e $cli) { + die "$cli does not exist, aborting"; +} +if ($coin) { + $cli .= " -ac_name=$coin"; +} +my $getblock= "$cli getblock"; +my $start = shift || 1850000; +my $end = shift || 1853000; + +my $blocks = qx{$cli getblockcount}; +if($?) { + print "ERROR, is node running? exiting...\n"; + exit 1; +} + +if ($end > $blocks) { + print "The block $end is beyond how many blocks this node knows about, exiting...\n"; + exit 1; +} + +if ($start < 1) { + print "Invalid start block $start, exiting...\n"; + exit 1; +} + +my $block = $start; +my $prev_blocktime = 0; +my $total_duration = 0; + +while ($block <= $end) { + my $blocktime = qx{$getblock $block | grep time}; + chomp $blocktime; + if($blocktime =~ m/(\d+)/) { + $blocktime = $1; + } + my $duration = $blocktime - $prev_blocktime; + if($prev_blocktime > 0) { + $total_duration += $duration; + } + #print "$block $blocktime $prev_blocktime $duration\n"; + print "$block $duration\n"; + $block++; + $prev_blocktime = $blocktime; +} +my $num_blocks = $end - $start; +my $avg_duration = $total_duration / $num_blocks; +print "Avg blocktime over $num_blocks blocks = $avg_duration\n"; diff --git a/contrib/block_time.pl b/contrib/block_time.pl index 3e3cf014d..2fc9299fb 100755 --- a/contrib/block_time.pl +++ b/contrib/block_time.pl @@ -5,7 +5,7 @@ use warnings; use strict; -# Given a block time, estimate when it will happen +# Given a block height, estimate when it will happen my $block = shift || die "Usage: $0 123"; my $coin = shift || ''; my $hush = "./src/hush-cli"; @@ -30,7 +30,7 @@ if ($block <= $blockcount) { if ($coin eq 'DRAGONX') { $minpb = 0.6; # minutes per block } elsif ($coin) { - # TODO: support custom bloctimes + # TODO: support custom blocktimes $minpb = 1; # assumes default blocktime of 60s } my $minutes = $diff*$minpb; diff --git a/contrib/debian/compat b/contrib/debian/compat index ec635144f..b1bd38b62 100644 --- a/contrib/debian/compat +++ b/contrib/debian/compat @@ -1 +1 @@ -9 +13 diff --git a/contrib/debian/hush.example b/contrib/debian/hush.example index 924659c02..43111f548 100644 --- a/contrib/debian/hush.example +++ b/contrib/debian/hush.example @@ -1 +1 @@ -DEBIAN/examples/zcash.conf +DEBIAN/examples/HUSH3.conf diff --git a/contrib/sdl_checkpoints.pl b/contrib/sdl_checkpoints.pl index 8b7ea54ea..938aee872 100755 --- a/contrib/sdl_checkpoints.pl +++ b/contrib/sdl_checkpoints.pl @@ -8,7 +8,11 @@ use warnings; use strict; -my $hush = "./src/hush-cli"; + +# call this script like this to generate checkpoints for a HAC such as DragonX: +# CLI=./src/dragonx-cli ./contrib/sdl_checkpoints.pl ... + +my $hush = $ENV{CLI} || "./src/hush-cli"; my $gethash = "$hush getblockhash"; my $gettree = "$hush getblockmerkletree"; my $start = shift || 300000; diff --git a/doc/cjdns.md b/doc/cjdns.md index 4b47bb8ac..17f5773d2 100644 --- a/doc/cjdns.md +++ b/doc/cjdns.md @@ -106,10 +106,7 @@ details. ## CJDNS-related information in Hush There are several ways to see your CJDNS address in Hush: -- in the "Local addresses" output of CLI `-netinfo` - in the "localaddresses" output of RPC `getnetworkinfo` -To see which CJDNS peers your node is connected to, use `hush-cli -netinfo 4` -or the `getpeerinfo` RPC (i.e. `hush-cli getpeerinfo`). - -You can use the `getnodeaddresses` RPC to fetch a number of CJDNS peers known to your node; run `hush-cli help getnodeaddresses` for details. +To see which CJDNS peers your node is connected to, use `hush-cli getpeerinfo` +RPC. diff --git a/doc/i2p.md b/doc/i2p.md index 8cc3a6557..3e5fabb39 100644 --- a/doc/i2p.md +++ b/doc/i2p.md @@ -100,15 +100,11 @@ address. There are several ways to see your I2P address if accepting incoming I2P connections (`-i2pacceptincoming`): -- in the "Local addresses" output of CLI `-netinfo` - in the "localaddresses" output of RPC `getnetworkinfo` - in the debug log (grep for `AddLocal`; the I2P address ends in `.b32.i2p`) - in the i2p/i2pd web console under "SAM Sessions" -To see which I2P peers your node is connected to, use `hush-cli -netinfo 4` -or the `getpeerinfo` RPC (e.g. `hush-cli getpeerinfo`). - -To see which I2P addresses your node knows, use the `getnodeaddresses 0 i2p` +To see which I2P peers your node is connected to, use `hush-cli getpeerinfo` RPC. ## Compatibility diff --git a/doc/release-process.md b/doc/release-process.md index f60b26632..c1adb3269 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -58,7 +58,7 @@ Look for Git issues that should be fixed in the next release. Especially low-ris Install deps on Linux: - apt-get install help2man debchange + apt-get install help2man devscripts ## Release process - If new seeds are being added or seeds are changing: diff --git a/doc/relnotes/README.md b/doc/relnotes/README.md index 41f6a786b..8ce5e027c 100644 --- a/doc/relnotes/README.md +++ b/doc/relnotes/README.md @@ -10,6 +10,10 @@ and no longer on Github, since they banned Duke Leto and also because they censor many people around the world and work with evil organizations. +# Hush 3.10.4 "" + * Add CLI options `-disableipv4` and `-disableipv6` which can be used to disable IPv4/IPv6 + * Updated ASmap, which maps IP addresses to Autonomous System (AS) numbers + # Hush 3.10.3 "Persistent Pezoporus" * Use WolfSSL 4.8.1 which prevents nodes from getting stuck in general and when shutting down diff --git a/doc/tor.md b/doc/tor.md index fe0608888..002b95754 100644 --- a/doc/tor.md +++ b/doc/tor.md @@ -16,7 +16,6 @@ configure Tor. ## How to see information about your Tor configuration via Hush There are several ways to see your local onion address in Hush: -- in the "Local addresses" output of CLI `-netinfo` - in the "localaddresses" output of RPC `getnetworkinfo` - in the debug log (grep for "AddLocal"; the Tor address ends in `.onion`) @@ -27,9 +26,6 @@ CLI `-addrinfo` returns the number of addresses known to your node per network. This can be useful to see how many onion peers your node knows, e.g. for `-onlynet=onion`. -To fetch a number of onion addresses that your node knows, for example seven -addresses, use the `getnodeaddresses 7 onion` RPC. - ## 1. Run Hush behind a Tor proxy The first step is running Hush behind a Tor proxy. This will already anonymize all diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index cacfad593..0c7737234 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -47,49 +47,6 @@ #define SATOSHIDEN ((uint64_t)100000000L) #define dstr(x) ((double)(x) / SATOSHIDEN) #define CCDISABLEALL memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES)) -#define CCENABLE(x) ASSETCHAINS_CCDISABLES[((uint8_t)x)] = 0 - -/* moved to hush_cJSON.h -#ifndef _BITS256 -#define _BITS256 - union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; - typedef union _bits256 bits256; -#endif -*/ -/// \endcond - -/// identifiers of additional data blobs in token opreturn script: -/// @see EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets) -/// @see GetOpretBlob -enum opretid : uint8_t { - // cc contracts data: - OPRETID_NONFUNGIBLEDATA = 0x11, //!< NFT data id - OPRETID_ASSETSDATA = 0x12, //!< assets contract data id - OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id - OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id - OPRETID_HEIRDATA = 0x15, //!< heir contract data id - OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id - OPRETID_PEGSDATA = 0x17, //!< pegs contract data id - - /*! \cond INTERNAL */ - // non cc contract data: - OPRETID_FIRSTNONCCDATA = 0x80, - /*! \endcond */ - OPRETID_BURNDATA = 0x80, //!< burned token data id - OPRETID_IMPORTDATA = 0x81 //!< imported token data id -}; - -/// finds opret blob data by opretid in the vector of oprets -/// @param oprets vector of oprets -/// @param id opret id to search -/// @param vopret found opret blob as byte array -/// @returns true if found -/// @see opretid -inline bool GetOpretBlob(const std::vector>> &oprets, uint8_t id, std::vector &vopret) { - vopret.clear(); - for(auto p : oprets) if (p.first == id) { vopret = p.second; return true; } - return false; -} /// \cond INTERNAL struct CC_utxo @@ -100,16 +57,6 @@ struct CC_utxo }; /// \endcond -/// \cond INTERNAL -struct CC_meta -{ - std::vector version; - uint8_t evalCode; - bool is1of2; - uint8_t numDestinations; - // followed by address destinations -}; -/// \endcond /// CC contract (Antara module) info structure that contains data used for signing and validation of cc contract transactions struct CCcontract_info @@ -184,16 +131,6 @@ struct CCcontract_info /// @returns pointer to the passed CCcontract_info structure, it must not be freed struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode); -/// \cond INTERNAL -struct oracleprice_info -{ - CPubKey pk; - std::vector data; - int32_t height; -}; -/// \endcond - - typedef std::vector vscript_t; extern struct NSPV_CCmtxinfo NSPV_U; //!< global variable with info about mtx object and used utxo @@ -258,7 +195,6 @@ bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid, bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); bool mytxid_inmempool(uint256 txid); int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout); -int32_t myGet_mempool_txs(std::vector &txs,uint8_t evalcode,uint8_t funcid); /// \endcond /// \cond INTERNAL @@ -393,52 +329,6 @@ bool getCCopret(const CScript &scriptPubKey, CScript &opret); /// @private bool makeCCopret(CScript &opret, std::vector> &vData); -/// CCaddr2set sets private key for additional eval code global address. -/// This allows to spend from two cc global addresses in one transaction (the first one is set in cp object by @see CCinit function). -/// @param cp contract info structure (@see CCcontract_info) where the private key is set -/// @param evalcode eval code of the other contract -/// @param pk global public key of the other contract -/// @param priv private key for the global public key of the other contract -/// @param coinaddr cc address obtained for this global pubkey and eval code with _GetCCaddress -/// @see CCinit -/// @see CCcontract_info -/// @see _GetCCaddress -void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); - -/// CCaddr2set sets private key for yet another eval code global address. -/// This allows to spend from three cc global addresses in one transaction (the first one is set in cp object by CCinit function, the second is set by CCaddr2set function). -/// @param cp contract info structure where the private key is set -/// @param evalcode eval code of the other contract -/// @param pk global public key of the other contract -/// @param priv private key for the global public key of the other contract -/// @param coinaddr the cc address obtained for this global pubkey and eval code with _GetCCaddress -/// @see CCinit -/// @see CCcontract_info -/// @see CCaddr2set -/// @see _GetCCaddress -void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr); - -/// CCaddr1of2set sets pubkeys, private key and cc addr for spending from 1of2 cryptocondition vout -/// @param cp contract info structure where the private key is set -/// @param pk1 one of the two public keys of the 1of2 cc -/// @param pk2 second of the two public keys of the 1of2 cc -/// @param priv private key for one of the two pubkeys -/// @param coinaddr the cc address obtained for this 1of2 cc with GetCCaddress1of2 -/// @see CCinit -/// @see CCcontract_info -/// @see GetCCaddress1of2 -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2,uint8_t *priv,char *coinaddr); - -/// CCaddrTokens1of2set sets pubkeys, private key and cc addr for spending from 1of2 token cryptocondition vout -/// @param cp contract info structure where the private key is set -/// @param pk1 one of the two public keys of the 1of2 cc -/// @param pk2 second of the two public keys of the 1of2 cc -/// @param priv private key for one of the two pubkeys -/// @param coinaddr the cc address obtained for this 1of2 token cc with GetTokensCCaddress1of2 -/// @see GetTokensCCaddress -/// @see CCcontract_info -void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *coinaddr); - /// IsCCInput checks if scriptSig object contains a cryptocondition /// @param scriptSig scriptSig object with a cryptocondition /// @returns true if the scriptSig object contains a cryptocondition @@ -476,8 +366,6 @@ CPubKey pubkey2pk(std::vector vpubkey); /// @param tokenid id of token (id of token creation tx) int64_t CCfullsupply(uint256 tokenid); -/// @private -bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue); /// Returns bitcoin address for the scriptPubKey parameter /// @param[out] destaddr the returned address of the scriptPubKey, the buffer should have size of at least 64 chars @@ -485,15 +373,6 @@ bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue); /// @returns true if success bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); -/// Returns custom bitcoin address for the scriptPubKey parameter -/// @param[out] destaddr the returned address of the scriptPubKey, the buffer should have size of at least 64 chars -/// @param scriptPubKey scriptPubKey object -/// @param taddr custom address prefix -/// @param prefix custom pubkey prefix -/// @param prefix2 custom script prefix -/// @returns true if success -bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix,uint8_t prefix2); - /// Returns my pubkey, that is set by -pubkey hushd parameter /// @returns public key as byte array std::vector Mypubkey(); @@ -633,9 +512,6 @@ bits256 bits256_doublesha256(char *deprecated,uint8_t *data,int32_t datalen); // UniValue ValueFromAmount(const CAmount& amount); // defined in server.h /*! \endcond */ -/*! \cond INTERNAL */ -int64_t TotalPubkeyNormalInputs(const CTransaction &tx, const CPubKey &pubkey); -int64_t TotalPubkeyCCInputs(const CTransaction &tx, const CPubKey &pubkey); inline std::string STR_TOLOWER(const std::string &str) { std::string out; for (std::string::const_iterator i = str.begin(); i != str.end(); i++) out += std::tolower(*i); return out; } /*! \endcond */ @@ -646,60 +522,4 @@ inline std::string STR_TOLOWER(const std::string &str) { std::string out; for (s void AddSigData2UniValue(UniValue &result, int32_t vini, UniValue& ccjson, std::string sscriptpubkey, int64_t amount); -#ifndef LOGSTREAM_DEFINED -#define LOGSTREAM_DEFINED -// bitcoin LogPrintStr with category "-debug" cmdarg support for C++ ostringstream: - -// log levels: -#define CCLOG_ERROR (-1) //!< error level -#define CCLOG_INFO 0 //!< info level -#define CCLOG_DEBUG1 1 //!< debug level 1 -#define CCLOG_DEBUG2 2 //!< debug level 2 -#define CCLOG_DEBUG3 3 //!< debug level 3 -#define CCLOG_MAXLEVEL 3 - -/// @private -extern void CCLogPrintStr(const char *category, int level, const std::string &str); - -/// @private -template -void CCLogPrintStream(const char *category, int level, const char *functionName, T print_to_stream) -{ -} -/// Macro for logging messages using bitcoin LogAcceptCategory and LogPrintStr functions. -/// Supports error, info and three levels of debug messages. -/// Logging category is set by -debug=category hushd param. -/// To set debug level pass -debug=category-1, -debug=category-2 or -debug=category-3 param. If some level is enabled lower level messages also will be printed. -/// To print info-level messages pass just -debug=category parameter, with no level. -/// Error-level messages will always be printed, even if -debug parameter is not set -/// @param category category of message, for example Antara module name -/// @param level debug-level, use defines CCLOG_ERROR, CCLOG_INFO, CCLOG_DEBUGN -/// @param logoperator to form the log message (the 'stream' name is mandatory) -/// usage: LOGSTREAM("category", debug-level, stream << "some log data" << data2 << data3 << ... << std::endl); -/// example: LOGSTREAM("heir", CCLOG_INFO, stream << "heir public key is " << HexStr(heirPk) << std::endl); -#define LOGSTREAM(category, level, logoperator) CCLogPrintStream( category, level, NULL, [=](std::ostringstream &stream) {logoperator;} ) - -/// LOGSTREAMFN is a version of LOGSTREAM macro which adds calling function name with the standard define \_\_func\_\_ at the beginning of the printed string. -/// LOGSTREAMFN parameters are the same as in LOGSTREAM -/// @see LOGSTREAM -#define LOGSTREAMFN(category, level, logoperator) CCLogPrintStream( category, level, __func__, [=](std::ostringstream &stream) {logoperator;} ) - -/// @private -template -UniValue report_ccerror(const char *category, int level, T print_to_stream) -{ - UniValue err(UniValue::VOBJ); - std::ostringstream stream; - - print_to_stream(stream); - err.push_back(Pair("result", "error")); - err.push_back(Pair("error", stream.str())); - stream << std::endl; - CCLogPrintStr(category, level, stream.str()); - return err; -} - -/// @private -#define CCERR_RESULT(category,level,logoperator) return report_ccerror(category, level, [=](std::ostringstream &stream) {logoperator;}) -#endif // #ifndef LOGSTREAM_DEFINED #endif diff --git a/src/cc/CCutilbits.cpp b/src/cc/CCutilbits.cpp index e0ad86c04..17de1e356 100644 --- a/src/cc/CCutilbits.cpp +++ b/src/cc/CCutilbits.cpp @@ -102,7 +102,3 @@ CPubKey pubkey2pk(std::vector vpubkey) pk.Set(vpubkey.begin(), vpubkey.end()); return(pk); } - -void CCLogPrintStr(const char *category, int level, const std::string &str) -{ -} diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 5d8e40c40..6e3f2f735 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -100,22 +100,6 @@ uint32_t GetLatestTimestamp(int32_t height) return(hush_heightstamp(height)); } // :P -void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) -{ -} - -void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr) -{ -} - -void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *coinaddr) -{ -} - -void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *tokenaddr) -{ -} - bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; @@ -132,11 +116,6 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) return(false); } -bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix, uint8_t prefix2) -{ - return(false); -} - bool pubkey2addr(char *destaddr,uint8_t *pubkey33) { std::vectorpk; int32_t i; @@ -145,11 +124,6 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33) return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); } -bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue) -{ - return false; -} - bool priv2addr(char *coinaddr,uint8_t *buf33,uint8_t priv32[32]) { CKey priv; CPubKey pk; int32_t i; uint8_t *src; @@ -189,57 +163,9 @@ CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv) int32_t NSPV_coinaddr_inmempool(char const *logcategory,char *coinaddr,uint8_t CCflag); -int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr) -{ - int32_t i,n; char destaddr[64]; - if ( HUSH_NSPV_SUPERLITE ) - return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1)); - BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) - { - const CTransaction &tx = e.GetTx(); - if ( (n= tx.vout.size()) > 0 ) - { - const uint256 &txid = tx.GetHash(); - for (i=0; i &txs,uint8_t evalcode,uint8_t funcid) -{ - int i=0; - - if ( HUSH_NSPV_SUPERLITE ) - { - CTransaction tx; uint256 hashBlock; - - NSPV_evalcode_inmempool(evalcode,funcid); - for (int i=0;i vopret; char destaddr[64]; *vindexp = -1; memset(satoshisp,0,sizeof(*satoshisp)); - /* - if ( funcid == NSPV_CC_TXIDS) - { - std::vector > tmp_txids; uint256 tmp_txid,hashBlock; - int32_t n=0,skipcount=vout>>16; uint8_t eval=(vout>>8)&0xFF, func=vout&0xFF; - - CTransaction tx; - SetCCtxids(tmp_txids,coinaddr,isCC); - if ( skipcount < 0 ) skipcount = 0; - if ( skipcount >= tmp_txids.size() ) - skipcount = tmp_txids.size()-1; - if ( tmp_txids.size()-skipcount > 0 ) - { - for (std::vector >::const_iterator it=tmp_txids.begin(); it!=tmp_txids.end(); it++) - { - if (txid!=zeroid || func!=0) - { - myGetTransaction(it->first.txhash,tx,hashBlock); - std::vector> oprets; uint256 tokenid,txid; - std::vector vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; - std::vector pubkeys; - - if (DecodeTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,tokenevalcode,tokenid,pubkeys,oprets)!=0 && GetOpretBlob(oprets, OPRETID_CHANNELSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) - { - vopret=vOpretExtra; - } - else GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey, vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 2 && script[0]==eval ) - { - switch (eval) - { - case EVAL_CHANNELS:EVAL_PEGS:EVAL_ORACLES:EVAL_GAMES:EVAL_IMPORTGATEWAY:EVAL_ROGUE: - E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> tmp_txid;); - if (e!=eval || (txid!=zeroid && txid!=tmp_txid) || (func!=0 && f!=func)) continue; - break; - case EVAL_TOKENS:EVAL_DICE:EVAL_DILITHIUM:EVAL_FAUCET:EVAL_LOTO:EVAL_PAYMENTS:EVAL_REWARDS: - E_UNMARSHAL(vopret,ss >> e; ss >> f;); - if (e!=eval || (func!=0 && f!=func)) continue; - break; - default: - break; - } - } - } - if ( n >= skipcount ) txids.push_back(it->first.txhash); - n++; - } - return (n-skipcount); - } - return (0); - } - */ if ( mempool.size() == 0 ) return(0); - /* - if ( funcid == NSPV_MEMPOOL_CCEVALCODE ) - { - isCC = true; - evalcode = vout & 0xff; - func = (vout >> 8) & 0xff; - } - */ + LOCK(mempool.cs); BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) { diff --git a/src/init.cpp b/src/init.cpp index c034826d6..b0c64fe05 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -429,8 +429,8 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-i2psam=", strprintf(_("I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)"))); strUsage += HelpMessageOpt("-i2pacceptincoming", strprintf(_("If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy. If this is not set but -i2psam is set then only outgoing connections will be made to the I2P network. Ignored if -i2psam is not set. Listening for incoming I2P connections is done through the SAM proxy, not by binding to a local address and port (default: 1)"))); strUsage += HelpMessageOpt("-onlynet=", _("Only connect to nodes in network (ipv4, ipv6, onion or i2p)")); - strUsage += HelpMessageOpt("-disableipv4", _("Disable Ipv4 network connections") + " " + _("(default: 0)")); - strUsage += HelpMessageOpt("-disableipv6", _("Disable Ipv6 network connections") + " " + _("(default: 0)")); + strUsage += HelpMessageOpt("-disableipv4", _("Disable Ipv4 network connections") + " " + strprintf(_("(default: %u)"), DEFAULT_DISABLE_IPV4)); + strUsage += HelpMessageOpt("-disableipv6", _("Disable Ipv6 network connections") + " " + strprintf(_("(default: %u)"), DEFAULT_DISABLE_IPV6)); strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), 1)); strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with Bloom filters (default: %u)"), 1)); @@ -1647,8 +1647,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::set nets; BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) { enum Network net = ParseNetwork(snet); - if (net == NET_UNROUTABLE) + if (net == NET_UNROUTABLE) { return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); + } else if (net == NET_IPV4 && GetBoolArg("-disableipv4", DEFAULT_DISABLE_IPV4)) { + return InitError(strprintf(_("-onlynet=ipv4 is incompatible with -disableipv4 !"))); + } else if (net == NET_IPV6 && GetBoolArg("-disableipv6", DEFAULT_DISABLE_IPV4)) { + return InitError(strprintf(_("-onlynet=ipv6 is incompatible with -disableipv6 !"))); + } nets.insert(net); } for (int n = 0; n < NET_MAX; n++) { @@ -1658,6 +1663,22 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } + if(mapMultiArgs["-disableipv6"].size() > 1) { + return InitError("-disableipv6 can only be used once"); + } + + if(mapMultiArgs["-disableipv4"].size() > 1) { + return InitError("-disableipv4 can only be used once"); + } + + if (GetBoolArg("-disableipv6", DEFAULT_DISABLE_IPV6)) { + SetReachable(NET_IPV6, false); + } + + if (GetBoolArg("-disableipv4", DEFAULT_DISABLE_IPV4)) { + SetReachable(NET_IPV4, false); + } + //fprintf(stderr,"%s tik19\n", __FUNCTION__); if (mapArgs.count("-allowlist")) { BOOST_FOREACH(const std::string& net, mapMultiArgs["-allowlist"]) { diff --git a/src/net.cpp b/src/net.cpp index f6893a54e..168f2b169 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -50,6 +50,9 @@ extern int32_t HUSH_TESTNODE; // Satoshi originally used 10 seconds(!), did they know something Peter Wuille didn't? #define DUMP_ADDRESSES_INTERVAL 300 +// Run asmap health check every 24hr by default +#define ASMAP_HEALTHCHECK_INTERVAL 24*60*60 + // This is every 2 blocks, on avg, on HUSH3 #define DUMP_ZINDEX_INTERVAL 150 @@ -1648,6 +1651,30 @@ int64_t PoissonNextSend(int64_t now, int average_interval_seconds) return now + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5); } +void ASMapHealthCheck() { + std::set clearnet_asns{}; + int unmapped_count{0}; + LOCK(cs_vNodes); + + for (const auto& pnode : vNodes) { + auto address = pnode->addr; + if(address.IsTor() || address.IsI2P() || address.IsCJDNS()) { + // These networks do not have ASNs, skip them + continue; + } + uint32_t asn = address.GetMappedAS(addrman.m_asmap); + if (asn == 0) { + ++unmapped_count; + continue; + } + clearnet_asns.insert(asn); + } + + LogPrintf("ASMap Health Check: %i clearnet peers are mapped to %i ASNs with %i peers being unmapped\n", vNodes.size(), clearnet_asns.size(), unmapped_count); +} + + + void ThreadOpenConnections() { // Connect to specific addresses @@ -1753,7 +1780,7 @@ void ThreadOpenConnections() int64_t nNow = GetTime(); int nTries = 0; - LogPrint("net", "Resolving addrman collisions\n"); + LogPrint("net", "Resolving addrman collisions\n"); addrman.ResolveCollisions(); while (true) { @@ -2378,10 +2405,14 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) scheduler.scheduleEvery(&DumpZindexStats, DUMP_ZINDEX_INTERVAL); } - // Dump network addresses - scheduler.scheduleEvery(&DumpAddresses, DUMP_ADDRESSES_INTERVAL); - + // Look for ~/.hush/AC_NAME/plz_stop scheduler.scheduleEvery(&CheckIfWeShouldStop, CHECK_PLZ_STOP_INTERVAL); + + // Schedule ASMap Health check to run regularly + scheduler.scheduleEvery(&ASMapHealthCheck, ASMAP_HEALTHCHECK_INTERVAL); + + // and schedule it to run once in 5 mins when we hopefully have peers connected + scheduler.scheduleFromNow(&ASMapHealthCheck, 300); } bool StopNode() diff --git a/src/net.h b/src/net.h index f7df49aa7..8684b3419 100644 --- a/src/net.h +++ b/src/net.h @@ -85,6 +85,12 @@ static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = (_MAX_BLOCK_SIZE + 24); static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ static const bool DEFAULT_LISTEN = true; + +/** -disableipv4 default */ +static const bool DEFAULT_DISABLE_IPV4 = false; +/** -disableipv6 default */ +static const bool DEFAULT_DISABLE_IPV6 = false; + /** The maximum number of entries in mapAskFor */ static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ; /** The maximum number of entries in setAskFor (larger due to getdata latency)*/ diff --git a/src/version.h b/src/version.h index 641bc489b..27553d45d 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,5 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers -// Copyright (c) 2016-2024 The Hush developers +// Copyright (c) 2016-2025 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 /****************************************************************************** @@ -21,7 +21,7 @@ #define HUSH_VERSION_H // network protocol versioning -static const int PROTOCOL_VERSION = 1987427; +static const int PROTOCOL_VERSION = 1987428; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; //! In this version, 'getheaders' was introduced. diff --git a/util/build-debian-package.sh b/util/build-debian-package.sh index 24bd4fe19..e277b8725 100755 --- a/util/build-debian-package.sh +++ b/util/build-debian-package.sh @@ -6,6 +6,14 @@ ## ./util/build-debian-package.sh # build amd64 package ## ./util/build-debian-package.sh aarch64 # build package for specific archiecture +# Check if running on Debian and exit if it is not +if grep -qi "Debian" /etc/os-release; then + : +else + echo -e "NOT RUNNING THIS SCRIPT ON DEBIAN! Try again with Debian." >&2 + exit 1 +fi + ARCH=${1:-amd64} echo "Let There Be Hush Debian Packages"