diff --git a/.cirrus.yml b/.cirrus.yml index 24d4e9f14c975..0b2a6d716cbdf 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -58,12 +58,12 @@ task: << : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV task: - name: '32-bit CentOS, dash, gui' + name: 'CentOS, dash, gui' << : *GLOBAL_TASK_TEMPLATE container: docker_arguments: - CI_IMAGE_NAME_TAG: "quay.io/centos/amd64:stream9" - FILE_ENV: "./ci/test/00_setup_env_i686_centos.sh" + CI_IMAGE_NAME_TAG: "quay.io/centos/centos:stream9" + FILE_ENV: "./ci/test/00_setup_env_native_centos.sh" env: << : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV PACKAGE_MANAGER_INSTALL: "yum install -y" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bc7c621af0ac..46c1c505e192f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ env: jobs: macos-native-arm64: name: ${{ matrix.job-name }} - # Use latest image, but hardcode version to avoid silent upgrades (and breaks). + # Use any image to support the xcode-select below, but hardcode version to avoid silent upgrades (and breaks). # See: https://github.com/actions/runner-images#available-images. runs-on: macos-14 @@ -49,6 +49,10 @@ jobs: - name: Clang version run: | + # Use the earliest Xcode supported by the version of macOS denoted in + # doc/release-notes-empty-template.md and providing at least the + # minimum clang version denoted in doc/dependencies.md. + # See: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes sudo xcode-select --switch /Applications/Xcode_15.0.app clang --version diff --git a/CMakeLists.txt b/CMakeLists.txt index 3611c9e280c40..90828c08389ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(CLIENT_VERSION_MINOR 99) set(CLIENT_VERSION_BUILD 0) set(CLIENT_VERSION_RC 0) set(CLIENT_VERSION_IS_RELEASE "false") -set(COPYRIGHT_YEAR "2024") +set(COPYRIGHT_YEAR "2025") # During the enabling of the CXX and CXXOBJ languages, we modify # CMake's compiler/linker invocation strings by appending the content diff --git a/COPYING b/COPYING index 7d1017ec41ab5..2e9706ebe74ba 100644 --- a/COPYING +++ b/COPYING @@ -1,8 +1,8 @@ The MIT License (MIT) -Copyright (c) 2009-2024 The Bitcoin Core developers -Copyright (c) 2009-2024 Bitcoin Developers -Copyright (c) 2014-2024 The Groestlcoin Core developers +Copyright (c) 2009-2025 The Bitcoin Core developers +Copyright (c) 2009-2025 Bitcoin Developers +Copyright (c) 2014-2025 The Groestlcoin Core developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ci/test/00_setup_env.sh b/ci/test/00_setup_env.sh index deccf9ffbc849..3a4cf6d1822d5 100755 --- a/ci/test/00_setup_env.sh +++ b/ci/test/00_setup_env.sh @@ -55,7 +55,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out} # The folder for previous release binaries. # This folder exists only on the ci guest, and on the ci host as a volume. export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases} -export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkg-config curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake} +export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake} export GOAL=${GOAL:-install} export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets} export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"} diff --git a/ci/test/00_setup_env_i686_centos.sh b/ci/test/00_setup_env_native_centos.sh similarity index 53% rename from ci/test/00_setup_env_i686_centos.sh rename to ci/test/00_setup_env_native_centos.sh index a149e7e44de2a..39bdb396b35f6 100644 --- a/ci/test/00_setup_env_i686_centos.sh +++ b/ci/test/00_setup_env_native_centos.sh @@ -6,12 +6,10 @@ export LC_ALL=C.UTF-8 -export HOST=i686-pc-linux-gnu -export CONTAINER_NAME=ci_i686_centos -export CI_IMAGE_NAME_TAG="quay.io/centos/amd64:stream9" +export CONTAINER_NAME=ci_native_centos +export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream9" export STREAM_GCC_V="12" -export CI_BASE_PACKAGES="gcc-toolset-${STREAM_GCC_V}-gcc-c++ glibc-devel.x86_64 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.x86_64 glibc-devel.i686 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison e2fsprogs cmake" +export CI_BASE_PACKAGES="gcc-toolset-${STREAM_GCC_V}-gcc-c++ glibc-devel gcc-toolset-${STREAM_GCC_V}-libstdc++-devel ccache make git python3 python3-pip which patch xz procps-ng dash rsync coreutils bison e2fsprogs cmake" export PIP_PACKAGES="pyzmq" export GOAL="install" export GROESTLCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON" -export CONFIG_SHELL="/bin/dash" diff --git a/ci/test/00_setup_env_native_msan.sh b/ci/test/00_setup_env_native_msan.sh index df7d3930dbcb3..c053394b9cf53 100644 --- a/ci/test/00_setup_env_native_msan.sh +++ b/ci/test/00_setup_env_native_msan.sh @@ -27,4 +27,3 @@ export GROESTLCOIN_CONFIG="\ -DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' \ " export USE_MEMORY_SANITIZER="true" -export RUN_FUNCTIONAL_TESTS="false" diff --git a/ci/test/01_base_install.sh b/ci/test/01_base_install.sh index e026b919e3eb4..a46f9ffabbef4 100755 --- a/ci/test/01_base_install.sh +++ b/ci/test/01_base_install.sh @@ -49,7 +49,7 @@ if [ -n "$PIP_PACKAGES" ]; then fi if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then - ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-19.1.0" /msan/llvm-project + ${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-19.1.6" /msan/llvm-project cmake -G Ninja -B /msan/clang_build/ \ -DLLVM_ENABLE_PROJECTS="clang" \ @@ -74,6 +74,7 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then -DLLVM_TARGETS_TO_BUILD=Native \ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ -DLIBCXXABI_USE_LLVM_UNWINDER=OFF \ + -DLIBCXX_ABI_DEFINES="_LIBCPP_ABI_BOUNDED_ITERATORS;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR;_LIBCPP_ABI_BOUNDED_UNIQUE_PTR" \ -DLIBCXX_HARDENING_MODE=debug \ -S /msan/llvm-project/runtimes diff --git a/cmake/script/GenerateHeaderFromJson.cmake b/cmake/script/GenerateHeaderFromJson.cmake index 4a3bddb323f81..384ac20d10efd 100644 --- a/cmake/script/GenerateHeaderFromJson.cmake +++ b/cmake/script/GenerateHeaderFromJson.cmake @@ -6,7 +6,7 @@ cmake_path(GET JSON_SOURCE_PATH STEM json_source_basename) file(READ ${JSON_SOURCE_PATH} hex_content HEX) string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}") -string(REGEX REPLACE "[^\n][^\n]" "0x\\0, " formatted_bytes "${formatted_bytes}") +string(REGEX REPLACE "[^\n][^\n]" "'\\\\x\\0'," formatted_bytes "${formatted_bytes}") set(header_content "#include diff --git a/cmake/script/GenerateHeaderFromRaw.cmake b/cmake/script/GenerateHeaderFromRaw.cmake index 638876ecea10c..d373d1c4f8702 100644 --- a/cmake/script/GenerateHeaderFromRaw.cmake +++ b/cmake/script/GenerateHeaderFromRaw.cmake @@ -6,7 +6,7 @@ cmake_path(GET RAW_SOURCE_PATH STEM raw_source_basename) file(READ ${RAW_SOURCE_PATH} hex_content HEX) string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}") -string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}, " formatted_bytes "${formatted_bytes}") +string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}," formatted_bytes "${formatted_bytes}") set(header_content "#include diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 72882fbce1a7d..346fe788deb86 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -5,8 +5,8 @@ Upstream-Contact: Satoshi Nakamoto Source: https://github.com/groestlcoin/groestlcoin Files: * -Copyright: 2009-2024, Bitcoin Core Developers -Copyright: 2014-2024, Groestlcoin Core Developers +Copyright: 2009-2025, Bitcoin Core Developers +Copyright: 2014-2025, Groestlcoin Core Developers License: Expat Comment: The Bitcoin Core and The Groestlcoin Core Developers encompasses all contributors to the project, listed in the release notes or the git log. diff --git a/contrib/tracing/log_raw_p2p_msgs.py b/contrib/tracing/log_raw_p2p_msgs.py index 10613bb8bf2ae..ccff7c9b480a2 100644 --- a/contrib/tracing/log_raw_p2p_msgs.py +++ b/contrib/tracing/log_raw_p2p_msgs.py @@ -41,7 +41,8 @@ program = """ #include -#define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) +// A min() macro. Prefixed with _TRACEPOINT_TEST to avoid collision with other MIN macros. +#define _TRACEPOINT_TEST_MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) // Maximum possible allocation size // from include/linux/percpu.h in the Linux kernel @@ -88,7 +89,7 @@ bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH); bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH); bpf_usdt_readarg(5, ctx, &msg->msg_size); - bpf_usdt_readarg_p(6, ctx, &msg->msg, MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); + bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); inbound_messages.perf_submit(ctx, msg, sizeof(*msg)); return 0; @@ -108,7 +109,7 @@ bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH); bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH); bpf_usdt_readarg(5, ctx, &msg->msg_size); - bpf_usdt_readarg_p(6, ctx, &msg->msg, MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); + bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); outbound_messages.perf_submit(ctx, msg, sizeof(*msg)); return 0; diff --git a/depends/Makefile b/depends/Makefile index 9d56be4d297b9..45e5b13841e94 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -141,7 +141,7 @@ include packages/packages.mk # 2. Before including packages/*.mk (excluding packages/packages.mk), since # they rely on the build_id variables # -build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR) 'NM='$(build_NM)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))') +build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR)' NM='$(build_NM)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))') $(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' NM='$(host_NM)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))') boost_packages_$(NO_BOOST) = $(boost_packages) diff --git a/depends/README.md b/depends/README.md index 0543411d04758..bc477f1525c7f 100644 --- a/depends/README.md +++ b/depends/README.md @@ -47,7 +47,7 @@ The paths are automatically configured and no other options are needed. Skip the following packages if you don't intend to use the GUI and will build with [`NO_QT=1`](#dependency-options): - apt install bison g++ pkg-config python3 xz-utils + apt install bison g++ pkgconf python3 xz-utils #### For macOS cross compilation diff --git a/depends/builders/freebsd.mk b/depends/builders/freebsd.mk index 465f58e04dc7f..18316f492ee95 100644 --- a/depends/builders/freebsd.mk +++ b/depends/builders/freebsd.mk @@ -1,5 +1,5 @@ build_freebsd_CC=clang build_freebsd_CXX=clang++ -build_freebsd_SHA256SUM = shasum -a 256 +build_freebsd_SHA256SUM = sha256sum build_freebsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o diff --git a/depends/packages/native_capnp.mk b/depends/packages/native_capnp.mk index d6e6b4cadbd62..e67b103716f49 100644 --- a/depends/packages/native_capnp.mk +++ b/depends/packages/native_capnp.mk @@ -1,9 +1,9 @@ package=native_capnp -$(package)_version=1.0.2 +$(package)_version=1.1.0 $(package)_download_path=https://capnproto.org/ $(package)_download_file=capnproto-c++-$($(package)_version).tar.gz $(package)_file_name=capnproto-cxx-$($(package)_version).tar.gz -$(package)_sha256_hash=9057dbc0223366b74bbeca33a05de164a229b0377927f1b7ef3828cdd8cb1d7e +$(package)_sha256_hash=07167580e563f5e821e3b2af1c238c16ec7181612650c5901330fa9a0da50939 define $(package)_set_vars $(package)_config_opts := -DBUILD_TESTING=OFF diff --git a/doc/build-freebsd.md b/doc/build-freebsd.md index 7fca78a532563..a027b4e982a3c 100644 --- a/doc/build-freebsd.md +++ b/doc/build-freebsd.md @@ -96,7 +96,7 @@ There is an included test suite that is useful for testing code changes when dev To run the test suite (recommended), you will need to have Python 3 installed: ```bash -pkg install python3 databases/py-sqlite3 +pkg install python3 databases/py-sqlite3 net/py-pyzmq ``` --- diff --git a/doc/build-netbsd.md b/doc/build-netbsd.md index f4c85a00430c8..14f1535659dc0 100644 --- a/doc/build-netbsd.md +++ b/doc/build-netbsd.md @@ -1,6 +1,6 @@ # NetBSD Build Guide -**Updated for NetBSD [10.0](https://netbsd.org/releases/formal-10/NetBSD-10.0.html)** +**Updated for NetBSD [10.1](https://netbsd.org/releases/formal-10/NetBSD-10.1.html)** This guide describes how to build groestlcoind, command-line utilities, and GUI on NetBSD. @@ -83,6 +83,13 @@ pkgin install qrencode Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI. +#### Notifications +###### ZeroMQ + +Groestlcoin Core can provide notifications via ZeroMQ. If the package is installed, support will be compiled in. +```bash +pkgin zeromq +``` #### Test Suite Dependencies @@ -90,10 +97,10 @@ There is an included test suite that is useful for testing code changes when dev To run the test suite (recommended), you will need to have Python 3 installed: ```bash -pkgin install python39 +pkgin install python310 py310-zmq ``` -### Building Groestlcoin Core +## Building Groestlcoin Core ### 1. Configuration diff --git a/doc/build-unix.md b/doc/build-unix.md index 42eba7b522f88..0be1c6c62edff 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -44,7 +44,7 @@ Finally, clang (often less resource hungry) can be used instead of gcc, which is Build requirements: - sudo apt-get install build-essential cmake pkg-config python3 + sudo apt-get install build-essential cmake pkgconf python3 Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies: diff --git a/doc/release-notes-28121.md b/doc/release-notes-28121.md new file mode 100644 index 0000000000000..911b7c562004d --- /dev/null +++ b/doc/release-notes-28121.md @@ -0,0 +1,2 @@ +The RPC `testmempoolaccept` response now includes a "reject-details" field in some cases, +similar to the complete error messages returned by `sendrawtransaction` (#28121) \ No newline at end of file diff --git a/src/arith_uint256.h b/src/arith_uint256.h index 38b74530343e1..60b371f6d328a 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -26,6 +26,7 @@ class base_uint protected: static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32."); static constexpr int WIDTH = BITS / 32; + /** Big integer represented with 32-bit digits, least-significant first. */ uint32_t pn[WIDTH]; public: diff --git a/src/banman.cpp b/src/banman.cpp index 2dbfc76df2dc9..2964a37de0173 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -30,7 +30,7 @@ void BanMan::LoadBanlist() { LOCK(m_banned_mutex); - if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated); + if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…")); const auto start{SteadyClock::now()}; if (m_ban_db.Read(m_banned)) { diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 3d1555fafe335..8e33cba58d1f2 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -99,7 +99,7 @@ std::string LicenseInfo() strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated + "\n" + "\n" + - _("This is experimental software.").translated + "\n" + + _("This is experimental software.") + "\n" + strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "").translated + "\n"; } diff --git a/src/crypto/chacha20.cpp b/src/crypto/chacha20.cpp index 4feed862cbcb1..b1bd3c549075f 100644 --- a/src/crypto/chacha20.cpp +++ b/src/crypto/chacha20.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022 The Bitcoin Core developers +// Copyright (c) 2017-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -25,14 +25,14 @@ void ChaCha20Aligned::SetKey(Span key) noexcept { assert(key.size() == KEYLEN); - input[0] = ReadLE32(UCharCast(key.data() + 0)); - input[1] = ReadLE32(UCharCast(key.data() + 4)); - input[2] = ReadLE32(UCharCast(key.data() + 8)); - input[3] = ReadLE32(UCharCast(key.data() + 12)); - input[4] = ReadLE32(UCharCast(key.data() + 16)); - input[5] = ReadLE32(UCharCast(key.data() + 20)); - input[6] = ReadLE32(UCharCast(key.data() + 24)); - input[7] = ReadLE32(UCharCast(key.data() + 28)); + input[0] = ReadLE32(key.data() + 0); + input[1] = ReadLE32(key.data() + 4); + input[2] = ReadLE32(key.data() + 8); + input[3] = ReadLE32(key.data() + 12); + input[4] = ReadLE32(key.data() + 16); + input[5] = ReadLE32(key.data() + 20); + input[6] = ReadLE32(key.data() + 24); + input[7] = ReadLE32(key.data() + 28); input[8] = 0; input[9] = 0; input[10] = 0; @@ -59,7 +59,7 @@ void ChaCha20Aligned::Seek(Nonce96 nonce, uint32_t block_counter) noexcept inline void ChaCha20Aligned::Keystream(Span output) noexcept { - unsigned char* c = UCharCast(output.data()); + std::byte* c = output.data(); size_t blocks = output.size() / BLOCKLEN; assert(blocks * BLOCKLEN == output.size()); @@ -161,8 +161,8 @@ inline void ChaCha20Aligned::Keystream(Span output) noexcept inline void ChaCha20Aligned::Crypt(Span in_bytes, Span out_bytes) noexcept { assert(in_bytes.size() == out_bytes.size()); - const unsigned char* m = UCharCast(in_bytes.data()); - unsigned char* c = UCharCast(out_bytes.data()); + const std::byte* m = in_bytes.data(); + std::byte* c = out_bytes.data(); size_t blocks = out_bytes.size() / BLOCKLEN; assert(blocks * BLOCKLEN == out_bytes.size()); diff --git a/src/crypto/chacha20poly1305.cpp b/src/crypto/chacha20poly1305.cpp index b969bb1a29903..282f32a5e4268 100644 --- a/src/crypto/chacha20poly1305.cpp +++ b/src/crypto/chacha20poly1305.cpp @@ -56,8 +56,8 @@ void ComputeTag(ChaCha20& chacha20, Span aad, Span +#include +#include #include #include -uint16_t static inline ReadLE16(const unsigned char* ptr) +template +concept ByteType = std::same_as || std::same_as; + +template +inline uint16_t ReadLE16(const B* ptr) { uint16_t x; memcpy(&x, ptr, 2); return le16toh_internal(x); } -uint32_t static inline ReadLE32(const unsigned char* ptr) +template +inline uint32_t ReadLE32(const B* ptr) { uint32_t x; memcpy(&x, ptr, 4); return le32toh_internal(x); } -uint64_t static inline ReadLE64(const unsigned char* ptr) +template +inline uint64_t ReadLE64(const B* ptr) { uint64_t x; memcpy(&x, ptr, 8); return le64toh_internal(x); } -void static inline WriteLE16(unsigned char* ptr, uint16_t x) +template +inline void WriteLE16(B* ptr, uint16_t x) { uint16_t v = htole16_internal(x); memcpy(ptr, &v, 2); } -void static inline WriteLE32(unsigned char* ptr, uint32_t x) +template +inline void WriteLE32(B* ptr, uint32_t x) { uint32_t v = htole32_internal(x); memcpy(ptr, &v, 4); } -void static inline WriteLE64(unsigned char* ptr, uint64_t x) +template +inline void WriteLE64(B* ptr, uint64_t x) { uint64_t v = htole64_internal(x); memcpy(ptr, &v, 8); } -uint16_t static inline ReadBE16(const unsigned char* ptr) +template +inline uint16_t ReadBE16(const B* ptr) { uint16_t x; memcpy(&x, ptr, 2); return be16toh_internal(x); } -uint32_t static inline ReadBE32(const unsigned char* ptr) +template +inline uint32_t ReadBE32(const B* ptr) { uint32_t x; memcpy(&x, ptr, 4); return be32toh_internal(x); } -uint64_t static inline ReadBE64(const unsigned char* ptr) +template +inline uint64_t ReadBE64(const B* ptr) { uint64_t x; memcpy(&x, ptr, 8); return be64toh_internal(x); } -void static inline WriteBE16(unsigned char* ptr, uint16_t x) +template +inline void WriteBE16(B* ptr, uint16_t x) { uint16_t v = htobe16_internal(x); memcpy(ptr, &v, 2); } -void static inline WriteBE32(unsigned char* ptr, uint32_t x) +template +inline void WriteBE32(B* ptr, uint32_t x) { uint32_t v = htobe32_internal(x); memcpy(ptr, &v, 4); } -void static inline WriteBE64(unsigned char* ptr, uint64_t x) +template +inline void WriteBE64(B* ptr, uint64_t x) { uint64_t v = htobe64_internal(x); memcpy(ptr, &v, 8); diff --git a/src/crypto/sha3.cpp b/src/crypto/sha3.cpp index 770500bfe2781..56aaa4615e73d 100644 --- a/src/crypto/sha3.cpp +++ b/src/crypto/sha3.cpp @@ -105,9 +105,9 @@ void KeccakF(uint64_t (&st)[25]) SHA3_256& SHA3_256::Write(Span data) { - if (m_bufsize && m_bufsize + data.size() >= sizeof(m_buffer)) { + if (m_bufsize && data.size() >= sizeof(m_buffer) - m_bufsize) { // Fill the buffer and process it. - std::copy(data.begin(), data.begin() + sizeof(m_buffer) - m_bufsize, m_buffer + m_bufsize); + std::copy(data.begin(), data.begin() + (sizeof(m_buffer) - m_bufsize), m_buffer + m_bufsize); data = data.subspan(sizeof(m_buffer) - m_bufsize); m_state[m_pos++] ^= ReadLE64(m_buffer); m_bufsize = 0; diff --git a/src/groestlcoin-chainstate.cpp b/src/groestlcoin-chainstate.cpp index bab09f13d9baf..51c482607aa8f 100644 --- a/src/groestlcoin-chainstate.cpp +++ b/src/groestlcoin-chainstate.cpp @@ -19,9 +19,9 @@ #include #include +#include #include #include -#include #include #include #include