Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/devtools/gen-manpages.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
for relpath in BINARIES:
abspath = os.path.join(builddir, relpath)
try:
r = subprocess.run([abspath, '--version'], stdout=subprocess.PIPE, universal_newlines=True)
r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, universal_newlines=True)
except IOError:
print(f'{abspath} not found or not an executable', file=sys.stderr)
sys.exit(1)
Comment on lines 38 to 42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix exception handling to catch CalledProcessError.

Adding check=True at line 39 causes subprocess.run to raise subprocess.CalledProcessError on non-zero exit codes, but the exception handler only catches IOError. This will result in an unhandled exception crash instead of the intended error message.

Apply this diff to fix the exception handling:

     try:
         r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, universal_newlines=True)
-    except IOError:
+    except (IOError, subprocess.CalledProcessError):
         print(f'{abspath} not found or not an executable', file=sys.stderr)
         sys.exit(1)

Note regarding static analysis: The Ruff S603 warning about untrusted input is a false positive here, as abspath is constructed from controlled sources (project-built binaries).

🧰 Tools
🪛 Ruff (0.14.6)

39-39: subprocess call: check for execution of untrusted input

(S603)

🤖 Prompt for AI Agents
In contrib/devtools/gen-manpages.py around lines 38-42, the try/except only
catches IOError but subprocess.run(..., check=True) will raise
subprocess.CalledProcessError on non-zero exit codes; change the exception
handler to catch subprocess.CalledProcessError (and still handle OSError/IOError
for missing executable) and keep the same stderr message and sys.exit(1);
reference subprocess.CalledProcessError (or import it) so the new except clause
handles both failure modes.

Expand Down
2 changes: 1 addition & 1 deletion doc/design/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class dash-qt,dashd,dash-cli,dash-wallet bold

</td></tr></table>

- The graph shows what _linker symbols_ (functions and variables) from each library other libraries can call and reference directly, but it is not a call graph. For example, there is no arrow connecting *libbitcoin_wallet* and *libbitcoin_node* libraries, because these libraries are intended to be modular and not depend on each other's internal implementation details. But wallet code still is still able to call node code indirectly through the `interfaces::Chain` abstract class in [`interfaces/chain.h`](../../src/interfaces/chain.h) and node code calls wallet code through the `interfaces::ChainClient` and `interfaces::Chain::Notifications` abstract classes in the same file. In general, defining abstract classes in [`src/interfaces/`](../../src/interfaces/) can be a convenient way of avoiding unwanted direct dependencies or circular dependencies between libraries.
- The graph shows what _linker symbols_ (functions and variables) from each library other libraries can call and reference directly, but it is not a call graph. For example, there is no arrow connecting *libbitcoin_wallet* and *libbitcoin_node* libraries, because these libraries are intended to be modular and not depend on each other's internal implementation details. But wallet code is still able to call node code indirectly through the `interfaces::Chain` abstract class in [`interfaces/chain.h`](../../src/interfaces/chain.h) and node code calls wallet code through the `interfaces::ChainClient` and `interfaces::Chain::Notifications` abstract classes in the same file. In general, defining abstract classes in [`src/interfaces/`](../../src/interfaces/) can be a convenient way of avoiding unwanted direct dependencies or circular dependencies between libraries.

- *libdash_consensus* should be a standalone dependency that any library can depend on, and it should not depend on any other libraries itself.

Expand Down
34 changes: 17 additions & 17 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,7 @@ obj/build.h: FORCE
"$(abs_top_srcdir)"
libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h


