From ffb7275b656c2ab8138982400bba46e5a9ca155b Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:52:17 -0600 Subject: [PATCH 1/9] Merge bitcoin/bitcoin#30268: util: add missing VecDeque include f51da34ec1a806d321a468691fa66082eef10ad9 utils: add missing include (Cory Fields) Pull request description: Noticed when testing `VecDeque` with no other includes. For libc++, need type_traits for `std::is_trivially_destructible_v`. ACKs for top commit: maflcko: ACK f51da34ec1a806d321a468691fa66082eef10ad9 glozow: ACK f51da34ec1a806d321a468691fa66082eef10ad9 sipa: utACK f51da34ec1a806d321a468691fa66082eef10ad9 Tree-SHA512: bf96910abe9aaddd8586e6cc8f68a9bbac4c26d976ebeebcfa86b86c0da5783c1cbdbc7fa09b62cdcfde19e6442eb65a66bf1e2e80408d68e9dd9689dc22b0fa --- src/util/vecdeque.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/vecdeque.h b/src/util/vecdeque.h index 00034d69f444..cde15d9cd95f 100644 --- a/src/util/vecdeque.h +++ b/src/util/vecdeque.h @@ -9,6 +9,7 @@ #include #include +#include /** Data structure largely mimicking std::deque, but using single preallocated ring buffer. * From 7cf73bebfe6837cc65515281626c4d3c2ba192cb Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:52:22 -0600 Subject: [PATCH 2/9] Merge bitcoin/bitcoin#30551: doc: mention optional dependencies (qrencode, zmq) in OpenBSD build docs 903def1ffd2903615de509d5869cadf5315f04e2 doc: mention optional dependencies (qrencode, zmq) in OpenBSD build docs (Sebastian Falbesoner) Pull request description: The wording is taken from the FreeBSD build docs. Tested on OpenBSD 7.5. See the following links for the package names: - https://openbsd.app/?search=libqrencode - https://openbsd.app/?search=zeromq Thanks to hebasto for noticing that this was missing. ACKs for top commit: maflcko: review ACK 903def1ffd2903615de509d5869cadf5315f04e2 hebasto: ACK 903def1ffd2903615de509d5869cadf5315f04e2, I can successfully build with the `libqrencode` and `zeromq` packages on my OpenBSD 7.5 installation. Tree-SHA512: 955e4892948a7703627d304a41a774f7cca0e4c672bdfa0edf531587d6970444aa49195b0f6f531ce375c8e7c2af6bbfa1a12e0612ae7a65f3e454fb17958672 --- doc/build-openbsd.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 0524df03aaee..ba87afa9061f 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -64,6 +64,22 @@ Dash Core includes a GUI built with the cross-platform Qt Framework. To compile pkg_add qt5 ``` +###### libqrencode + +The GUI can encode addresses in a QR Code. To build in QR support for the GUI, install `libqrencode`. Skip if not using the GUI or don't want QR code functionality. +```bash +pkg_add libqrencode +``` +--- + +#### Notifications +###### ZeroMQ + +Dash Core can provide notifications via ZeroMQ. If the package is installed, support will be compiled in. +```bash +pkg_add zeromq +``` + ## Building Dash Core **Important**: Use `gmake` (the non-GNU `make` will exit with an error). From d6ab4b9348743d6060a56f9c4290781f2370fbe6 Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:52:27 -0600 Subject: [PATCH 3/9] Merge bitcoin/bitcoin#30216: build: Fix building `fuzz` binary on on SunOS / illumos 3299abce948f205bb1354993614b669189f9b89f build: Fix building `fuzz` binary on on SunOS / illumos (Hennadii Stepanov) Pull request description: On master branch @ 457e1846d2bf6ef9d54b9ba1a330ba8bbff13091, building the `fuzz` binary fails: ``` $ ./autogen.sh $ ./configure $ gmake -C src test/fuzz/fuzz < snip > CXX test/fuzz/fuzz-http_request.o test/fuzz/http_request.cpp:13:10: fatal error: event2/buffer.h: No such file or directory 13 | #include | ^~~~~~~~~~~~~~~~~ compilation terminated. gmake: *** [Makefile:17138: test/fuzz/fuzz-http_request.o] Error 1 gmake: Leaving directory '/export/home/hebasto/git/bitcoin/src' ``` The testing system: ``` $ uname -a SunOS openindiana 5.11 illumos-82079dec87 i86pc i386 i86pc ``` This PR fixes this issue. ACKs for top commit: maflcko: ACK 3299abce948f205bb1354993614b669189f9b89f Tree-SHA512: 43048cf0d3db47d71263da179e07225afd901ed2039ee4d17314ff7b581ab36f41282fde3b1210926cecda546320dc573937c564520f61fbb236c2b9914ed0d4 --- src/Makefile.test.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 0ee6b75e336b..efc856e152e4 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -301,7 +301,7 @@ FUZZ_SUITE_LD_COMMON += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif if ENABLE_FUZZ_BINARY -test_fuzz_fuzz_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) +test_fuzz_fuzz_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(EVENT_CFLAGS) test_fuzz_fuzz_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) test_fuzz_fuzz_LDADD = $(FUZZ_SUITE_LD_COMMON) test_fuzz_fuzz_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(LDFLAGS_WRAP_EXCEPTIONS) $(PTHREAD_FLAGS) From 11a7bb3d8e5415c8dd41105275d3a53403b2e2fb Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:01 -0600 Subject: [PATCH 4/9] Merge bitcoin/bitcoin#30596: fuzz: replace hardcoded numbers for bech32 limits 59c0ece0a785ce9e22fbfefce9ca228d85e5d43d fuzz: replace hardcoded numbers for bech32 limits (josibake) Pull request description: Follow-up to #30047 to replace a hardcoded value that was missed in the original PR ACKs for top commit: paplorinc: ACK 59c0ece0a785ce9e22fbfefce9ca228d85e5d43d dergoegge: utACK 59c0ece0a785ce9e22fbfefce9ca228d85e5d43d marcofleon: ACK 59c0ece0a785ce9e22fbfefce9ca228d85e5d43d. Ran the test a bit to be sure, lgtm. brunoerg: utACK 59c0ece0a785ce9e22fbfefce9ca228d85e5d43d Tree-SHA512: 89799928feb6752a533259117340b087ff7299f9bf204b165dd87708e15b99a338521f2ac9f9e1fd91dc48b93be839059768d9e68b172e36328232174d1dfa3f --- src/bech32.cpp | 3 --- src/bech32.h | 3 +++ src/test/fuzz/bech32.cpp | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bech32.cpp b/src/bech32.cpp index d8d31a415c22..5694ad54c8f9 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -19,9 +19,6 @@ namespace typedef std::vector data; -/** The Bech32 and Bech32m checksum size */ -constexpr size_t CHECKSUM_SIZE = 6; - /** The Bech32 and Bech32m character set for encoding. */ const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; diff --git a/src/bech32.h b/src/bech32.h index fe2a276ae078..33d1ca1935ca 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -21,6 +21,9 @@ namespace bech32 { +/** The Bech32 and Bech32m checksum size */ +constexpr size_t CHECKSUM_SIZE = 6; + enum class Encoding { INVALID, //!< Failed decoding diff --git a/src/test/fuzz/bech32.cpp b/src/test/fuzz/bech32.cpp index ffc5ba518f14..daa6e2440461 100644 --- a/src/test/fuzz/bech32.cpp +++ b/src/test/fuzz/bech32.cpp @@ -29,8 +29,9 @@ FUZZ_TARGET(bech32) std::vector input; ConvertBits<8, 5, true>([&](unsigned char c) { input.push_back(c); }, buffer.begin(), buffer.end()); - if (input.size() + 3 + 6 <= 90) { - // If it's possible to encode input in Bech32(m) without exceeding the 90-character limit: + // Input data part + 3 characters for the HRP and separator (bc1) + the checksum characters + if (input.size() + 3 + bech32::CHECKSUM_SIZE <= bech32::CharLimit::BECH32) { + // If it's possible to encode input in Bech32(m) without exceeding the bech32-character limit: for (auto encoding : {bech32::Encoding::BECH32, bech32::Encoding::BECH32M}) { const std::string encoded = bech32::Encode(encoding, "bc", input); assert(!encoded.empty()); From e01580ce197ff7854ee8ce51fecd20d7b25c343e Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:07 -0600 Subject: [PATCH 5/9] Merge bitcoin/bitcoin#30098: refactor: simplify `FormatSubVersion` using strprintf/Join 12d82817bf32396b58c8c65645012def606680b6 refactor: simplify `FormatSubVersion` using strprintf/Join (Sebastian Falbesoner) Pull request description: Rather than using std::ostringstream and manually joining the comments, use strprintf and our own `Join` helper. ACKs for top commit: maflcko: utACK 12d82817bf32396b58c8c65645012def606680b6 TheCharlatan: tACK 12d82817bf32396b58c8c65645012def606680b6 hebasto: ACK 12d82817bf32396b58c8c65645012def606680b6, I have reviewed the code and it looks OK. tdb3: ACK for 12d82817bf32396b58c8c65645012def606680b6. Tree-SHA512: b9b965c4416a4c0c8727e3c4b40da4be04b14067200220492e9bed4fa35c1907fb5cdec2a30052b9e762f71da3d3cf042f43c96ab1f2523df5bb9920b44ea2a5 --- src/clientversion.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index d3305fa23329..419efce2887f 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -7,11 +7,11 @@ #endif #include +#include #include #include -#include #include #include @@ -67,19 +67,9 @@ std::string FormatFullVersion() */ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) { - std::ostringstream ss; - ss << "/"; - ss << name << ":" << FormatVersion(nClientVersion); - if (!comments.empty()) - { - std::vector::const_iterator it(comments.begin()); - ss << "(" << *it; - for(++it; it != comments.end(); ++it) - ss << "; " << *it; - ss << ")"; - } - ss << "/"; - return ss.str(); + std::string comments_str; + if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; ")); + return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str); } std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYear, unsigned int nEndYear) From 75099908556c296297416d6d5f55dd297ba5ea6d Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:12 -0600 Subject: [PATCH 6/9] Merge bitcoin/bitcoin#30218: refactor: remove unused `CKey::Negate` method 8801e319d51209fe3a3b06e2aab5f96ceead290d refactor: remove unused `CKey::Negate` method (Sebastian Falbesoner) Pull request description: This method was introduced as a pre-requirement for the v2 transport protocol back then (see PR #14047, commit 463921bb), when it was still BIP151. With the replacement BIP324, this is not needed anymore, and it's also unlikely that for any other proposal we'd ever need to negate private keys at this abstraction level. I'd argue that this operation is usually something that should happen within a secp256k1 module (like e.g. done in MuSig2, Silent Payments...). (If there is really demand in the future, it's also trivial to reintroduce the method.) ACKs for top commit: laanwj: ACK 8801e319d51209fe3a3b06e2aab5f96ceead290d sipa: ACK 8801e319d51209fe3a3b06e2aab5f96ceead290d achow101: ACK 8801e319d51209fe3a3b06e2aab5f96ceead290d Tree-SHA512: 7bc1566399635c5c6e4940a2724c865d5443eb190024379099330c023c516f1e4f423ed9e8c42bc93413b723a5464ec79d3f879f58c0e598fe24f495238df4ec --- src/key.cpp | 6 ------ src/key.h | 3 --- src/test/fuzz/key.cpp | 10 ---------- src/test/key_tests.cpp | 31 ------------------------------- 4 files changed, 50 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index b4e84e444604..775ad4687e06 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -165,12 +165,6 @@ void CKey::MakeNewKey(bool fCompressedIn) { fCompressed = fCompressedIn; } -bool CKey::Negate() -{ - assert(keydata); - return secp256k1_ec_seckey_negate(secp256k1_context_sign, keydata->data()); -} - CPrivKey CKey::GetPrivKey() const { assert(keydata); CPrivKey seckey; diff --git a/src/key.h b/src/key.h index e88a39f1fa42..67fe19890a0a 100644 --- a/src/key.h +++ b/src/key.h @@ -124,9 +124,6 @@ class CKey //! Generate a new private key using a cryptographic PRNG. void MakeNewKey(bool fCompressed); - //! Negate private key - bool Negate(); - /** * Convert the private key to a CPrivKey (serialized OpenSSL private key data). * This is expensive. diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp index eb901f464b67..ea73a0291046 100644 --- a/src/test/fuzz/key.cpp +++ b/src/test/fuzz/key.cpp @@ -76,16 +76,6 @@ FUZZ_TARGET(key, .init = initialize_key) assert(copied_key == key); } - { - CKey negated_key = key; - negated_key.Negate(); - assert(negated_key.IsValid()); - assert(!(negated_key == key)); - - negated_key.Negate(); - assert(negated_key == key); - } - const uint256 random_uint256 = Hash(buffer); { diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index cc54589b3793..76dcdad6b563 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -200,37 +200,6 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) BOOST_CHECK(found_small); } -BOOST_AUTO_TEST_CASE(key_key_negation) -{ - // create a dummy hash for signature comparison - unsigned char rnd[8]; - std::string str = "Bitcoin key verification\n"; - GetRandBytes(rnd); - uint256 hash{Hash(str, rnd)}; - - // import the static test key - CKey key = DecodeSecret(strSecret1C); - - // create a signature - std::vector vch_sig; - std::vector vch_sig_cmp; - key.Sign(hash, vch_sig); - - // negate the key twice - BOOST_CHECK(key.GetPubKey().data()[0] == 0x03); - key.Negate(); - // after the first negation, the signature must be different - key.Sign(hash, vch_sig_cmp); - BOOST_CHECK(vch_sig_cmp != vch_sig); - BOOST_CHECK(key.GetPubKey().data()[0] == 0x02); - key.Negate(); - // after the second negation, we should have the original key and thus the - // same signature - key.Sign(hash, vch_sig_cmp); - BOOST_CHECK(vch_sig_cmp == vch_sig); - BOOST_CHECK(key.GetPubKey().data()[0] == 0x03); -} - static CPubKey UnserializePubkey(const std::vector& data) { DataStream stream{}; From fb2483ac4bc35d233fa32b3aed140223e283d98a Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:20 -0600 Subject: [PATCH 7/9] Merge bitcoin/bitcoin#29521: cli: Detect port errors in rpcconnect and rpcport 24bc46c83b39149f4845a575a82337eb46d91bdb cli: Add warning for duplicate port definition (tdb3) e208fb5d3bea4c1fb750cb0028819635ecdeb415 cli: Sanitize ports in rpcconnect and rpcport (tdb3) Pull request description: Adds invalid port detection to bitcoin-cli for -rpcconnect and -rpcport. In addition to detecting malformed/invalid ports (e.g. those outside of the 16-bit port range, not numbers, etc.), bitcoin-cli also now considers usage of port 0 to be invalid. bitcoin-cli previously considered port 0 to be valid and attempted to use it to reach bitcoind. Functional tests were added for invalid port detection as well as port prioritization. Additionally, a warning is provided when a port is specified in both -rpcconnect and -rpcport. This PR is an alternate approach to PR #27820 (e.g. SplitHostPort is unmodified). Considered an alternative to 127.0.0.1 being specified in functional tests, but at first glance, this might need an update to test_framework/util.py (e.g. rpc_url), which might be left to a future PR. ACKs for top commit: S3RK: light code review ACK 24bc46c83b39149f4845a575a82337eb46d91bdb achow101: ACK 24bc46c83b39149f4845a575a82337eb46d91bdb cbergqvist: re ACK 24bc46c83b39149f4845a575a82337eb46d91bdb Tree-SHA512: c83ab6a30a08dd1ac8b368a7dcc2b4f23170f0b61dd67ffcad7bcda05096d333bcb9821fba11018151f55b2929c0a333bfec15b8bb863d83f41fc1974c6efca5 --- src/bitcoin-cli.cpp | 37 +++++++++++++++++- test/functional/interface_bitcoin_cli.py | 49 ++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 68552727d72f..5dff6c5114e7 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -759,8 +759,41 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co // 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6) // 3. default port for chain uint16_t port{BaseParams().RPCPort()}; - SplitHostPort(gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host); - port = static_cast(gArgs.GetIntArg("-rpcport", port)); + { + uint16_t rpcconnect_port{0}; + const std::string rpcconnect_str = gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT); + if (!SplitHostPort(rpcconnect_str, rpcconnect_port, host)) { + // Uses argument provided as-is + // (rather than value parsed) + // to aid the user in troubleshooting + throw std::runtime_error(strprintf("Invalid port provided in -rpcconnect: %s", rpcconnect_str)); + } else { + if (rpcconnect_port != 0) { + // Use the valid port provided in rpcconnect + port = rpcconnect_port; + } // else, no port was provided in rpcconnect (continue using default one) + } + + if (std::optional rpcport_arg = gArgs.GetArg("-rpcport")) { + // -rpcport was specified + const uint16_t rpcport_int{ToIntegral(rpcport_arg.value()).value_or(0)}; + if (rpcport_int == 0) { + // Uses argument provided as-is + // (rather than value parsed) + // to aid the user in troubleshooting + throw std::runtime_error(strprintf("Invalid port provided in -rpcport: %s", rpcport_arg.value())); + } + + // Use the valid port provided + port = rpcport_int; + + // If there was a valid port provided in rpcconnect, + // rpcconnect_port is non-zero. + if (rpcconnect_port != 0) { + tfm::format(std::cerr, "Warning: Port specified in both -rpcconnect and -rpcport. Using -rpcport %u\n", port); + } + } + } // Obtain event base raii_event_base base = obtain_event_base(); diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py index aed1bc918847..be78828df81b 100755 --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -8,6 +8,7 @@ import re from test_framework.blocktools import COINBASE_MATURITY +from test_framework.netutil import test_ipv6_local from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -15,6 +16,7 @@ assert_raises_process_error, assert_raises_rpc_error, get_auth_cookie, + rpc_port, ) import time @@ -110,6 +112,53 @@ def run_test(self): self.log.info("Test connecting to a non-existing server") assert_raises_process_error(1, "Could not connect to the server", self.nodes[0].cli('-rpcport=1').echo) + self.log.info("Test handling of invalid ports in rpcconnect") + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:notaport", self.nodes[0].cli("-rpcconnect=127.0.0.1:notaport").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:-1", self.nodes[0].cli("-rpcconnect=127.0.0.1:-1").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:0", self.nodes[0].cli("-rpcconnect=127.0.0.1:0").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:65536", self.nodes[0].cli("-rpcconnect=127.0.0.1:65536").echo) + + self.log.info("Checking for IPv6") + have_ipv6 = test_ipv6_local() + if not have_ipv6: + self.log.info("Skipping IPv6 tests") + + if have_ipv6: + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:notaport", self.nodes[0].cli("-rpcconnect=[::1]:notaport").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:-1", self.nodes[0].cli("-rpcconnect=[::1]:-1").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:0", self.nodes[0].cli("-rpcconnect=[::1]:0").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:65536", self.nodes[0].cli("-rpcconnect=[::1]:65536").echo) + + self.log.info("Test handling of invalid ports in rpcport") + assert_raises_process_error(1, "Invalid port provided in -rpcport: notaport", self.nodes[0].cli("-rpcport=notaport").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcport: -1", self.nodes[0].cli("-rpcport=-1").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcport: 0", self.nodes[0].cli("-rpcport=0").echo) + assert_raises_process_error(1, "Invalid port provided in -rpcport: 65536", self.nodes[0].cli("-rpcport=65536").echo) + + self.log.info("Test port usage preferences") + node_rpc_port = rpc_port(self.nodes[0].index) + # Prevent bitcoin-cli from using existing rpcport in conf + conf_rpcport = "rpcport=" + str(node_rpc_port) + self.nodes[0].replace_in_config([(conf_rpcport, "#" + conf_rpcport)]) + # prefer rpcport over rpcconnect + assert_raises_process_error(1, "Could not connect to the server 127.0.0.1:1", self.nodes[0].cli(f"-rpcconnect=127.0.0.1:{node_rpc_port}", "-rpcport=1").echo) + if have_ipv6: + assert_raises_process_error(1, "Could not connect to the server ::1:1", self.nodes[0].cli(f"-rpcconnect=[::1]:{node_rpc_port}", "-rpcport=1").echo) + + assert_equal(BLOCKS, self.nodes[0].cli("-rpcconnect=127.0.0.1:18999", f'-rpcport={node_rpc_port}').getblockcount()) + if have_ipv6: + assert_equal(BLOCKS, self.nodes[0].cli("-rpcconnect=[::1]:18999", f'-rpcport={node_rpc_port}').getblockcount()) + + # prefer rpcconnect port over default + assert_equal(BLOCKS, self.nodes[0].cli(f"-rpcconnect=127.0.0.1:{node_rpc_port}").getblockcount()) + if have_ipv6: + assert_equal(BLOCKS, self.nodes[0].cli(f"-rpcconnect=[::1]:{node_rpc_port}").getblockcount()) + + # prefer rpcport over default + assert_equal(BLOCKS, self.nodes[0].cli(f'-rpcport={node_rpc_port}').getblockcount()) + # Re-enable rpcport in conf if present + self.nodes[0].replace_in_config([("#" + conf_rpcport, conf_rpcport)]) + self.log.info("Test connecting with non-existing RPC cookie file") assert_raises_process_error(1, "Could not locate RPC credentials", self.nodes[0].cli('-rpccookiefile=does-not-exist', '-rpcpassword=').echo) From c88f6d6bb5ea97afeb161b4074928312ba5a2eb3 Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:44 -0600 Subject: [PATCH 8/9] Merge bitcoin/bitcoin#30199: clang-tidy: Add `bugprone-move-forwarding-reference` check 88cdb5967f093cf96e9184a48c0d9e34cea9d341 clang-tidy: Add `bugprone-move-forwarding-reference` check (Hennadii Stepanov) Pull request description: This PR adds [`bugprone-move-forwarding-reference`](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/move-forwarding-reference.html) to the clang-tidy checks. ACKs for top commit: maflcko: utACK 88cdb5967f093cf96e9184a48c0d9e34cea9d341 Tree-SHA512: 8366c895085d0656a4491035aa8863c9dca12885c2bdf0392bebc63d6f6f5473ec263594e5fde70a3c211e95d19b9cd98e2c574ced91b4c970cce0edce40bceb --- src/.clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/.clang-tidy b/src/.clang-tidy index ce43637d0490..864cb4c11861 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -2,6 +2,7 @@ Checks: ' -*, bitcoin-*, bugprone-argument-comment, +bugprone-move-forwarding-reference, bugprone-use-after-move, bugprone-lambda-function-name, misc-unused-using-decls, From 654b9798dfea98648d43b1deb78c4116be56e75c Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Sun, 15 Nov 2026 20:53:48 -0600 Subject: [PATCH 9/9] Merge bitcoin/bitcoin#28167: init: Add option for rpccookie permissions (replace 26088) 73f0a6cbd0b628675028fbd5a37eff8115e7ccfe doc: detail -rpccookieperms option (willcl-ark) d2afa2690cceb0012b2aa1960e1cfa497f3103fa test: add rpccookieperms test (willcl-ark) f467aede78533dac60a118e1566138d65522c213 init: add option for rpccookie permissions (willcl-ark) 7df03f1a923e239cea8c9b0d603a9eb00863a40c util: add perm string helper functions (willcl-ark) Pull request description: This PR picks up #26088 by aureleoules which adds a bitcoind launch option `-rpccookieperms` to set the file permissions of the cookie generated by bitcoin core. Example usage to make the generated cookie group-readable: `./src/bitcoind -rpccookieperms=group`. Accepted values for `-rpccookieperms` are `[owner|group|all]`. We let `fs::perms` handle platform-specific permissions changes. ACKs for top commit: achow101: ACK 73f0a6cbd0b628675028fbd5a37eff8115e7ccfe ryanofsky: Code review ACK 73f0a6cbd0b628675028fbd5a37eff8115e7ccfe. Main change since last review is no longer throwing a skip exception in the rpc test on windows, so other checks can run after it, and overall test result is passing, not skipped. Also were clarifying renames and documentation improvements. tdb3: cr ACK 73f0a6cbd0b628675028fbd5a37eff8115e7ccfe Tree-SHA512: e800d59a44aca10e1c58ca69bf3fdde9f6ccf5eab4b7b962645af6d6bc0cfa3a357701e409c8c60d8d7744fcd33a91e77ada11790aa88cd7811ef60fab86ab11 Dash adaptations: - src/init.cpp: -rpccookieperms registered between -rpccookiefile and Dash's -rpcexternaluser/-rpcexternalworkqueue args, keeping the alphabetical order --- doc/init.md | 6 ++++-- src/httprpc.cpp | 19 +++++++++++++++-- src/init.cpp | 1 + src/rpc/request.cpp | 21 +++++++++++++------ src/rpc/request.h | 4 +++- src/util/fs_helpers.cpp | 40 ++++++++++++++++++++++++++++++++++++ src/util/fs_helpers.h | 14 +++++++++++++ test/functional/rpc_users.py | 39 +++++++++++++++++++++++++++++++++++ 8 files changed, 133 insertions(+), 11 deletions(-) diff --git a/doc/init.md b/doc/init.md index d557cfb0541a..94a30ede6e84 100644 --- a/doc/init.md +++ b/doc/init.md @@ -35,8 +35,10 @@ it will use a special cookie file for authentication. The cookie is generated wi content when the daemon starts, and deleted when it exits. Read access to this file controls who can access it through RPC. -By default the cookie is stored in the data directory, but it's location can be overridden -with the option '-rpccookiefile'. +By default the cookie is stored in the data directory, but its location can be +overridden with the option `-rpccookiefile`. Default file permissions for the +cookie are "owner" (i.e. user read/writeable) via default application-wide file +umask of `0077`, but these can be overridden with the `-rpccookieperms` option. This allows for running dashd without having to do any manual configuration. diff --git a/src/httprpc.cpp b/src/httprpc.cpp index ffd73f68d72f..1b93b83f2584 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -20,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -281,8 +284,20 @@ static bool InitRPCAuthentication() { if (gArgs.GetArg("-rpcpassword", "") == "") { - LogPrintf("Using random cookie authentication.\n"); - if (!GenerateAuthCookie(&strRPCUserColonPass)) { + LogInfo("Using random cookie authentication.\n"); + + std::optional cookie_perms{std::nullopt}; + auto cookie_perms_arg{gArgs.GetArg("-rpccookieperms")}; + if (cookie_perms_arg) { + auto perm_opt = InterpretPermString(*cookie_perms_arg); + if (!perm_opt) { + LogInfo("Invalid -rpccookieperms=%s; must be one of 'owner', 'group', or 'all'.\n", *cookie_perms_arg); + return false; + } + cookie_perms = *perm_opt; + } + + if (!GenerateAuthCookie(&strRPCUserColonPass, cookie_perms)) { return false; } } else { diff --git a/src/init.cpp b/src/init.cpp index dc2a1cb95296..8153ac035d55 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -887,6 +887,7 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-rpcbind=[:port]", "Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::RPC); argsman.AddArg("-rpcdoccheck", strprintf("Throw a non-fatal error at runtime if the documentation for an RPC is incorrect (default: %u)", DEFAULT_RPC_DOC_CHECK), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC); argsman.AddArg("-rpccookiefile=", "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)", ArgsManager::ALLOW_ANY, OptionsCategory::RPC); + argsman.AddArg("-rpccookieperms=", strprintf("Set permissions on the RPC auth cookie file so that it is readable by [owner|group|all] (default: owner [via umask 0077])"), ArgsManager::ALLOW_ANY, OptionsCategory::RPC); argsman.AddArg("-rpcexternaluser=", "List of comma-separated usernames for JSON-RPC external connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC); argsman.AddArg("-rpcexternalworkqueue=", strprintf("Set the depth of the work queue to service external RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC); argsman.AddArg("-rpcpassword=", "Password for JSON-RPC connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC); diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index 219879474362..58749d653f68 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -6,12 +6,11 @@ #include -#include - #include #include #include #include +#include #include #include @@ -83,7 +82,7 @@ static fs::path GetAuthCookieFile(bool temp=false) static bool g_generated_cookie = false; -bool GenerateAuthCookie(std::string *cookie_out) +bool GenerateAuthCookie(std::string* cookie_out, std::optional cookie_perms) { const size_t COOKIE_SIZE = 32; unsigned char rand_pwd[COOKIE_SIZE]; @@ -97,7 +96,7 @@ bool GenerateAuthCookie(std::string *cookie_out) fs::path filepath_tmp = GetAuthCookieFile(true); file.open(filepath_tmp); if (!file.is_open()) { - LogPrintf("Unable to open cookie authentication file %s for writing\n", fs::PathToString(filepath_tmp)); + LogInfo("Unable to open cookie authentication file %s for writing\n", fs::PathToString(filepath_tmp)); return false; } file << cookie; @@ -105,11 +104,21 @@ bool GenerateAuthCookie(std::string *cookie_out) fs::path filepath = GetAuthCookieFile(false); if (!RenameOver(filepath_tmp, filepath)) { - LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath)); + LogInfo("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath)); return false; } + if (cookie_perms) { + std::error_code code; + fs::permissions(filepath, cookie_perms.value(), fs::perm_options::replace, code); + if (code) { + LogInfo("Unable to set permissions on cookie authentication file %s\n", fs::PathToString(filepath_tmp)); + return false; + } + } + g_generated_cookie = true; - LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath)); + LogInfo("Generated RPC authentication cookie %s\n", fs::PathToString(filepath)); + LogInfo("Permissions used for cookie: %s\n", PermsToSymbolicString(fs::status(filepath).permissions())); if (cookie_out) *cookie_out = cookie; diff --git a/src/rpc/request.h b/src/rpc/request.h index 06c061f5722a..dff6acbe5408 100644 --- a/src/rpc/request.h +++ b/src/rpc/request.h @@ -8,9 +8,11 @@ #include +#include #include #include +#include UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id); UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id); @@ -18,7 +20,7 @@ std::string JSONRPCReply(const UniValue& result, const UniValue& error, const Un UniValue JSONRPCError(int code, const std::string& message); /** Generate a new RPC authentication cookie and write it to disk */ -bool GenerateAuthCookie(std::string *cookie_out); +bool GenerateAuthCookie(std::string* cookie_out, std::optional cookie_perms=std::nullopt); /** Read the RPC authentication cookie from disk */ bool GetAuthCookie(std::string *cookie_out); /** Delete RPC authentication cookie from disk */ diff --git a/src/util/fs_helpers.cpp b/src/util/fs_helpers.cpp index adcf5078bc74..9197195b03e7 100644 --- a/src/util/fs_helpers.cpp +++ b/src/util/fs_helpers.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -310,3 +311,42 @@ bool TryCreateDirectories(const fs::path& p) // create_directories didn't create the directory, it had to have existed already return false; } + +std::string PermsToSymbolicString(fs::perms p) +{ + std::string perm_str(9, '-'); + + auto set_perm = [&](size_t pos, fs::perms required_perm, char letter) { + if ((p & required_perm) != fs::perms::none) { + perm_str[pos] = letter; + } + }; + + set_perm(0, fs::perms::owner_read, 'r'); + set_perm(1, fs::perms::owner_write, 'w'); + set_perm(2, fs::perms::owner_exec, 'x'); + set_perm(3, fs::perms::group_read, 'r'); + set_perm(4, fs::perms::group_write, 'w'); + set_perm(5, fs::perms::group_exec, 'x'); + set_perm(6, fs::perms::others_read, 'r'); + set_perm(7, fs::perms::others_write, 'w'); + set_perm(8, fs::perms::others_exec, 'x'); + + return perm_str; +} + +std::optional InterpretPermString(const std::string& s) +{ + if (s == "owner") { + return fs::perms::owner_read | fs::perms::owner_write; + } else if (s == "group") { + return fs::perms::owner_read | fs::perms::owner_write | + fs::perms::group_read; + } else if (s == "all") { + return fs::perms::owner_read | fs::perms::owner_write | + fs::perms::group_read | + fs::perms::others_read; + } else { + return std::nullopt; + } +} diff --git a/src/util/fs_helpers.h b/src/util/fs_helpers.h index 80a84da97649..88482d9e7396 100644 --- a/src/util/fs_helpers.h +++ b/src/util/fs_helpers.h @@ -12,6 +12,7 @@ #include #include #include +#include /** * Ensure file contents are fully committed to disk, using a platform-specific @@ -111,6 +112,19 @@ void ReleaseDirectoryLocks(); bool TryCreateDirectories(const fs::path& p); fs::path GetDefaultDataDir(); +/** Convert fs::perms to symbolic string of the form 'rwxrwxrwx' + * + * @param[in] p the perms to be converted + * @return Symbolic permissions string + */ +std::string PermsToSymbolicString(fs::perms p); +/** Interpret a custom permissions level string as fs::perms + * + * @param[in] s Permission level string + * @return Permissions as fs::perms + */ +std::optional InterpretPermString(const std::string& s); + #ifdef WIN32 fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true); #endif diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py index 891a23c29fca..375b02a93884 100755 --- a/test/functional/rpc_users.py +++ b/test/functional/rpc_users.py @@ -11,12 +11,15 @@ ) import http.client +import os +import platform import urllib.parse import subprocess from random import SystemRandom import string import configparser import sys +from typing import Optional def call_with_auth(node, user, password): url = urllib.parse.urlparse(node.url) @@ -83,6 +86,40 @@ def test_auth(self, node, user, password): self.log.info('Wrong...') assert_equal(401, call_with_auth(node, user+'wrong', password+'wrong').status) + def test_rpccookieperms(self): + p = {"owner": 0o600, "group": 0o640, "all": 0o644} + + if platform.system() == 'Windows': + self.log.info(f"Skip cookie file permissions checks as OS detected as: {platform.system()=}") + return + + self.log.info('Check cookie file permissions can be set using -rpccookieperms') + + cookie_file_path = self.nodes[1].chain_path / '.cookie' + PERM_BITS_UMASK = 0o777 + + def test_perm(perm: Optional[str]): + if not perm: + perm = 'owner' + self.restart_node(1) + else: + self.restart_node(1, extra_args=[f"-rpccookieperms={perm}"]) + + file_stat = os.stat(cookie_file_path) + actual_perms = file_stat.st_mode & PERM_BITS_UMASK + expected_perms = p[perm] + assert_equal(expected_perms, actual_perms) + + # Remove any leftover rpc{user|password} config options from previous tests + self.nodes[1].replace_in_config([("rpcuser", "#rpcuser"), ("rpcpassword", "#rpcpassword")]) + + self.log.info('Check default cookie permission') + test_perm(None) + + self.log.info('Check custom cookie permissions') + for perm in ["owner", "group", "all"]: + test_perm(perm) + def run_test(self): self.conf_setup() self.log.info('Check correctness of the rpcauth config option') @@ -114,6 +151,8 @@ def run_test(self): (self.nodes[0].chain_path / ".cookie.tmp").mkdir() self.nodes[0].assert_start_raises_init_error(expected_msg=init_error) + self.test_rpccookieperms() + if __name__ == '__main__': HTTPBasicsTest().main()