# server: shared between dashd and dash-qt
# Contains code accessing mempool and chain state that is meant to be separated
# from wallet and gui code (see node/README.md). Shared code should go in
# libbitcoin_common or libbitcoin_util libraries, instead.
# node #
libbitcoin_node_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(MINIUPNPC_CPPFLAGS) $(NATPMP_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
libbitcoin_node_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_node_a_SOURCES = \
Expand Down Expand Up @@ -619,7 +615,9 @@ endif
if !ENABLE_WALLET
libbitcoin_node_a_SOURCES += dummywallet.cpp
endif
#

# zmq #
if ENABLE_ZMQ
libbitcoin_zmq_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(ZMQ_CFLAGS)
libbitcoin_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Expand All @@ -630,10 +628,9 @@ libbitcoin_zmq_a_SOURCES = \
zmq/zmqrpc.cpp \
zmq/zmqutil.cpp
endif
#


# wallet: shared between dashd and dash-qt, but only linked
# when wallet enabled
# wallet #
libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(BDB_CPPFLAGS) $(SQLITE_CFLAGS)
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_a_SOURCES = \
Expand Down Expand Up @@ -677,18 +674,17 @@ endif
if USE_BDB
libbitcoin_wallet_a_SOURCES += wallet/bdb.cpp wallet/salvage.cpp
endif
#

# wallet tool #
libbitcoin_wallet_tool_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libbitcoin_wallet_tool_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_tool_a_SOURCES = \
wallet/wallettool.cpp \
$(BITCOIN_CORE_H)
#

# crypto primitives library

# crypto_base contains the unspecialized (unoptimized) versions of our
# crypto functions. Functions that require custom compiler flags and/or
# runtime opt-in are omitted.
# crypto #
crypto_libbitcoin_crypto_base_la_CPPFLAGS = $(AM_CPPFLAGS) $(PIC_FLAGS)

# Specify -static in both CXXFLAGS and LDFLAGS so libtool will only build a
Expand Down Expand Up @@ -849,8 +845,9 @@ crypto_libbitcoin_crypto_arm_shani_la_CPPFLAGS = $(AM_CPPFLAGS)
crypto_libbitcoin_crypto_arm_shani_la_CXXFLAGS += $(ARM_SHANI_CXXFLAGS)
crypto_libbitcoin_crypto_arm_shani_la_CPPFLAGS += -DENABLE_ARM_SHANI
crypto_libbitcoin_crypto_arm_shani_la_SOURCES = crypto/sha256_arm_shani.cpp
#

# consensus: shared between all executables that validate any consensus rules.
# consensus #
libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_consensus_a_SOURCES = \
Expand Down Expand Up @@ -891,8 +888,9 @@ libbitcoin_consensus_a_SOURCES = \
util/strencodings.h \
util/string.cpp \
version.h
#

# common: shared between dashd, and dash-qt and non-server tools
# common #
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_common_a_SOURCES = \
Expand Down Expand Up @@ -937,8 +935,9 @@ libbitcoin_common_a_SOURCES = \
script/standard.cpp \
warnings.cpp \
$(BITCOIN_CORE_H)
#

# util: shared between all executables.
# util #
libbitcoin_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libbitcoin_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_util_a_SOURCES = \
Expand Down Expand Up @@ -996,8 +995,9 @@ libbitcoin_util_a_SOURCES = \
if USE_LIBEVENT
libbitcoin_util_a_SOURCES += util/url.cpp
endif
#

# cli: shared between dash-cli and dash-qt
# cli #
libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_cli_a_SOURCES = \
Expand Down
36 changes: 19 additions & 17 deletions src/Makefile.test_util.include
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
LIBTEST_UTIL=libtest_util.a

EXTRA_LIBRARIES += \
$(LIBTEST_UTIL)
$(LIBTEST_UTIL)

TEST_UTIL_H = \
test/util/blockfilter.h \
test/util/chainstate.h \
test/util/json.h \
test/util/index.h \
test/util/llmq_tests.h \
test/util/logging.h \
test/util/mining.h \
test/util/net.h \
test/util/poolresourcetester.h \
test/util/script.h \
test/util/setup_common.h \
test/util/str.h \
test/util/transaction_utils.h \
test/util/wallet.h \
test/util/validation.h \
test/util/xoroshiro128plusplus.h
test/util/blockfilter.h \
test/util/chainstate.h \
test/util/json.h \
test/util/index.h \
test/util/llmq_tests.h \
test/util/logging.h \
test/util/mining.h \
test/util/net.h \
test/util/poolresourcetester.h \
test/util/script.h \
test/util/setup_common.h \
test/util/str.h \
test/util/transaction_utils.h \
test/util/txmempool.h \
test/util/wallet.h \
test/util/validation.h \
test/util/xoroshiro128plusplus.h

libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libtest_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Expand All @@ -38,6 +39,7 @@ libtest_util_a_SOURCES = \
test/util/setup_common.cpp \
test/util/str.cpp \
test/util/transaction_utils.cpp \
test/util/txmempool.cpp \
test/util/validation.cpp \
test/util/wallet.cpp \
$(TEST_UTIL_H)
19 changes: 12 additions & 7 deletions src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ static void SetupWalletToolArgs(ArgsManager& argsman)
argsman.AddCommand("createfromdump", "Create new wallet file from dumped records", OptionsCategory::COMMANDS);
}

static bool WalletAppInit(ArgsManager& args, int argc, char* argv[])
static std::optional<int> WalletAppInit(ArgsManager& args, int argc, char* argv[])
{
SetupWalletToolArgs(args);
std::string error_message;
if (!args.ParseParameters(argc, argv, error_message)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error_message);
return false;
return EXIT_FAILURE;
}
if (argc < 2 || HelpRequested(args) || args.IsArgSet("-version")) {
const bool missing_args{argc < 2};
if (missing_args || HelpRequested(args) || args.IsArgSet("-version")) {
std::string strUsage = strprintf("%s dash-wallet version", PACKAGE_NAME) + " " + FormatFullVersion() + "\n";

if (args.IsArgSet("-version")) {
Expand All @@ -72,20 +73,24 @@ static bool WalletAppInit(ArgsManager& args, int argc, char* argv[])
strUsage += "\n" + args.GetHelpMessage();
}
tfm::format(std::cout, "%s", strUsage);
return false;
if (missing_args) {
tfm::format(std::cerr, "Error: too few parameters\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

// check for printtoconsole, allow -debug
LogInstance().m_print_to_console = args.GetBoolArg("-printtoconsole", args.GetBoolArg("-debug", false));

if (!CheckDataDirOption()) {
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", args.GetArg("-datadir", ""));
return false;
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
SelectParams(args.GetChainName());

return true;
return std::nullopt;
}

MAIN_FUNCTION
Expand All @@ -98,7 +103,7 @@ MAIN_FUNCTION
SetupEnvironment();
RandomInit();
try {
if (!WalletAppInit(args, argc, argv)) return EXIT_FAILURE;
if (const auto maybe_exit{WalletAppInit(args, argc, argv)}) return *maybe_exit;
} catch (...) {
PrintExceptionContinue(std::current_exception(), "WalletAppInit()");
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)

const auto BadPortWarning = [](const char* prefix, uint16_t port) {
return strprintf(_("%s request to listen on port %u. This port is considered \"bad\" and "
"thus it is unlikely that any Dash Core peers connect to it. See "
"thus it is unlikely that any peer will connect to it. See "
"doc/p2p-bad-ports.md for details and a full list."),
prefix,
port);
Expand Down
16 changes: 6 additions & 10 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,7 @@ struct Peer {

struct TxRelay {
mutable RecursiveMutex m_bloom_filter_mutex;
/** Whether the peer wishes to receive transaction announcements.
*
* This is initially set based on the fRelay flag in the received
* `version` message. If initially set to false, it can only be flipped
* to true if we have offered the peer NODE_BLOOM services and it sends
* us a `filterload` or `filterclear` message. See BIP37. */
/** Whether we relay transactions to this peer. */
bool m_relay_txs GUARDED_BY(m_bloom_filter_mutex){false};
/** A bloom filter for which transactions to announce to the peer. See BIP37. */
std::unique_ptr<CBloomFilter> m_bloom_filter PT_GUARDED_BY(m_bloom_filter_mutex) GUARDED_BY(m_bloom_filter_mutex){nullptr};
Expand Down Expand Up @@ -3817,11 +3812,12 @@ void PeerManagerImpl::ProcessMessage(
}
peer->m_starting_height = starting_height;

// We only initialize the m_tx_relay data structure if:
// - this isn't an outbound block-relay-only connection; and
// We only initialize the Peer::TxRelay m_relay_txs data structure if:
// - this isn't an outbound block-relay-only connection, and
// - this isn't an outbound feeler connection, and
// - fRelay=true or we're offering NODE_BLOOM to this peer
// (NODE_BLOOM means that the peer may turn on tx relay later)
// - fRelay=true (the peer wishes to receive transaction announcements)
// or we're offering NODE_BLOOM to this peer. NODE_BLOOM means that
// the peer may turn on transaction relay later.
if (!pfrom.IsBlockOnlyConn() &&
!pfrom.IsFeelerConn() &&
(fRelay || (peer->m_our_services & NODE_BLOOM))) {
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
<item>
<widget class="QLineEdit" name="externalSignerPath">
<property name="toolTip">
<string>Full path to a Dash Core compatible script (e.g. C:\Downloads\hwi.exe or /Users/you/Downloads/hwi.py). Beware: malware can steal your coins!</string>
<string>Full path to a %1 compatible script (e.g. C:\Downloads\hwi.exe or /Users/you/Downloads/hwi.py). Beware: malware can steal your coins!</string>
</property>
</widget>
</item>
Expand Down
4 changes: 3 additions & 1 deletion src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :

showPage(0);

#ifndef ENABLE_EXTERNAL_SIGNER
#ifdef ENABLE_EXTERNAL_SIGNER
ui->externalSignerPath->setToolTip(ui->externalSignerPath->toolTip().arg(PACKAGE_NAME));
#else
//: "External signing" means using devices such as hardware wallets.
ui->externalSignerPath->setToolTip(tr("Compiled without external signing support (required for external signing)"));
ui->externalSignerPath->setEnabled(false);
Expand Down
12 changes: 7 additions & 5 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static RPCHelpMan getpeerinfo()
{RPCResult::Type::STR_HEX, "verified_pubkey_hash", "Only present when the peer is a masternode and successfully "
"authenticated via MNAUTH. In this case, this field contains the "
"hash of the masternode's operator public key"},
{RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether peer has asked us to relay transactions to it"},
{RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether we relay transactions to this peer"},
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
Expand All @@ -133,9 +133,9 @@ static RPCHelpMan getpeerinfo()
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
{RPCResult::Type::NUM, "pingtime", /*optional=*/true, "ping time (if available)"},
{RPCResult::Type::NUM, "minping", /*optional=*/true, "minimum observed ping time (if any at all)"},
{RPCResult::Type::NUM, "pingwait", /*optional=*/true, "ping wait (if non-zero)"},
{RPCResult::Type::NUM, "pingtime", /*optional=*/true, "The last ping time in milliseconds (ms), if any"},
{RPCResult::Type::NUM, "minping", /*optional=*/true, "The minimum observed ping time in milliseconds (ms), if any"},
{RPCResult::Type::NUM, "pingwait", /*optional=*/true, "The duration in milliseconds (ms) of an outstanding ping (if non-zero)"},
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
{RPCResult::Type::STR, "subver", "The string version"},
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
Expand Down Expand Up @@ -219,7 +219,9 @@ static RPCHelpMan getpeerinfo()
ServiceFlags services{statestats.their_services};
obj.pushKV("services", strprintf("%016x", services));
obj.pushKV("servicesnames", GetServicesNames(services));
obj.pushKV("relaytxes", statestats.m_relay_txs);
if (fStateStats) {
obj.pushKV("relaytxes", statestats.m_relay_txs);
}
if (!stats.verifiedProRegTxHash.IsNull()) {
obj.pushKV("verified_proregtx_hash", stats.verifiedProRegTxHash.ToString());
}
Expand Down
1 change: 1 addition & 0 deletions src/test/blockencodings_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <consensus/merkle.h>
#include <pow.h>
#include <streams.h>
#include <test/util/txmempool.h>

#include <test/util/setup_common.h>

Expand Down
1 change: 1 addition & 0 deletions src/test/evo_deterministicmns_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <script/signingprovider.h>
#include <script/standard.h>
#include <spork.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <validation.h>

Expand Down
1 change: 1 addition & 0 deletions src/test/fuzz/tx_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <test/util/mining.h>
#include <test/util/script.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <validation.h>
#include <validationinterface.h>

Expand Down
1 change: 1 addition & 0 deletions src/test/fuzz/validation_load_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <util/time.h>
#include <validation.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/mempool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <policy/policy.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <util/system.h>
#include <util/time.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <policy/policy.h>
#include <pow.h>
#include <script/standard.h>
#include <test/util/txmempool.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/system.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/policyestimator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <policy/fees.h>
#include <policy/policy.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <uint256.h>
#include <util/time.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/sigopcount_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <coins.h>
#include <key.h>
#include <pubkey.h>
#include <script/script.h>
Expand Down
Loading
Loading