Compare commits

...

36 Commits

Author SHA1 Message Date
Kittywhiskers Van Gogh
b9f358defc
Merge 86c88977ba into 3d5dc160d8 2024-12-15 18:31:19 +00:00
pasta
3d5dc160d8
Merge #6462: backport: merge bitcoin#23092, #23005, #24704, #24391, #25338, #25422, #25493, #26826, #26814, #26832, #27418, partial bitcoin#27254 (compat backports)
Some checks failed
Guix Build / build-image (push) Failing after 6m2s
Guix Build / build (aarch64-linux-gnu) (push) Has been skipped
Guix Build / build (arm-linux-gnueabihf) (push) Has been skipped
Guix Build / build (arm64-apple-darwin) (push) Has been skipped
Guix Build / build (powerpc64-linux-gnu) (push) Has been skipped
Guix Build / build (riscv64-linux-gnu) (push) Has been skipped
Guix Build / build (x86_64-apple-darwin) (push) Has been skipped
Guix Build / build (x86_64-linux-gnu) (push) Has been skipped
Guix Build / build (x86_64-w64-mingw32) (push) Has been skipped
Check Merge Fast-Forward Only / check_merge (push) Successful in 1m49s
Label Merge Conflicts / main (push) Failing after 40s
CI / Build Image (push) Failing after 15m29s
CI / Build Dependencies (arm-linux, arm-linux-gnueabihf) (push) Has been cancelled
CI / Build Dependencies (linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (arm-linux, arm-linux, arm-linux-gnueabihf) (push) Has been cancelled
CI / Build (linux64, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_cxx20, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_fuzz, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_nowallet, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_sqlite, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_tsan, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
CI / Build (linux64_ubsan, linux64, x86_64-pc-linux-gnu) (push) Has been cancelled
2ab561d281 partial bitcoin#27254: Extract util/fs from util/system (Kittywhiskers Van Gogh)
280988bee3 merge bitcoin#27418: Remove windows workaround in authproxy (Kittywhiskers Van Gogh)
a497df0339 merge bitcoin#26832: move (win) S_* defines into bdb (Kittywhiskers Van Gogh)
db676a7e5f merge bitcoin#26814: remove windows-only compat.h usage in random (Kittywhiskers Van Gogh)
94e6637c33 merge bitcoin#26826: remove windows-only compat.h usage in randomenv (Kittywhiskers Van Gogh)
bbb0cceb7a merge bitcoin#25493: document code in compat.h (Kittywhiskers Van Gogh)
3f143096c8 merge bitcoin#25422: globally define NOMINMAX when building with mingw-w64 (Kittywhiskers Van Gogh)
000495df8e merge bitcoin#25338: Avoid incompatibility with CMake AUTOUIC feature (Kittywhiskers Van Gogh)
714ea55dbe build: migrate stacktrace-related flags to `DEBUG_`{`C`,`CXX`}`FLAGS` (Kittywhiskers Van Gogh)
11323c3851 merge bitcoin#24391: stop overriding user autoconf flags (Kittywhiskers Van Gogh)
548121d366 merge bitcoin#24704: remove strnlen back-compat code (Kittywhiskers Van Gogh)
b65038ec94 merge bitcoin#23005: Delay wallet client construction (Kittywhiskers Van Gogh)
f3b065cd9c merge bitcoin#23092: Remove Windows workaround in authproxy (WinError 10053) (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * This PR originally included [bitcoin#27378](https://github.com/bitcoin/bitcoin/pull/27378) but including it caused multiple tests to fail ([build](https://gitlab.com/dashpay/dash/-/jobs/8577987174#L2224)), even after adjusting `timeout`. It has been omitted instead.

    <details>

    <summary>Test failures:</summary>

    ```
    feature_abortnode.py                               |   Failed  | 201 s
    feature_dip3_v19.py                                |   Failed  | 237 s
    feature_llmq_rotation.py                           |   Failed  | 54 s
    p2p_invalid_messages.py                            |   Failed  | 5 s
    rpc_bind.py --nonloopback                          |   Failed  | 63 s
    wallet_multiwallet.py --descriptors                |   Failed  | 79 s
    wallet_multiwallet.py --legacy-wallet              |   Failed  | 89 s

    ALL                                                |   Failed  | 8540 s (accumulated)
    ```

    </details>

    <details>

    <summary>feature_abortnode.py failure:</summary>

    ```
    dash@107cfae2b2b5:/src/dash$ ./test/functional/feature_abortnode.py
    2024-12-09T18:31:01.776000Z TestFramework (INFO): PRNG seed is: 6843309100291447752
    2024-12-09T18:31:01.776000Z TestFramework (INFO): Initializing test directory /tmp/dash_func_test_fcijb99n
    2024-12-09T18:31:02.802000Z TestFramework (INFO): Waiting for crash
    2024-12-09T18:34:23.026000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        def is_node_stopped(self):
            """Checks whether the node has stopped.

            Returns True if the node has stopped. False otherwise.
            This method is responsible for freeing resources (self.process)."""
            if not self.running:
                return True
            return_code = self.process.poll()
            if return_code is None:
                return False

            # process has stopped. Assert that it didn't return an error code.
            assert return_code == 0, self._node_msg(
                "Node returned non-zero exit code (%d) when stopping" % return_code)
            self.running = False
            self.process = None
            self.rpc_connected = False
            self.rpc = None
            self.log.debug("Node stopped")
            return True
    '''
    2024-12-09T18:34:23.027000Z TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "/src/dash/test/functional/test_framework/test_framework.py", line 161, in main
        self.run_test()
      File "/src/dash/./test/functional/feature_abortnode.py", line 44, in run_test
        self.nodes[0].wait_until_stopped(timeout=200)
      File "/src/dash/test/functional/test_framework/test_node.py", line 414, in wait_until_stopped
        wait_until_helper(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
      File "/src/dash/test/functional/test_framework/util.py", line 287, in wait_until_helper
        raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
    AssertionError: Predicate ''''
        def is_node_stopped(self):
            """Checks whether the node has stopped.

            Returns True if the node has stopped. False otherwise.
            This method is responsible for freeing resources (self.process)."""
            if not self.running:
                return True
            return_code = self.process.poll()
            if return_code is None:
                return False

            # process has stopped. Assert that it didn't return an error code.
            assert return_code == 0, self._node_msg(
                "Node returned non-zero exit code (%d) when stopping" % return_code)
            self.running = False
            self.process = None
            self.rpc_connected = False
            self.rpc = None
            self.log.debug("Node stopped")
            return True
    ''' not true after 200.0 seconds
    2024-12-09T18:34:23.530000Z TestFramework (INFO): Stopping nodes
    2024-12-09T18:34:23.530000Z TestFramework (ERROR): Unexpected exception caught during shutdown
    Traceback (most recent call last):
      File "/src/dash/test/functional/test_framework/test_framework.py", line 341, in shutdown
        self.stop_nodes()
      File "/src/dash/test/functional/test_framework/test_framework.py", line 673, in stop_nodes
        node.stop_node(expected_stderr=expected_stderr, wait=wait, wait_until_stopped=False)
      File "/src/dash/test/functional/test_framework/test_node.py", line 368, in stop_node
        self.stop(wait=wait)
      File "/src/dash/test/functional/test_framework/coverage.py", line 49, in __call__
        return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
      File "/src/dash/test/functional/test_framework/authproxy.py", line 124, in __call__
        response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
      File "/src/dash/test/functional/test_framework/authproxy.py", line 103, in _request
        return self._get_response()
      File "/src/dash/test/functional/test_framework/authproxy.py", line 162, in _get_response
        raise JSONRPCException(
    test_framework.authproxy.JSONRPCException: non-JSON HTTP response with '503 Service Unavailable' from server (-342)
    2024-12-09T18:34:23.531000Z TestFramework (WARNING): Not cleaning up dir /tmp/dash_func_test_fcijb99n
    2024-12-09T18:34:23.531000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/dash_func_test_fcijb99n/test_framework.log
    2024-12-09T18:34:23.531000Z TestFramework (ERROR):
    2024-12-09T18:34:23.531000Z TestFramework (ERROR): Hint: Call /src/dash/test/functional/combine_logs.py '/tmp/dash_func_test_fcijb99n' to consolidate all logs
    2024-12-09T18:34:23.531000Z TestFramework (ERROR):
    2024-12-09T18:34:23.531000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
    2024-12-09T18:34:23.531000Z TestFramework (ERROR): https://github.com/dashpay/dash/issues
    2024-12-09T18:34:23.531000Z TestFramework (ERROR):
    [node 1] Cleaning up leftover process
    [node 0] Cleaning up leftover process
    ```

    </details>

  * [bitcoin#27254](https://github.com/bitcoin/bitcoin/pull/27254) has been partially backported to include a missing header to allow it to build.

    <details>

    <summary>Compile error:</summary>

    ```
    In file included from ./util/system.h:19,
                   from util/system.cpp:7:
    ./compat/assumptions.h:49:22: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
       49 | static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "size_t assumed to be 32-bit or 64-bit");
          |                      ^~~~~~
          |                      std::size_t
    In file included from /usr/include/c++/11/limits:42,
                   from ./compat/assumptions.h:11,
                   from ./util/system.h:19,
                   from util/system.cpp:7:
    /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:280:33: note: 'std::size_t' declared here
      280 |   typedef __SIZE_TYPE__         size_t;
          |                                 ^~~~~~
    ```

    </details>

  * ~~GitLab job failures as of 2339ae6459cad77d94795c0e92ba3f3fe31c485a, for `linux64-build` ([source](https://gitlab.com/dashpay/dash/-/jobs/8590291130#L4621)), `linux64_cxx20-build` ([source](https://gitlab.com/dashpay/dash/-/jobs/8590291134#L3497)) and `linux64_sqlite-build` ([source](https://gitlab.com/dashpay/dash/-/jobs/8590291137#L3489)) are not related to failures in compilation or unit tests but are to do with reaching the artifact limit.~~ Resolved with [dash#6487](https://github.com/dashpay/dash/pull/6487), thanks Udjin!

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 2ab561d281
  PastaPastaPasta:
    utACK 2ab561d281

Tree-SHA512: 6d05305f17fd607ed93b4a2e00de195a96bde1a34bedf04f6dd84892dc71028ae71590fa5063026ec7ff728d6e411af410c363b4a88947ce6e5999d4431bb29b
2024-12-15 12:30:54 -06:00
pasta
032fc21198
Merge #6479: feat: enable coverage linter for functional tests
2e509b96c4 fix: add a workaround for RPC getmerkleblocks, debug, coinjoinsalt, voteraw (Konstantin Akimov)
f0decc8790 feat: add unit test for ClearDiscouraged (Konstantin Akimov)
865b24ea00 feat: hide cleardiscouraged RPC so far as it no intent to use by regular users (Konstantin Akimov)
1f5fa7e7cf feat: enable linter coverage for functional tests (Konstantin Akimov)
59ddac5656 feat: hide deprecated RPC from help and add TODOes to remove them (Konstantin Akimov)
05732aceaf feat: implement functional tests for RPC getblockheaders (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  https://github.com/dashpay/dash-issues/issues/63

  ## What was done?
  Add functional tests for `getblockheaders`
  Hide RPC `cleardiscouraged` (as it is used only for functional tests) and RPC `getpoolinfo` (deprecated long time ago)
  Add a workaround to ignore these RPCs `getmerkleblocks`, `voteraw`, `debug`, `coinjoinsalt` at the moment
  Enables linter for coverage

  ## How Has This Been Tested?
  Run locally with `test/functional/test_runner.py -j20 --previous-releases --coverage --extended`
  Enabled in CI

  ## Breaking Changes
  N/A if hidding `cleardiscouraged` is not a breaking change.

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  UdjinM6:
    LGTM, utACK 2e509b96c4
  PastaPastaPasta:
    utACK 2e509b96c4

Tree-SHA512: bb31465d9a71ef824533d9310393d89293c87c7407ec3e37697f6d36dc6c010381a6e0408f9598354e610d51ef662485d8a653cc0e198842e2198ac1c30c90f1
2024-12-15 12:12:40 -06:00
pasta
05ca6cffff
Merge #6489: ci: allow overriding MAKEJOBS
feb6a1ad3f ci: allow overriding MAKEJOBS (UdjinM6)

Pull request description:

  ## Issue being fixed or feature implemented
  That's how these variable are ment to behave
  >echo "Fallback to default values in env (if not yet set)"

  https://github.com/dashpay/dash/blame/develop/ci/test/00_setup_env.sh#L26

  That's also how it's done in bitcoin https://github.com/bitcoin/bitcoin/blob/master/ci/test/00_setup_env.sh#L38.

  But we broke it in c52992aaa4 and I'm not sure why 🤷‍♂️

  ## What was done?

  ## How Has This Been Tested?

  ## Breaking Changes

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK feb6a1ad3f
  kwvg:
    utACK feb6a1ad3f

Tree-SHA512: 617e761cf5c52d8e4329bf8aa1680c72a7816ae3248ed415d2c3232e5aa0941f18e21f0d6d363848238f53730097aa22f51a6e1cd62bd0b31d3da853f9f79e28
2024-12-15 11:57:04 -06:00
Kittywhiskers Van Gogh
2ab561d281
partial bitcoin#27254: Extract util/fs from util/system
includes:
- b202b3dd6393b415fa68e18dc49c9431dc6b58b2
2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
280988bee3
merge bitcoin#27418: Remove windows workaround in authproxy 2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
a497df0339
merge bitcoin#26832: move (win) S_* defines into bdb 2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
db676a7e5f
merge bitcoin#26814: remove windows-only compat.h usage in random 2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
94e6637c33
merge bitcoin#26826: remove windows-only compat.h usage in randomenv 2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
bbb0cceb7a
merge bitcoin#25493: document code in compat.h 2024-12-15 09:08:55 +00:00
Kittywhiskers Van Gogh
3f143096c8
merge bitcoin#25422: globally define NOMINMAX when building with mingw-w64 2024-12-15 09:08:22 +00:00
Kittywhiskers Van Gogh
000495df8e
merge bitcoin#25338: Avoid incompatibility with CMake AUTOUIC feature 2024-12-15 09:08:22 +00:00
Kittywhiskers Van Gogh
714ea55dbe
build: migrate stacktrace-related flags to DEBUG_{C,CXX}FLAGS
`DEBUG_CFLAGS` doesn't exist so we need to create it
2024-12-15 09:08:22 +00:00
Kittywhiskers Van Gogh
11323c3851
merge bitcoin#24391: stop overriding user autoconf flags 2024-12-15 09:08:22 +00:00
Kittywhiskers Van Gogh
548121d366
merge bitcoin#24704: remove strnlen back-compat code 2024-12-15 09:08:22 +00:00
Kittywhiskers Van Gogh
b65038ec94
merge bitcoin#23005: Delay wallet client construction 2024-12-15 09:08:21 +00:00
Kittywhiskers Van Gogh
f3b065cd9c
merge bitcoin#23092: Remove Windows workaround in authproxy (WinError 10053) 2024-12-15 09:08:21 +00:00
UdjinM6
feb6a1ad3f
ci: allow overriding MAKEJOBS 2024-12-15 00:16:21 +03:00
Konstantin Akimov
2e509b96c4
fix: add a workaround for RPC getmerkleblocks, debug, coinjoinsalt, voteraw
We indeed doesn't have functional tests for them yet, but this linter will help to avoid
adding new RPCs without tests
2024-12-13 21:19:11 +07:00
Konstantin Akimov
f0decc8790
feat: add unit test for ClearDiscouraged 2024-12-13 21:19:11 +07:00
Konstantin Akimov
865b24ea00
feat: hide cleardiscouraged RPC so far as it no intent to use by regular users 2024-12-13 21:19:11 +07:00
Konstantin Akimov
1f5fa7e7cf
feat: enable linter coverage for functional tests 2024-12-13 21:19:11 +07:00
Konstantin Akimov
59ddac5656
feat: hide deprecated RPC from help and add TODOes to remove them 2024-12-13 21:19:11 +07:00
Konstantin Akimov
05732aceaf
feat: implement functional tests for RPC getblockheaders 2024-12-13 21:19:11 +07:00
Kittywhiskers Van Gogh
86c88977ba
merge bitcoin#29263: c++20 endian/byteswap/clz modernization 2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
a34937df51
merge bitcoin#29275: Fix prevector iterator concept issues 2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
d00f8a1316
merge bitcoin#28127: Remove C-style const-violating cast, Use reinterpret_cast 2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
3910a7547f
partial bitcoin#27978: Drop unsafe AsBytePtr function
excludes
- some changes to `src/wallet/bdb.cpp`
2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
67b0621edf
partial bitcoin#27790: Add PrefixCursor
includes:
- 84b2f353 (excludes `src/wallet/test/util.cpp`)
2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
d85003a7af
merge bitcoin#26825: remove already tested headers from AC_CHECK_HEADERS 2024-11-02 13:09:55 +00:00
Kittywhiskers Van Gogh
a1becc2ef3
merge bitcoin#26489: Split overly large util_tests.cpp file 2024-11-02 13:09:54 +00:00
Kittywhiskers Van Gogh
d2a2713ceb
merge bitcoin#26159: Remove stdlib.h from header checks 2024-11-01 21:04:56 +00:00
Kittywhiskers Van Gogh
b112911d6c
merge bitcoin#26150: remove stdio.h from header checks 2024-11-01 21:04:55 +00:00
Kittywhiskers Van Gogh
8283396d4c
merge bitcoin#26135: remove strings.h from header checks 2024-11-01 21:04:55 +00:00
Kittywhiskers Van Gogh
9d8fa38965
partial bitcoin#24831: add include-what-you-use
includes:
- c79ad935f0412bac3e19a6b925efdb390eb00bd9
2024-11-01 21:04:54 +00:00
Kittywhiskers Van Gogh
1a630ba785
merge bitcoin#24989: rename BytePtr to AsBytePtr 2024-11-01 21:04:54 +00:00
120 changed files with 1519 additions and 1676 deletions

View File

@ -116,8 +116,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
BITCOIN_QT_CHECK([
TEMP_CPPFLAGS=$CPPFLAGS
TEMP_CXXFLAGS=$CXXFLAGS
CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
CXXFLAGS="$PIC_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
_BITCOIN_QT_IS_STATIC
if test "x$bitcoin_cv_static_qt" = xyes; then
_BITCOIN_QT_CHECK_STATIC_LIBS
@ -177,8 +177,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
AC_MSG_CHECKING(whether -fPIE can be used with this Qt config)
TEMP_CPPFLAGS=$CPPFLAGS
TEMP_CXXFLAGS=$CXXFLAGS
CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
CXXFLAGS="$PIE_FLAGS $CXXFLAGS"
CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
CXXFLAGS="$PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <QtCore/qconfig.h>
#ifndef QT_VERSION
@ -200,7 +200,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
BITCOIN_QT_CHECK([
AC_MSG_CHECKING(whether -fPIC is needed with this Qt config)
TEMP_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <QtCore/qconfig.h>
#ifndef QT_VERSION

View File

@ -25,8 +25,7 @@ export JOB_NUMBER=${JOB_NUMBER:-1}
echo "Fallback to default values in env (if not yet set)"
# The number of parallel jobs to pass down to make and test_runner.py
MAKEJOBS="-j$(nproc)"
export MAKEJOBS
export MAKEJOBS=${MAKEJOBS:--j$(nproc)}
# A folder for the ci system to put temporary files (ccache, datadirs for tests, ...)
# This folder only exists on the ci host.
export BASE_SCRATCH_DIR=${BASE_SCRATCH_DIR:-$BASE_ROOT_DIR/ci/scratch}

View File

@ -9,8 +9,7 @@ export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_qt5
export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev"
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
# TODO: we have few rpcs that aren't covered by any test, re-enable the line below once it's fixed
# export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_pruning,feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_pruning,feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
export RUN_UNIT_TESTS_SEQUENTIAL="true"
export RUN_UNIT_TESTS="false"
export GOAL="install"

View File

@ -372,7 +372,9 @@ case $host in
esac
if test "x$enable_debug" = xyes; then
dnl Clear default -g -O2 flags
dnl If debugging is enabled, and the user hasn't overriden CXXFLAGS, clear
dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up
dnl with "-O0 -g3 -g -O2".
if test "x$CXXFLAGS_overridden" = xno; then
CXXFLAGS=""
fi
@ -397,11 +399,11 @@ else
# Stacktraces will be suboptimal due to optimization, but better than nothing. Also, -fno-omit-frame-pointer
# mitigates this a little bit
if test "x$GCC" = xyes; then
CFLAGS="$CFLAGS -g1 -fno-omit-frame-pointer"
DEBUG_CFLAGS="$DEBUG_CFLAGS -g1 -fno-omit-frame-pointer"
fi
if test "x$GXX" = xyes; then
CXXFLAGS="$CXXFLAGS -g1 -fno-omit-frame-pointer"
DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g1 -fno-omit-frame-pointer"
fi
fi
@ -429,7 +431,7 @@ if test x$LINK_WRAP_SUPPORTED = "xyes"; then
fi
# Needed for MinGW targets when debug symbols are enabled as compiled objects get very large
AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [CXXFLAGS="$CXXFLAGS -Wa,-mbig-obj"],,,)
AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Wa,-mbig-obj"],,,)
if test x$use_sanitizers != x; then
dnl First check if the compiler accepts flags. If an incompatible pair like
@ -532,7 +534,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
fi
dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CXXFLAGS="$CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CORE_CXXFLAGS="$CORE_CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]])
enable_arm_crc=no
enable_arm_shani=no
@ -683,7 +685,7 @@ CXXFLAGS="$TEMP_CXXFLAGS"
fi
CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS"
CORE_CPPFLAGS="$CORE_CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS"
AC_ARG_WITH([utils],
[AS_HELP_STRING([--with-utils],
@ -755,7 +757,10 @@ case $host in
AC_MSG_ERROR("windres not found")
fi
CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN"
CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN"
dnl Prevent the definition of min/max macros.
dnl We always want to use the standard library.
CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX"
dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override
@ -766,14 +771,14 @@ case $host in
postdeps_CXX=
dnl We require Windows 7 (NT 6.1) or later
AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[LDFLAGS="$LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[CORE_LDFLAGS="$CORE_LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]])
;;
*darwin*)
TARGET_OS=darwin
if test x$cross_compiling != xyes; then
BUILD_OS=darwin
AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]])
AC_CHECK_PROG([BREW],brew, brew)
if test x$BREW = xbrew; then
@ -800,8 +805,8 @@ case $host in
gmp_prefix=$($BREW --prefix gmp 2>/dev/null)
if test x$gmp_prefix != x; then
CPPFLAGS="$CPPFLAGS -I$gmp_prefix/include"
LDFLAGS="$LDFLAGS -L$gmp_prefix/lib"
CORE_CPPFLAGS="$CORE_CPPFLAGS -I$gmp_prefix/include"
CORE_LDFLAGS="$CORE_LDFLAGS -L$gmp_prefix/lib"
fi
case $host in
@ -813,20 +818,20 @@ case $host in
if test "x$use_upnp" != xno && $BREW list --versions miniupnpc >/dev/null; then
miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null)
if test "x$suppress_external_warnings" != xno; then
CPPFLAGS="$CPPFLAGS -isystem $miniupnpc_prefix/include"
CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $miniupnpc_prefix/include"
else
CPPFLAGS="$CPPFLAGS -I$miniupnpc_prefix/include"
CORE_CPPFLAGS="$CORE_CPPFLAGS -I$miniupnpc_prefix/include"
fi
LDFLAGS="$LDFLAGS -L$miniupnpc_prefix/lib"
CORE_LDFLAGS="$CORE_LDFLAGS -L$miniupnpc_prefix/lib"
fi
if test "x$use_natpmp" != xno && $BREW list --versions libnatpmp >/dev/null; then
libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null)
if test "x$suppress_external_warnings" != xno; then
CPPFLAGS="$CPPFLAGS -isystem $libnatpmp_prefix/include"
CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $libnatpmp_prefix/include"
else
CPPFLAGS="$CPPFLAGS -I$libnatpmp_prefix/include"
CORE_CPPFLAGS="$CORE_CPPFLAGS -I$libnatpmp_prefix/include"
fi
LDFLAGS="$LDFLAGS -L$libnatpmp_prefix/lib"
CORE_LDFLAGS="$CORE_LDFLAGS -L$libnatpmp_prefix/lib"
fi
;;
esac
@ -849,7 +854,7 @@ case $host in
esac
fi
CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
CORE_CPPFLAGS="$CORE_CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
OBJCXXFLAGS="$CXXFLAGS"
;;
*android*)
@ -912,11 +917,17 @@ if test x$use_lcov = xyes; then
AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh")
LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER"
AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"],
AX_CHECK_LINK_FLAG([[--coverage]], [CORE_LDFLAGS="$CORE_LDFLAGS --coverage"],
[AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
AX_CHECK_COMPILE_FLAG([--coverage],[CORE_CXXFLAGS="$CORE_CXXFLAGS --coverage"],
[AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
CXXFLAGS="$CXXFLAGS -Og"
dnl If coverage is enabled, and the user hasn't overriden CXXFLAGS, clear
dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up
dnl with "--coverage -Og -O0 -g -O2".
if test "$CXXFLAGS_overridden" = "no"; then
CXXFLAGS=""
fi
CORE_CXXFLAGS="$CORE_CXXFLAGS -Og -O0"
fi
if test x$use_lcov_branch != xno; then
@ -942,13 +953,13 @@ AC_FUNC_STRERROR_R
if test x$ac_cv_sys_file_offset_bits != x &&
test x$ac_cv_sys_file_offset_bits != xno &&
test x$ac_cv_sys_file_offset_bits != xunknown; then
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
CORE_CPPFLAGS="$CORE_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
fi
if test x$ac_cv_sys_large_files != x &&
test x$ac_cv_sys_large_files != xno &&
test x$ac_cv_sys_large_files != xunknown; then
CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
CORE_CPPFLAGS="$CORE_CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
fi
if test "x$enable_gprof" = xyes; then
@ -1037,18 +1048,17 @@ dnl These flags are specific to ld64, and may cause issues with other linkers.
dnl For example: GNU ld will interpret -dead_strip as -de and then try and use
dnl "ad_strip" as the symbol for the entry point.
if test x$TARGET_OS = xdarwin; then
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,-fixup_chains]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [[$LDFLAG_WERROR]])
fi
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])
AC_CHECK_HEADERS([sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])
AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],,
[#include <sys/types.h>
#include <ifaddrs.h>]
)
AC_CHECK_DECLS([strnlen])
dnl These are used for daemonization in dashd
AC_CHECK_DECLS([fork])
@ -1058,18 +1068,6 @@ AC_CHECK_DECLS([pipe2])
AC_CHECK_FUNCS([timingsafe_bcmp])
AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,,
[#if HAVE_ENDIAN_H
#include <endian.h>
#elif HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif])
AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,,
[#if HAVE_BYTESWAP_H
#include <byteswap.h>
#endif])
dnl Check for mallopt(M_ARENA_MAX) (to set glibc arenas)
AC_MSG_CHECKING(for mallopt M_ARENA_MAX)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
@ -1361,7 +1359,7 @@ if test "x$enable_fuzz" = "xyes"; then
[[-fsanitize=$use_sanitizers]],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])
CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"],
CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"],
[],
[AC_LANG_PROGRAM([[
#include <cstdint>
@ -1385,7 +1383,7 @@ else
QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
fi
CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"
CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"
fi
if test x$enable_wallet != xno; then
@ -1518,7 +1516,7 @@ fi
dnl Check for reduced exports
if test x$use_reduce_exports = xyes; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"],
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CORE_CXXFLAGS="$CORE_CXXFLAGS -fvisibility=hidden"],
[AC_MSG_ERROR([Cannot set hidden symbol visibility. Use --disable-reduce-exports.])],[[$CXXFLAG_WERROR]])
AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]],[RELDFLAGS="-Wl,--exclude-libs,ALL"],,[[$LDFLAG_WERROR]])
AX_CHECK_LINK_FLAG([-Wl,-no_exported_symbols], [LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -Wl,-no_exported_symbols"], [], [$LDFLAG_WERROR])
@ -1870,10 +1868,14 @@ AC_SUBST(BITCOIN_MP_NODE_NAME)
AC_SUBST(BITCOIN_MP_GUI_NAME)
AC_SUBST(RELDFLAGS)
AC_SUBST(CORE_LDFLAGS)
AC_SUBST(CORE_CPPFLAGS)
AC_SUBST(CORE_CXXFLAGS)
AC_SUBST(DEBUG_CFLAGS)
AC_SUBST(DEBUG_CPPFLAGS)
AC_SUBST(DEBUG_CXXFLAGS)
AC_SUBST(WARN_CXXFLAGS)
AC_SUBST(NOWARN_CXXFLAGS)
AC_SUBST(DEBUG_CXXFLAGS)
AC_SUBST(ERROR_CXXFLAGS)
AC_SUBST(GPROF_CXXFLAGS)
AC_SUBST(GPROF_LDFLAGS)
@ -1995,10 +1997,10 @@ echo " target os = $host_os"
echo " build os = $build_os"
echo
echo " CC = $CC"
echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS"
echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
echo " CFLAGS = $DEBUG_CFLAGS $PTHREAD_CFLAGS $CFLAGS"
echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS"
echo " CXX = $CXX"
echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CORE_CXXFLAGS $CXXFLAGS"
echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $CORE_LDFLAGS $LDFLAGS"
echo " ARFLAGS = $ARFLAGS"
echo

View File

@ -9,9 +9,10 @@ print-%: FORCE
DIST_SUBDIRS = secp256k1
AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS)
AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) $(CORE_LDFLAGS)
AM_CFLAGS = $(DEBUG_CFLAGS)
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) $(CORE_CXXFLAGS)
AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS)
AM_LIBTOOLFLAGS = --preserve-dup-deps
PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
EXTRA_LIBRARIES =
@ -162,9 +163,9 @@ BITCOIN_CORE_H = \
coinjoin/util.h \
coins.h \
common/bloom.h \
compat.h \
compat/assumptions.h \
compat/byteswap.h \
compat/compat.h \
compat/cpuid.h \
compat/endian.h \
compressor.h \
@ -279,7 +280,7 @@ BITCOIN_CORE_H = \
node/psbt.h \
node/transaction.h \
node/txreconciliation.h \
node/ui_interface.h \
node/interface_ui.h \
node/utxo_snapshot.h \
noui.h \
outputtype.h \
@ -512,7 +513,7 @@ libbitcoin_server_a_SOURCES = \
node/psbt.cpp \
node/transaction.cpp \
node/txreconciliation.cpp \
node/ui_interface.cpp \
node/interface_ui.cpp \
noui.cpp \
policy/fees.cpp \
policy/packages.cpp \
@ -792,7 +793,6 @@ libbitcoin_util_a_SOURCES = \
support/lockedpool.cpp \
chainparamsbase.cpp \
clientversion.cpp \
compat/strnlen.cpp \
fs.cpp \
interfaces/echo.cpp \
interfaces/handler.cpp \

View File

@ -73,6 +73,7 @@ endif
# test_dash binary #
BITCOIN_TESTS =\
test/argsman_tests.cpp \
test/arith_uint256_tests.cpp \
test/scriptnum10.h \
test/addrman_tests.cpp \

View File

@ -6,7 +6,7 @@
#include <banman.h>
#include <netaddress.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <sync.h>
#include <util/system.h>
#include <util/time.h>

View File

@ -17,12 +17,12 @@ static void EllSwiftCreate(benchmark::Bench& bench)
uint256 entropy = GetRandHash();
bench.batch(1).unit("pubkey").run([&] {
auto ret = key.EllSwiftCreate(AsBytes(Span{entropy}));
auto ret = key.EllSwiftCreate(MakeByteSpan(entropy));
/* Use the first 32 bytes of the ellswift encoded public key as next private key. */
key.Set(UCharCast(ret.data()), UCharCast(ret.data()) + 32, true);
assert(key.IsValid());
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
std::copy(ret.begin() + 32, ret.begin() + 64, BytePtr(entropy.data()));
std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
});
ECC_Stop();

View File

@ -10,7 +10,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <compat.h>
#include <compat/compat.h>
#include <compat/stdin.h>
#include <policy/feerate.h>
#include <rpc/client.h>

View File

@ -9,7 +9,7 @@
#include <chainparams.h>
#include <clientversion.h>
#include <coins.h>
#include <compat.h>
#include <compat/compat.h>
#include <consensus/consensus.h>
#include <core_io.h>
#include <key_io.h>
@ -26,10 +26,10 @@
#include <util/system.h>
#include <util/translation.h>
#include <cstdio>
#include <functional>
#include <memory>
#include <optional>
#include <stdio.h>
#include <stacktraces.h>

View File

@ -8,7 +8,7 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <compat.h>
#include <compat/compat.h>
#include <logging.h>
#include <util/strencodings.h>
#include <util/system.h>

View File

@ -10,12 +10,12 @@
#include <chainparams.h>
#include <clientversion.h>
#include <compat.h>
#include <compat/compat.h>
#include <init.h>
#include <interfaces/chain.h>
#include <interfaces/init.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <noui.h>
#include <shutdown.h>
#include <util/check.h>
@ -27,8 +27,8 @@
#include <stacktraces.h>
#include <util/url.h>
#include <cstdio>
#include <functional>
#include <stdio.h>
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
UrlDecodeFn* const URL_DECODE = urlDecode;

View File

@ -8,6 +8,7 @@
#ifndef BITCOIN_COMPAT_ASSUMPTIONS_H
#define BITCOIN_COMPAT_ASSUMPTIONS_H
#include <cstddef>
#include <limits>
// Assumption: We assume that the macro NDEBUG is not defined.

View File

@ -5,44 +5,66 @@
#ifndef BITCOIN_COMPAT_BYTESWAP_H
#define BITCOIN_COMPAT_BYTESWAP_H
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#include <cstdint>
#ifdef _MSC_VER
#include <cstdlib>
#endif
#include <stdint.h>
#if defined(HAVE_BYTESWAP_H)
#include <byteswap.h>
// All internal_bswap_* functions can be replaced with std::byteswap once we
// require c++23. Both libstdc++ and libc++ implement std::byteswap via these
// builtins.
#ifndef DISABLE_BUILTIN_BSWAPS
# if defined __has_builtin
# if __has_builtin(__builtin_bswap16)
# define bitcoin_builtin_bswap16(x) __builtin_bswap16(x)
# endif
# if __has_builtin(__builtin_bswap32)
# define bitcoin_builtin_bswap32(x) __builtin_bswap32(x)
# endif
# if __has_builtin(__builtin_bswap64)
# define bitcoin_builtin_bswap64(x) __builtin_bswap64(x)
# endif
# elif defined(_MSC_VER)
# define bitcoin_builtin_bswap16(x) _byteswap_ushort(x)
# define bitcoin_builtin_bswap32(x) _byteswap_ulong(x)
# define bitcoin_builtin_bswap64(x) _byteswap_uint64(x)
# endif
#endif
#if defined(MAC_OSX)
#include <libkern/OSByteOrder.h>
#define bswap_16(x) OSSwapInt16(x)
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
// MSVC's _byteswap_* functions are not constexpr
#ifndef _MSC_VER
#define BSWAP_CONSTEXPR constexpr
#else
// Non-MacOS / non-Darwin
#define BSWAP_CONSTEXPR
#endif
#if HAVE_DECL_BSWAP_16 == 0
inline uint16_t bswap_16(uint16_t x)
inline BSWAP_CONSTEXPR uint16_t internal_bswap_16(uint16_t x)
{
#ifdef bitcoin_builtin_bswap16
return bitcoin_builtin_bswap16(x);
#else
return (x >> 8) | (x << 8);
#endif
}
#endif // HAVE_DECL_BSWAP16 == 0
#if HAVE_DECL_BSWAP_32 == 0
inline uint32_t bswap_32(uint32_t x)
inline BSWAP_CONSTEXPR uint32_t internal_bswap_32(uint32_t x)
{
#ifdef bitcoin_builtin_bswap32
return bitcoin_builtin_bswap32(x);
#else
return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
#endif
}
#endif // HAVE_DECL_BSWAP32 == 0
#if HAVE_DECL_BSWAP_64 == 0
inline uint64_t bswap_64(uint64_t x)
inline BSWAP_CONSTEXPR uint64_t internal_bswap_64(uint64_t x)
{
#ifdef bitcoin_builtin_bswap64
return bitcoin_builtin_bswap64(x);
#else
return (((x & 0xff00000000000000ull) >> 56)
| ((x & 0x00ff000000000000ull) >> 40)
| ((x & 0x0000ff0000000000ull) >> 24)
@ -51,9 +73,7 @@ inline uint64_t bswap_64(uint64_t x)
| ((x & 0x0000000000ff0000ull) << 24)
| ((x & 0x000000000000ff00ull) << 40)
| ((x & 0x00000000000000ffull) << 56));
#endif
}
#endif // HAVE_DECL_BSWAP64 == 0
#endif // defined(MAC_OSX)
#endif // BITCOIN_COMPAT_BYTESWAP_H

View File

@ -3,24 +3,24 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_COMPAT_H
#define BITCOIN_COMPAT_H
#ifndef BITCOIN_COMPAT_COMPAT_H
#define BITCOIN_COMPAT_COMPAT_H
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
// Windows defines FD_SETSIZE to 64 (see _fd_types.h in mingw-w64),
// which is too small for our usage, but allows us to redefine it safely.
// We redefine it to be 1024, to match glibc, see typesizes.h.
#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#ifdef FD_SETSIZE
#undef FD_SETSIZE // prevent redefinition compiler warning
#undef FD_SETSIZE
#endif
#define FD_SETSIZE 1024 // max number of fds in fd_set
#define FD_SETSIZE 1024
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdint.h>
#include <cstdint>
#else
#include <fcntl.h>
#include <sys/mman.h>
@ -37,54 +37,46 @@
#include <unistd.h>
#endif
// We map Linux / BSD error functions and codes, to the equivalent
// Windows definitions, and use the WSA* names throughout our code.
// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h).
#ifndef WIN32
typedef unsigned int SOCKET;
#include <errno.h>
#include <cerrno>
#define WSAGetLastError() errno
#define WSAEINVAL EINVAL
#define WSAEALREADY EALREADY
#define WSAEWOULDBLOCK EWOULDBLOCK
#define WSAEAGAIN EAGAIN
#define WSAEMSGSIZE EMSGSIZE
#define WSAEINTR EINTR
#define WSAEINPROGRESS EINPROGRESS
#define WSAEADDRINUSE EADDRINUSE
#define WSAENOTSOCK EBADF
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR -1
#define SD_SEND SHUT_WR
#else
#ifndef WSAEAGAIN
// WSAEAGAIN doesn't exist on Windows
#ifdef EAGAIN
#define WSAEAGAIN EAGAIN
#else
#define WSAEAGAIN WSAEWOULDBLOCK
#endif
#endif
#endif
#ifdef WIN32
#ifndef S_IRUSR
#define S_IRUSR 0400
#define S_IWUSR 0200
#endif
#else
// Windows defines MAX_PATH as it's maximum path length.
// We define MAX_PATH for use on non-Windows systems.
#ifndef WIN32
#define MAX_PATH 1024
#endif
// ssize_t is POSIX, and not present when using MSVC.
#ifdef _MSC_VER
#if !defined(ssize_t)
#ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#endif
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
// The type of the option value passed to getsockopt & setsockopt
// differs between Windows and non-Windows.
#ifndef WIN32
typedef void* sockopt_arg_type;
#else
@ -135,4 +127,4 @@ bool static inline IsSelectableSocket(const SOCKET& s) {
#define MSG_DONTWAIT 0
#endif
#endif // BITCOIN_COMPAT_H
#endif // BITCOIN_COMPAT_COMPAT_H

View File

@ -10,6 +10,8 @@
#include <cpuid.h>
#include <cstdint>
// We can't use cpuid.h's __get_cpuid as it does not support subleafs.
void static inline GetCPUID(uint32_t leaf, uint32_t subleaf, uint32_t& a, uint32_t& b, uint32_t& c, uint32_t& d)
{

View File

@ -5,237 +5,70 @@
#ifndef BITCOIN_COMPAT_ENDIAN_H
#define BITCOIN_COMPAT_ENDIAN_H
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <compat/byteswap.h>
#include <stdint.h>
#include <bit>
#include <cstdint>
#if defined(HAVE_ENDIAN_H)
#include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
#include <sys/endian.h>
#endif
#ifndef HAVE_CONFIG_H
// While not technically a supported configuration, defaulting to defining these
// DECLs when we were compiled without autotools makes it easier for other build
// systems to build things like libdashconsensus for strange targets.
#ifdef htobe16
#define HAVE_DECL_HTOBE16 1
#endif
#ifdef htole16
#define HAVE_DECL_HTOLE16 1
#endif
#ifdef be16toh
#define HAVE_DECL_BE16TOH 1
#endif
#ifdef le16toh
#define HAVE_DECL_LE16TOH 1
#endif
#ifdef htobe32
#define HAVE_DECL_HTOBE32 1
#endif
#ifdef htole32
#define HAVE_DECL_HTOLE32 1
#endif
#ifdef be32toh
#define HAVE_DECL_BE32TOH 1
#endif
#ifdef le32toh
#define HAVE_DECL_LE32TOH 1
#endif
#ifdef htobe64
#define HAVE_DECL_HTOBE64 1
#endif
#ifdef htole64
#define HAVE_DECL_HTOLE64 1
#endif
#ifdef be64toh
#define HAVE_DECL_BE64TOH 1
#endif
#ifdef le64toh
#define HAVE_DECL_LE64TOH 1
#endif
#endif // HAVE_CONFIG_H
#if defined(WORDS_BIGENDIAN)
#if HAVE_DECL_HTOBE16 == 0
inline uint16_t htobe16(uint16_t host_16bits)
inline BSWAP_CONSTEXPR uint16_t htobe16_internal(uint16_t host_16bits)
{
return host_16bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_16(host_16bits);
else return host_16bits;
}
#endif // HAVE_DECL_HTOBE16
#if HAVE_DECL_HTOLE16 == 0
inline uint16_t htole16(uint16_t host_16bits)
inline BSWAP_CONSTEXPR uint16_t htole16_internal(uint16_t host_16bits)
{
return bswap_16(host_16bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_16(host_16bits);
else return host_16bits;
}
#endif // HAVE_DECL_HTOLE16
#if HAVE_DECL_BE16TOH == 0
inline uint16_t be16toh(uint16_t big_endian_16bits)
inline BSWAP_CONSTEXPR uint16_t be16toh_internal(uint16_t big_endian_16bits)
{
return big_endian_16bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_16(big_endian_16bits);
else return big_endian_16bits;
}
#endif // HAVE_DECL_BE16TOH
#if HAVE_DECL_LE16TOH == 0
inline uint16_t le16toh(uint16_t little_endian_16bits)
inline BSWAP_CONSTEXPR uint16_t le16toh_internal(uint16_t little_endian_16bits)
{
return bswap_16(little_endian_16bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_16(little_endian_16bits);
else return little_endian_16bits;
}
#endif // HAVE_DECL_LE16TOH
#if HAVE_DECL_HTOBE32 == 0
inline uint32_t htobe32(uint32_t host_32bits)
inline BSWAP_CONSTEXPR uint32_t htobe32_internal(uint32_t host_32bits)
{
return host_32bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_32(host_32bits);
else return host_32bits;
}
#endif // HAVE_DECL_HTOBE32
#if HAVE_DECL_HTOLE32 == 0
inline uint32_t htole32(uint32_t host_32bits)
inline BSWAP_CONSTEXPR uint32_t htole32_internal(uint32_t host_32bits)
{
return bswap_32(host_32bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(host_32bits);
else return host_32bits;
}
#endif // HAVE_DECL_HTOLE32
#if HAVE_DECL_BE32TOH == 0
inline uint32_t be32toh(uint32_t big_endian_32bits)
inline BSWAP_CONSTEXPR uint32_t be32toh_internal(uint32_t big_endian_32bits)
{
return big_endian_32bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_32(big_endian_32bits);
else return big_endian_32bits;
}
#endif // HAVE_DECL_BE32TOH
#if HAVE_DECL_LE32TOH == 0
inline uint32_t le32toh(uint32_t little_endian_32bits)
inline BSWAP_CONSTEXPR uint32_t le32toh_internal(uint32_t little_endian_32bits)
{
return bswap_32(little_endian_32bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(little_endian_32bits);
else return little_endian_32bits;
}
#endif // HAVE_DECL_LE32TOH
#if HAVE_DECL_HTOBE64 == 0
inline uint64_t htobe64(uint64_t host_64bits)
inline BSWAP_CONSTEXPR uint64_t htobe64_internal(uint64_t host_64bits)
{
return host_64bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_64(host_64bits);
else return host_64bits;
}
#endif // HAVE_DECL_HTOBE64
#if HAVE_DECL_HTOLE64 == 0
inline uint64_t htole64(uint64_t host_64bits)
inline BSWAP_CONSTEXPR uint64_t htole64_internal(uint64_t host_64bits)
{
return bswap_64(host_64bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_64(host_64bits);
else return host_64bits;
}
#endif // HAVE_DECL_HTOLE64
#if HAVE_DECL_BE64TOH == 0
inline uint64_t be64toh(uint64_t big_endian_64bits)
inline BSWAP_CONSTEXPR uint64_t be64toh_internal(uint64_t big_endian_64bits)
{
return big_endian_64bits;
if constexpr (std::endian::native == std::endian::little) return internal_bswap_64(big_endian_64bits);
else return big_endian_64bits;
}
#endif // HAVE_DECL_BE64TOH
#if HAVE_DECL_LE64TOH == 0
inline uint64_t le64toh(uint64_t little_endian_64bits)
inline BSWAP_CONSTEXPR uint64_t le64toh_internal(uint64_t little_endian_64bits)
{
return bswap_64(little_endian_64bits);
if constexpr (std::endian::native == std::endian::big) return internal_bswap_64(little_endian_64bits);
else return little_endian_64bits;
}
#endif // HAVE_DECL_LE64TOH
#else // WORDS_BIGENDIAN
#if HAVE_DECL_HTOBE16 == 0
inline uint16_t htobe16(uint16_t host_16bits)
{
return bswap_16(host_16bits);
}
#endif // HAVE_DECL_HTOBE16
#if HAVE_DECL_HTOLE16 == 0
inline uint16_t htole16(uint16_t host_16bits)
{
return host_16bits;
}
#endif // HAVE_DECL_HTOLE16
#if HAVE_DECL_BE16TOH == 0
inline uint16_t be16toh(uint16_t big_endian_16bits)
{
return bswap_16(big_endian_16bits);
}
#endif // HAVE_DECL_BE16TOH
#if HAVE_DECL_LE16TOH == 0
inline uint16_t le16toh(uint16_t little_endian_16bits)
{
return little_endian_16bits;
}
#endif // HAVE_DECL_LE16TOH
#if HAVE_DECL_HTOBE32 == 0
inline uint32_t htobe32(uint32_t host_32bits)
{
return bswap_32(host_32bits);
}
#endif // HAVE_DECL_HTOBE32
#if HAVE_DECL_HTOLE32 == 0
inline uint32_t htole32(uint32_t host_32bits)
{
return host_32bits;
}
#endif // HAVE_DECL_HTOLE32
#if HAVE_DECL_BE32TOH == 0
inline uint32_t be32toh(uint32_t big_endian_32bits)
{
return bswap_32(big_endian_32bits);
}
#endif // HAVE_DECL_BE32TOH
#if HAVE_DECL_LE32TOH == 0
inline uint32_t le32toh(uint32_t little_endian_32bits)
{
return little_endian_32bits;
}
#endif // HAVE_DECL_LE32TOH
#if HAVE_DECL_HTOBE64 == 0
inline uint64_t htobe64(uint64_t host_64bits)
{
return bswap_64(host_64bits);
}
#endif // HAVE_DECL_HTOBE64
#if HAVE_DECL_HTOLE64 == 0
inline uint64_t htole64(uint64_t host_64bits)
{
return host_64bits;
}
#endif // HAVE_DECL_HTOLE64
#if HAVE_DECL_BE64TOH == 0
inline uint64_t be64toh(uint64_t big_endian_64bits)
{
return bswap_64(big_endian_64bits);
}
#endif // HAVE_DECL_BE64TOH
#if HAVE_DECL_LE64TOH == 0
inline uint64_t le64toh(uint64_t little_endian_64bits)
{
return little_endian_64bits;
}
#endif // HAVE_DECL_LE64TOH
#endif // WORDS_BIGENDIAN
#endif // BITCOIN_COMPAT_ENDIAN_H

View File

@ -2,23 +2,19 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <compat/stdin.h>
#include <cstdio> // for fileno(), stdin
#include <cstdio>
#ifdef WIN32
#include <windows.h> // for SetStdinEcho()
#include <io.h> // for isatty()
#include <windows.h>
#include <io.h>
#else
#include <termios.h> // for SetStdinEcho()
#include <unistd.h> // for SetStdinEcho(), isatty()
#include <poll.h> // for StdinReady()
#include <termios.h>
#include <unistd.h>
#include <poll.h>
#endif
#include <compat/stdin.h>
// https://stackoverflow.com/questions/1413445/reading-a-password-from-stdcin
void SetStdinEcho(bool enable)
{

View File

@ -1,18 +0,0 @@
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <cstring>
#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len)
{
const char *end = (const char *)memchr(start, '\0', max_len);
return end ? (size_t)(end - start) : max_len;
}
#endif // HAVE_DECL_STRNLEN

View File

@ -9,8 +9,8 @@
#include <array>
#include <cstddef>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
#include <utility>
// classes for ChaCha20 256-bit stream cipher developed by Daniel J. Bernstein

View File

@ -5,106 +5,81 @@
#ifndef BITCOIN_CRYPTO_COMMON_H
#define BITCOIN_CRYPTO_COMMON_H
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#include <stdint.h>
#include <string.h>
#include <compat/endian.h>
#include <cstdint>
#include <cstring>
uint16_t static inline ReadLE16(const unsigned char* ptr)
{
uint16_t x;
memcpy((char*)&x, ptr, 2);
return le16toh(x);
memcpy(&x, ptr, 2);
return le16toh_internal(x);
}
uint32_t static inline ReadLE32(const unsigned char* ptr)
{
uint32_t x;
memcpy((char*)&x, ptr, 4);
return le32toh(x);
memcpy(&x, ptr, 4);
return le32toh_internal(x);
}
uint64_t static inline ReadLE64(const unsigned char* ptr)
{
uint64_t x;
memcpy((char*)&x, ptr, 8);
return le64toh(x);
memcpy(&x, ptr, 8);
return le64toh_internal(x);
}
void static inline WriteLE16(unsigned char* ptr, uint16_t x)
{
uint16_t v = htole16(x);
memcpy(ptr, (char*)&v, 2);
uint16_t v = htole16_internal(x);
memcpy(ptr, &v, 2);
}
void static inline WriteLE32(unsigned char* ptr, uint32_t x)
{
uint32_t v = htole32(x);
memcpy(ptr, (char*)&v, 4);
uint32_t v = htole32_internal(x);
memcpy(ptr, &v, 4);
}
void static inline WriteLE64(unsigned char* ptr, uint64_t x)
{
uint64_t v = htole64(x);
memcpy(ptr, (char*)&v, 8);
uint64_t v = htole64_internal(x);
memcpy(ptr, &v, 8);
}
uint16_t static inline ReadBE16(const unsigned char* ptr)
{
uint16_t x;
memcpy((char*)&x, ptr, 2);
return be16toh(x);
memcpy(&x, ptr, 2);
return be16toh_internal(x);
}
uint32_t static inline ReadBE32(const unsigned char* ptr)
{
uint32_t x;
memcpy((char*)&x, ptr, 4);
return be32toh(x);
memcpy(&x, ptr, 4);
return be32toh_internal(x);
}
uint64_t static inline ReadBE64(const unsigned char* ptr)
{
uint64_t x;
memcpy((char*)&x, ptr, 8);
return be64toh(x);
memcpy(&x, ptr, 8);
return be64toh_internal(x);
}
void static inline WriteBE32(unsigned char* ptr, uint32_t x)
{
uint32_t v = htobe32(x);
memcpy(ptr, (char*)&v, 4);
uint32_t v = htobe32_internal(x);
memcpy(ptr, &v, 4);
}
void static inline WriteBE64(unsigned char* ptr, uint64_t x)
{
uint64_t v = htobe64(x);
memcpy(ptr, (char*)&v, 8);
}
/** Return the smallest number n such that (x >> n) == 0 (or 64 if the highest bit in x is set. */
uint64_t static inline CountBits(uint64_t x)
{
#if HAVE_BUILTIN_CLZL
if (sizeof(unsigned long) >= sizeof(uint64_t)) {
return x ? 8 * sizeof(unsigned long) - __builtin_clzl(x) : 0;
}
#endif
#if HAVE_BUILTIN_CLZLL
if (sizeof(unsigned long long) >= sizeof(uint64_t)) {
return x ? 8 * sizeof(unsigned long long) - __builtin_clzll(x) : 0;
}
#endif
int ret = 0;
while (x) {
x >>= 1;
++ret;
}
return ret;
uint64_t v = htobe64_internal(x);
memcpy(ptr, &v, 8);
}
#endif // BITCOIN_CRYPTO_COMMON_H

View File

@ -7,8 +7,8 @@
#include <crypto/hmac_sha256.h>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A rfc5869 HKDF implementation with HMAC_SHA256 and fixed key output length of 32 bytes (L=32) */
class CHKDF_HMAC_SHA256_L32

View File

@ -7,8 +7,8 @@
#include <crypto/sha256.h>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A hasher class for HMAC-SHA-256. */
class CHMAC_SHA256

View File

@ -7,8 +7,8 @@
#include <crypto/sha512.h>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A hasher class for HMAC-SHA-512. */
class CHMAC_SHA512

View File

@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_PKCS5_PBKDF2_HMAC_SHA512_H
#define BITCOIN_CRYPTO_PKCS5_PBKDF2_HMAC_SHA512_H
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A rfc2898 implementation of PKCS#5 v2.0 password based encryption key
* derivation function PBKDF2 with HMAC_SHA512. This implementation is

View File

@ -8,8 +8,8 @@
#include <span.h>
#include <cassert>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
#define POLY1305_BLOCK_SIZE 16

View File

@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_RIPEMD160_H
#define BITCOIN_CRYPTO_RIPEMD160_H
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A hasher class for RIPEMD-160. */
class CRIPEMD160

View File

@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_SHA1_H
#define BITCOIN_CRYPTO_SHA1_H
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A hasher class for SHA1. */
class CSHA1

View File

@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_SHA256_H
#define BITCOIN_CRYPTO_SHA256_H
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
#include <string>
/** A hasher class for SHA-256. */

View File

@ -5,8 +5,8 @@
// This is a translation to GCC extended asm syntax from YASM code by Intel
// (available at the bottom of this file).
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
#if defined(__x86_64__) || defined(__amd64__)

View File

@ -7,8 +7,8 @@
#include <span.h>
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
//! The Keccak-f[1600] transform.
void KeccakF(uint64_t (&st)[25]);

View File

@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_SHA512_H
#define BITCOIN_CRYPTO_SHA512_H
#include <cstdlib>
#include <stdint.h>
#include <stdlib.h>
/** A hasher class for SHA-512. */
class CSHA512

View File

@ -21,6 +21,8 @@
static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64;
static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024;
inline auto CharCast(const std::byte* data) { return reinterpret_cast<const char*>(data); }
class dbwrapper_error : public std::runtime_error
{
public:
@ -83,12 +85,12 @@ public:
template <typename V>
void Write(const CDataStream& _ssKey, const V& value)
{
leveldb::Slice slKey((const char*)_ssKey.data(), _ssKey.size());
leveldb::Slice slKey(CharCast(_ssKey.data()), _ssKey.size());
ssValue.reserve(DBWRAPPER_PREALLOC_VALUE_SIZE);
ssValue << value;
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
leveldb::Slice slValue((const char*)ssValue.data(), ssValue.size());
leveldb::Slice slValue(CharCast(ssValue.data()), ssValue.size());
batch.Put(slKey, slValue);
// - varint: key length (1 byte up to 127B, 2 bytes up to 16383B, ...)
@ -110,7 +112,7 @@ public:
}
void Erase(const CDataStream& _ssKey) {
leveldb::Slice slKey((const char*)_ssKey.data(), _ssKey.size());
leveldb::Slice slKey(CharCast(_ssKey.data()), _ssKey.size());
batch.Delete(slKey);
// - byte: header
@ -151,7 +153,7 @@ public:
}
void Seek(const CDataStream& ssKey) {
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
piter->Seek(slKey);
}
@ -259,7 +261,7 @@ public:
bool ReadDataStream(const CDataStream& ssKey, CDataStream& ssValue) const
{
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
std::string strValue;
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
@ -319,7 +321,7 @@ public:
bool Exists(const CDataStream& key) const
{
leveldb::Slice slKey((const char*)key.data(), key.size());
leveldb::Slice slKey(CharCast(key.data()), key.size());
std::string strValue;
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
@ -363,8 +365,8 @@ public:
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
ssKey1 << key_begin;
ssKey2 << key_end;
leveldb::Slice slKey1((const char*)ssKey1.data(), ssKey1.size());
leveldb::Slice slKey2((const char*)ssKey2.data(), ssKey2.size());
leveldb::Slice slKey1(CharCast(ssKey1.data()), ssKey1.size());
leveldb::Slice slKey2(CharCast(ssKey2.data()), ssKey2.size());
uint64_t size = 0;
leveldb::Range range(slKey1, slKey2);
pdb->GetApproximateSizes(&range, 1, &size);
@ -382,8 +384,8 @@ public:
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
ssKey1 << key_begin;
ssKey2 << key_end;
leveldb::Slice slKey1((const char*)ssKey1.data(), ssKey1.size());
leveldb::Slice slKey2((const char*)ssKey2.data(), ssKey2.size());
leveldb::Slice slKey1(CharCast(ssKey1.data()), ssKey1.size());
leveldb::Slice slKey2(CharCast(ssKey2.data()), ssKey2.size());
pdb->CompactRange(&slKey1, &slKey2);
}

View File

@ -11,9 +11,6 @@
#include <sys/utsname.h>
#include <unistd.h>
#else
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <codecvt>
#include <limits>
#include <windows.h>

View File

@ -10,7 +10,7 @@
#include <chainparamsbase.h>
#include <netbase.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <rpc/protocol.h> // For HTTP status codes
#include <shutdown.h>
#include <sync.h>
@ -19,8 +19,8 @@
#include <util/threadnames.h>
#include <util/translation.h>
#include <cstdio>
#include <deque>
#include <stdio.h>
#include <string>
#include <sys/types.h>

View File

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <compat.h>
#include <compat/compat.h>
#include <compat/endian.h>
#include <crypto/sha256.h>
#include <fs.h>
@ -355,7 +355,7 @@ Binary Session::MyDestination() const
uint16_t cert_len;
memcpy(&cert_len, &m_private_key.at(CERT_LEN_POS), sizeof(cert_len));
cert_len = be16toh(cert_len);
cert_len = be16toh_internal(cert_len);
const size_t dest_len = DEST_LEN_BASE + cert_len;

View File

@ -5,7 +5,7 @@
#ifndef BITCOIN_I2P_H
#define BITCOIN_I2P_H
#include <compat.h>
#include <compat/compat.h>
#include <fs.h>
#include <netaddress.h>
#include <sync.h>

View File

@ -5,7 +5,7 @@
#include <chainparams.h>
#include <index/base.h>
#include <node/blockstorage.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <shutdown.h>
#include <tinyformat.h>
#include <util/thread.h>

View File

@ -39,7 +39,7 @@
#include <netgroup.h>
#include <node/blockstorage.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <node/txreconciliation.h>
#include <policy/feerate.h>
#include <policy/fees.h>
@ -1441,11 +1441,6 @@ bool AppInitLockDataDirectory()
bool AppInitInterfaces(NodeContext& node)
{
node.chain = interfaces::MakeChain(node);
// Create client interfaces for wallets that are supposed to be loaded
// according to -wallet and -disablewallet options. This only constructs
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
// when load() and start() interface methods are called below.
g_wallet_init_interface.Construct(node);
return true;
}
@ -1515,11 +1510,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);
tableRPC.InitPlatformRestrictions();
// Create client interfaces for wallets that are supposed to be loaded
// according to -wallet and -disablewallet options. This only constructs
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
// when load() and start() interface methods are called below.
g_wallet_init_interface.Construct(node);
uiInterface.InitWallet();
/* Register RPC commands regardless of -server setting so they will be
* available in the GUI RPC console even if external calls are disabled.
*/
tableRPC.InitPlatformRestrictions();
RegisterAllCoreRPCCommands(tableRPC);
for (const auto& client : node.chain_clients) {
client->registerRpcs();

View File

@ -11,7 +11,7 @@
#include <crypto/sha256.h>
#include <key.h>
#include <logging.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <random.h>
#include <util/string.h>
#include <util/system.h>

View File

@ -309,6 +309,10 @@ public:
using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>;
virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;
//! Register handler for wallet client constructed messages.
using InitWalletFn = std::function<void()>;
virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;
//! Register handler for number of connections changed messages.
using NotifyNumConnectionsChangedFn = std::function<void(int new_num_connections)>;
virtual std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0;

View File

@ -12,11 +12,11 @@
#include <tinyformat.h>
#include <util/system.h>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <memory>
#include <stdexcept>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unistd.h>

View File

@ -10,10 +10,10 @@
#include <util/strencodings.h>
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
#include <system_error>
#include <unistd.h>

View File

@ -12,7 +12,7 @@
#include <consensus/validation.h>
#include <masternode/sync.h>
#include <node/blockstorage.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <scheduler.h>
#include <spork.h>
#include <txmempool.h>

View File

@ -18,7 +18,7 @@
#include <util/thread.h>
#ifdef USE_NATPMP
#include <compat.h>
#include <compat/compat.h>
#include <natpmp.h>
#endif // USE_NATPMP

View File

@ -8,11 +8,11 @@
#include <governance/governance.h>
#include <netfulfilledman.h>
#include <netmessagemaker.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <shutdown.h>
#include <validation.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
class CMasternodeSync;

View File

@ -9,9 +9,8 @@
#include <prevector.h>
#include <support/allocators/pool.h>
#include <stdlib.h>
#include <cassert>
#include <cstdlib>
#include <map>
#include <memory>
#include <set>

View File

@ -15,7 +15,7 @@
#include <addrman.h>
#include <banman.h>
#include <clientversion.h>
#include <compat.h>
#include <compat/compat.h>
#include <consensus/consensus.h>
#include <crypto/sha256.h>
#include <node/eviction.h>
@ -25,7 +25,7 @@
#include <net_permissions.h>
#include <netaddress.h>
#include <netbase.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <protocol.h>
#include <random.h>
#include <scheduler.h>

View File

@ -9,7 +9,7 @@
#include <bip324.h>
#include <chainparams.h>
#include <common/bloom.h>
#include <compat.h>
#include <compat/compat.h>
#include <consensus/amount.h>
#include <fs.h>
#include <crypto/siphash.h>

View File

@ -10,7 +10,7 @@
#endif
#include <attributes.h>
#include <compat.h>
#include <compat/compat.h>
#include <crypto/siphash.h>
#include <prevector.h>
#include <random.h>

View File

@ -5,7 +5,7 @@
#include <netbase.h>
#include <compat.h>
#include <compat/compat.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/sock.h>

View File

@ -9,7 +9,7 @@
#include <config/bitcoin-config.h>
#endif
#include <compat.h>
#include <compat/compat.h>
#include <netaddress.h>
#include <serialize.h>
#include <util/sock.h>

View File

@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <util/translation.h>
@ -15,6 +15,7 @@ struct UISignals {
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
boost::signals2::signal<CClientUIInterface::InitWalletSig> InitWallet;
boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
@ -37,6 +38,7 @@ static UISignals g_ui_signals;
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
ADD_SIGNALS_IMPL_WRAPPER(InitMessage);
ADD_SIGNALS_IMPL_WRAPPER(InitWallet);
ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
@ -51,6 +53,7 @@ ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
void CClientUIInterface::InitWallet() { return g_ui_signals.InitWallet(); }
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }

View File

@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NODE_UI_INTERFACE_H
#define BITCOIN_NODE_UI_INTERFACE_H
#ifndef BITCOIN_NODE_INTERFACE_UI_H
#define BITCOIN_NODE_INTERFACE_UI_H
#include <functional>
#include <memory>
@ -83,6 +83,9 @@ public:
/** Progress message during initialization. */
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
/** Wallet client created. */
ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, );
/** Number of network connections changed. */
ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections);
@ -128,4 +131,4 @@ constexpr auto AbortError = InitError;
extern CClientUIInterface uiInterface;
#endif // BITCOIN_NODE_UI_INTERFACE_H
#endif // BITCOIN_NODE_INTERFACE_UI_H

View File

@ -30,7 +30,7 @@
#include <node/blockstorage.h>
#include <node/coin.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <node/transaction.h>
#include <policy/feerate.h>
#include <policy/fees.h>
@ -527,6 +527,10 @@ public:
{
return MakeHandler(::uiInterface.ShowProgress_connect(fn));
}
std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) override
{
return MakeHandler(::uiInterface.InitWallet_connect(fn));
}
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override
{
return MakeHandler(::uiInterface.NotifyNumConnectionsChanged_connect(fn));

View File

@ -7,7 +7,7 @@
#include <noui.h>
#include <logging.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <util/translation.h>
#include <string>

View File

@ -6,12 +6,12 @@
#define BITCOIN_PREVECTOR_H
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
#include <utility>
@ -47,26 +47,28 @@ public:
typedef const value_type* const_pointer;
class iterator {
T* ptr;
T* ptr{};
public:
typedef Diff difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef std::random_access_iterator_tag iterator_category;
using element_type = T;
using iterator_category = std::contiguous_iterator_tag;
iterator() = default;
iterator(T* ptr_) : ptr(ptr_) {}
T& operator*() const { return *ptr; }
T* operator->() const { return ptr; }
T& operator[](size_type pos) { return ptr[pos]; }
const T& operator[](size_type pos) const { return ptr[pos]; }
T& operator[](size_type pos) const { return ptr[pos]; }
iterator& operator++() { ptr++; return *this; }
iterator& operator--() { ptr--; return *this; }
iterator operator++(int) { iterator copy(*this); ++(*this); return copy; }
iterator operator--(int) { iterator copy(*this); --(*this); return copy; }
difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); }
iterator operator+(size_type n) { return iterator(ptr + n); }
iterator operator+(size_type n) const { return iterator(ptr + n); }
iterator friend operator+(size_type n, iterator x) { return x + n; }
iterator& operator+=(size_type n) { ptr += n; return *this; }
iterator operator-(size_type n) { return iterator(ptr - n); }
iterator operator-(size_type n) const { return iterator(ptr - n); }
iterator& operator-=(size_type n) { ptr -= n; return *this; }
bool operator==(iterator x) const { return ptr == x.ptr; }
bool operator!=(iterator x) const { return ptr != x.ptr; }
@ -77,18 +79,17 @@ public:
};
class reverse_iterator {
T* ptr;
T* ptr{};
public:
typedef Diff difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef std::bidirectional_iterator_tag iterator_category;
reverse_iterator() = default;
reverse_iterator(T* ptr_) : ptr(ptr_) {}
T& operator*() { return *ptr; }
const T& operator*() const { return *ptr; }
T* operator->() { return ptr; }
const T* operator->() const { return ptr; }
T& operator*() const { return *ptr; }
T* operator->() const { return ptr; }
reverse_iterator& operator--() { ptr++; return *this; }
reverse_iterator& operator++() { ptr--; return *this; }
reverse_iterator operator++(int) { reverse_iterator copy(*this); ++(*this); return copy; }
@ -98,13 +99,15 @@ public:
};
class const_iterator {
const T* ptr;
const T* ptr{};
public:
typedef Diff difference_type;
typedef const T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef std::random_access_iterator_tag iterator_category;
using element_type = const T;
using iterator_category = std::contiguous_iterator_tag;
const_iterator() = default;
const_iterator(const T* ptr_) : ptr(ptr_) {}
const_iterator(iterator x) : ptr(&(*x)) {}
const T& operator*() const { return *ptr; }
@ -115,9 +118,10 @@ public:
const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; }
const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; }
difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); }
const_iterator operator+(size_type n) { return const_iterator(ptr + n); }
const_iterator operator+(size_type n) const { return const_iterator(ptr + n); }
const_iterator friend operator+(size_type n, const_iterator x) { return x + n; }
const_iterator& operator+=(size_type n) { ptr += n; return *this; }
const_iterator operator-(size_type n) { return const_iterator(ptr - n); }
const_iterator operator-(size_type n) const { return const_iterator(ptr - n); }
const_iterator& operator-=(size_type n) { ptr -= n; return *this; }
bool operator==(const_iterator x) const { return ptr == x.ptr; }
bool operator!=(const_iterator x) const { return ptr != x.ptr; }
@ -128,13 +132,14 @@ public:
};
class const_reverse_iterator {
const T* ptr;
const T* ptr{};
public:
typedef Diff difference_type;
typedef const T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef std::bidirectional_iterator_tag iterator_category;
const_reverse_iterator() = default;
const_reverse_iterator(const T* ptr_) : ptr(ptr_) {}
const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {}
const T& operator*() const { return *ptr; }

View File

@ -16,7 +16,7 @@
#include <interfaces/node.h>
#include <net.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <noui.h>
#include <qt/bitcoingui.h>
#include <qt/clientmodel.h>
@ -262,7 +262,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
// We don't hold a direct pointer to the splash screen after creation, but the splash
// screen will take care of deleting itself when finish() happens.
m_splash->show();
connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet);
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
}

View File

@ -36,7 +36,7 @@
#include <interfaces/coinjoin.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <qt/governancelist.h>
#include <qt/masternodelist.h>
#include <util/system.h>

View File

@ -29,9 +29,6 @@
#include <cmath>
#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>

View File

@ -4,7 +4,7 @@
#include <qt/bitcoin.h>
#include <compat.h>
#include <compat/compat.h>
#include <util/translation.h>
#include <util/url.h>

View File

@ -17,7 +17,7 @@
#include <clientversion.h>
#include <interfaces/node.h>
#include <key_io.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <policy/policy.h>
#include <util/system.h>

View File

@ -21,7 +21,7 @@
#include <chainparams.h>
#include <interfaces/node.h>
#include <key_io.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <policy/fees.h>
#include <txmempool.h>
#include <wallet/coincontrol.h>

View File

@ -199,6 +199,7 @@ void SplashScreen::subscribeToCoreSignals()
// Connect signals to client
m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); });
}
void SplashScreen::handleLoadWallet()

View File

@ -66,6 +66,7 @@ private:
bool m_shutdown = false;
std::unique_ptr<interfaces::Handler> m_handler_init_message;
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
std::unique_ptr<interfaces::Handler> m_handler_init_wallet;
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
std::list<std::unique_ptr<interfaces::Wallet>> m_connected_wallets;
std::list<std::unique_ptr<interfaces::Handler>> m_connected_wallet_handlers;

View File

@ -18,7 +18,7 @@
#include <qt/walletmodel.h>
#include <interfaces/node.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <optional>

View File

@ -18,7 +18,7 @@
#include <util/system.h>
#include <util/strencodings.h>
#include <stdio.h>
#include <cstdio>
#include <QCloseEvent>
#include <QLabel>

View File

@ -5,7 +5,7 @@
#include <qt/walletframe.h>
#include <fs.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <psbt.h>
#include <qt/governancelist.h>
#include <qt/guiutil.h>

View File

@ -22,7 +22,7 @@
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <key_io.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <psbt.h>
#include <util/system.h> // for GetBoolArg
#include <util/translation.h>

View File

@ -22,7 +22,7 @@
#include <qt/walletmodel.h>
#include <interfaces/node.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <util/strencodings.h>
#include <QAction>

View File

@ -9,24 +9,23 @@
#include <crypto/chacha20.h>
#include <crypto/sha256.h>
#include <crypto/sha512.h>
#include <support/cleanse.h>
#ifdef WIN32
#include <compat.h> // for Windows API
#include <wincrypt.h>
#endif
#include <logging.h>
#include <randomenv.h>
#include <support/allocators/secure.h>
#include <span.h>
#include <sync.h> // for Mutex
#include <util/time.h> // for GetTimeMicros()
#include <support/allocators/secure.h>
#include <support/cleanse.h>
#include <sync.h>
#include <util/time.h>
#include <array>
#include <cmath>
#include <stdlib.h>
#include <cstdlib>
#include <thread>
#ifndef WIN32
#ifdef WIN32
#include <windows.h>
#include <wincrypt.h>
#else
#include <fcntl.h>
#endif
@ -729,7 +728,7 @@ bool Random_SanityCheck()
* GetOSRand() overwrites all 32 bytes of the output given a maximum
* number of tries.
*/
static const ssize_t MAX_TRIES = 1024;
static constexpr int MAX_TRIES{1024};
uint8_t data[NUM_OS_RANDOM_BYTES];
bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */
int num_overwritten;

View File

@ -11,6 +11,7 @@
#include <span.h>
#include <uint256.h>
#include <bit>
#include <cassert>
#include <chrono> // For std::chrono::microseconds
#include <cstdint>
@ -196,7 +197,7 @@ public:
{
assert(range);
--range;
int bits = CountBits(range);
int bits = std::bit_width(range);
while (true) {
uint64_t ret = randbits(bits);
if (ret <= range) return ret;

View File

@ -14,22 +14,23 @@
#include <crypto/sha512.h>
#include <span.h>
#include <support/cleanse.h>
#include <util/time.h> // for GetTime()
#ifdef WIN32
#include <compat.h> // for Windows API
#endif
#include <util/time.h>
#include <algorithm>
#include <atomic>
#include <cstdint>
#include <cstring>
#include <chrono>
#include <climits>
#include <thread>
#include <vector>
#include <stdint.h>
#include <string.h>
#ifndef WIN32
#include <sys/types.h> // must go before a number of other headers
#ifdef WIN32
#include <windows.h>
#include <winreg.h>
#else
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/resource.h>

View File

@ -365,6 +365,7 @@ static RPCHelpMan coinjoinsalt_set()
}
#endif // ENABLE_WALLET
// TODO: remove it completely
static RPCHelpMan getpoolinfo()
{
return RPCHelpMan{"getpoolinfo",
@ -469,7 +470,6 @@ void RegisterCoinJoinRPCCommands(CRPCTable &t)
static const CRPCCommand commands[] =
{ // category actor (function)
// --------------------- -----------------------
{ "dash", &getpoolinfo, },
{ "dash", &getcoinjoininfo, },
#ifdef ENABLE_WALLET
{ "dash", &coinjoin, },
@ -480,6 +480,8 @@ static const CRPCCommand commands[] =
{ "dash", &coinjoinsalt_generate, },
{ "dash", &coinjoinsalt_get, },
{ "dash", &coinjoinsalt_set, },
{ "hidden", &getpoolinfo, },
#endif // ENABLE_WALLET
};
// clang-format on

View File

@ -134,6 +134,7 @@ static UniValue GetNextMasternodeForPayment(const CChain& active_chain, CDetermi
return obj;
}
// TODO: drop it
static RPCHelpMan masternode_winner()
{
return RPCHelpMan{"masternode winner",
@ -154,6 +155,7 @@ static RPCHelpMan masternode_winner()
};
}
// TODO: drop it
static RPCHelpMan masternode_current()
{
return RPCHelpMan{"masternode current",
@ -227,7 +229,7 @@ static RPCHelpMan masternode_status()
}
UniValue mnObj(UniValue::VOBJ);
// keep compatibility with legacy status for now (might get deprecated/removed later)
// keep compatibility with legacy status for now (TODO: get deprecated/removed later)
mnObj.pushKV("outpoint", node.mn_activeman->GetOutPoint().ToStringShort());
mnObj.pushKV("service", node.mn_activeman->GetService().ToStringAddrPort());
auto dmn = CHECK_NONFATAL(node.dmnman)->GetListAtChainTip().GetMN(node.mn_activeman->GetProTxHash());
@ -750,8 +752,8 @@ static const CRPCCommand commands[] =
{ "dash", &masternode_status, },
{ "dash", &masternode_payments, },
{ "dash", &masternode_winners, },
{ "dash", &masternode_current, },
{ "dash", &masternode_winner, },
{ "hidden", &masternode_current, },
{ "hidden", &masternode_winner, },
};
// clang-format on
for (const auto& command : commands) {

View File

@ -241,7 +241,7 @@ static RPCHelpMan getpeerinfo()
obj.pushKV("masternode", stats.m_masternode_connection);
if (fStateStats) {
if (IsDeprecatedRPCEnabled("banscore")) {
// banscore is deprecated in v21 for removal in v22
// TODO: banscore is deprecated in v21 for removal in v22, maybe impossible due to usages in p2p_quorum_data.py
obj.pushKV("banscore", statestats.m_misbehavior_score);
}
obj.pushKV("startingheight", statestats.m_starting_height);
@ -1126,10 +1126,10 @@ static const CRPCCommand commands[] =
{ "network", &setban, },
{ "network", &listbanned, },
{ "network", &clearbanned, },
{ "network", &cleardiscouraged, },
{ "network", &setnetworkactive, },
{ "network", &getnodeaddresses, },
{ "hidden", &cleardiscouraged, },
{ "hidden", &addconnection, },
{ "hidden", &addpeeraddress, },
{ "hidden", &sendmsgtopeer },

View File

@ -60,27 +60,27 @@ template<typename Stream> inline void ser_writedata8(Stream &s, uint8_t obj)
}
template<typename Stream> inline void ser_writedata16(Stream &s, uint16_t obj)
{
obj = htole16(obj);
obj = htole16_internal(obj);
s.write(AsBytes(Span{&obj, 1}));
}
template<typename Stream> inline void ser_writedata16be(Stream &s, uint16_t obj)
{
obj = htobe16(obj);
obj = htobe16_internal(obj);
s.write(AsBytes(Span{&obj, 1}));
}
template<typename Stream> inline void ser_writedata32(Stream &s, uint32_t obj)
{
obj = htole32(obj);
obj = htole32_internal(obj);
s.write(AsBytes(Span{&obj, 1}));
}
template<typename Stream> inline void ser_writedata32be(Stream &s, uint32_t obj)
{
obj = htobe32(obj);
obj = htobe32_internal(obj);
s.write(AsBytes(Span{&obj, 1}));
}
template<typename Stream> inline void ser_writedata64(Stream &s, uint64_t obj)
{
obj = htole64(obj);
obj = htole64_internal(obj);
s.write(AsBytes(Span{&obj, 1}));
}
template<typename Stream> inline uint8_t ser_readdata8(Stream &s)
@ -93,31 +93,31 @@ template<typename Stream> inline uint16_t ser_readdata16(Stream &s)
{
uint16_t obj;
s.read(AsWritableBytes(Span{&obj, 1}));
return le16toh(obj);
return le16toh_internal(obj);
}
template<typename Stream> inline uint16_t ser_readdata16be(Stream &s)
{
uint16_t obj;
s.read(AsWritableBytes(Span{&obj, 1}));
return be16toh(obj);
return be16toh_internal(obj);
}
template<typename Stream> inline uint32_t ser_readdata32(Stream &s)
{
uint32_t obj;
s.read(AsWritableBytes(Span{&obj, 1}));
return le32toh(obj);
return le32toh_internal(obj);
}
template<typename Stream> inline uint32_t ser_readdata32be(Stream &s)
{
uint32_t obj;
s.read(AsWritableBytes(Span{&obj, 1}));
return be32toh(obj);
return be32toh_internal(obj);
}
template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
{
uint64_t obj;
s.read(AsWritableBytes(Span{&obj, 1}));
return le64toh(obj);
return le64toh_internal(obj);
}
@ -655,11 +655,11 @@ struct CustomUintFormatter
{
if (v < 0 || v > MAX) throw std::ios_base::failure("CustomUintFormatter value out of range");
if (BigEndian) {
uint64_t raw = htobe64(v);
s.write({BytePtr(&raw) + 8 - Bytes, Bytes});
uint64_t raw = htobe64_internal(v);
s.write(AsBytes(Span{&raw, 1}).last(Bytes));
} else {
uint64_t raw = htole64(v);
s.write({BytePtr(&raw), Bytes});
uint64_t raw = htole64_internal(v);
s.write(AsBytes(Span{&raw, 1}).first(Bytes));
}
}
@ -669,11 +669,11 @@ struct CustomUintFormatter
static_assert(std::numeric_limits<U>::max() >= MAX && std::numeric_limits<U>::min() <= 0, "Assigned type too small");
uint64_t raw = 0;
if (BigEndian) {
s.read({BytePtr(&raw) + 8 - Bytes, Bytes});
v = static_cast<I>(be64toh(raw));
s.read(AsWritableBytes(Span{&raw, 1}).last(Bytes));
v = static_cast<I>(be64toh_internal(raw));
} else {
s.read({BytePtr(&raw), Bytes});
v = static_cast<I>(le64toh(raw));
s.read(AsWritableBytes(Span{&raw, 1}).first(Bytes));
v = static_cast<I>(le64toh_internal(raw));
}
}
};

View File

@ -12,7 +12,7 @@
#include <logging.h>
#include <util/tokenpipe.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <warnings.h>
#include <assert.h>

View File

@ -5,10 +5,10 @@
#ifndef BITCOIN_SPAN_H
#define BITCOIN_SPAN_H
#include <type_traits>
#include <cstddef>
#include <algorithm>
#include <assert.h>
#include <cassert>
#include <cstddef>
#include <type_traits>
#ifdef DEBUG_CORE
#define CONSTEXPR_IF_NOT_DEBUG
@ -243,21 +243,16 @@ T& SpanPopBack(Span<T>& span)
return back;
}
//! Convert a data pointer to a std::byte data pointer.
//! Where possible, please use the safer AsBytes helpers.
inline const std::byte* BytePtr(const void* data) { return reinterpret_cast<const std::byte*>(data); }
inline std::byte* BytePtr(void* data) { return reinterpret_cast<std::byte*>(data); }
// From C++20 as_bytes and as_writeable_bytes
template <typename T>
Span<const std::byte> AsBytes(Span<T> s) noexcept
{
return {BytePtr(s.data()), s.size_bytes()};
return {reinterpret_cast<const std::byte*>(s.data()), s.size_bytes()};
}
template <typename T>
Span<std::byte> AsWritableBytes(Span<T> s) noexcept
{
return {BytePtr(s.data()), s.size_bytes()};
return {reinterpret_cast<std::byte*>(s.data()), s.size_bytes()};
}
template <typename V>
@ -272,10 +267,10 @@ Span<std::byte> MakeWritableByteSpan(V&& v) noexcept
}
// Helper functions to safely cast to unsigned char pointers.
inline unsigned char* UCharCast(char* c) { return (unsigned char*)c; }
inline unsigned char* UCharCast(char* c) { return reinterpret_cast<unsigned char*>(c); }
inline unsigned char* UCharCast(unsigned char* c) { return c; }
inline unsigned char* UCharCast(std::byte* c) { return (unsigned char*)c; }
inline const unsigned char* UCharCast(const char* c) { return (unsigned char*)c; }
inline unsigned char* UCharCast(std::byte* c) { return reinterpret_cast<unsigned char*>(c); }
inline const unsigned char* UCharCast(const char* c) { return reinterpret_cast<const unsigned char*>(c); }
inline const unsigned char* UCharCast(const unsigned char* c) { return c; }
inline const unsigned char* UCharCast(const std::byte* c) { return reinterpret_cast<const unsigned char*>(c); }

View File

@ -6,7 +6,7 @@
#ifndef BITCOIN_STATS_RAWSENDER_H
#define BITCOIN_STATS_RAWSENDER_H
#include <compat.h>
#include <compat/compat.h>
#include <sync.h>
#include <threadinterrupt.h>

View File

@ -13,11 +13,11 @@
#include <algorithm>
#include <assert.h>
#include <cstdio>
#include <ios>
#include <limits>
#include <optional>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>

View File

@ -6,7 +6,7 @@
#ifndef BITCOIN_SUPPORT_CLEANSE_H
#define BITCOIN_SUPPORT_CLEANSE_H
#include <stdlib.h>
#include <cstdlib>
/** Secure overwrite a buffer (possibly containing secret data) with zero-bytes. The write
* operation will not be optimized out by the compiler. */

View File

@ -10,9 +10,6 @@
#endif
#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#else
#include <sys/mman.h> // for mmap

1043
src/test/argsman_tests.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,13 +4,13 @@
#include <boost/test/unit_test.hpp>
#include <stdlib.h>
#include <chain.h>
#include <rpc/blockchain.h>
#include <test/util/setup_common.h>
#include <util/string.h>
#include <cstdlib>
/* Equality between doubles is imprecise. Comparison should be done
* with a small threshold of tolerance, rather than exact equality.
*/

View File

@ -16,9 +16,9 @@ BOOST_AUTO_TEST_CASE(bswap_tests)
uint16_t e1 = 0x3412;
uint32_t e2 = 0xbc9a7856;
uint64_t e3 = 0xbc9a78563412f0de;
BOOST_CHECK(bswap_16(u1) == e1);
BOOST_CHECK(bswap_32(u2) == e2);
BOOST_CHECK(bswap_64(u3) == e3);
BOOST_CHECK(internal_bswap_16(u1) == e1);
BOOST_CHECK(internal_bswap_32(u2) == e2);
BOOST_CHECK(internal_bswap_64(u3) == e3);
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -1083,28 +1083,6 @@ BOOST_AUTO_TEST_CASE(hkdf_hmac_sha256_l32_tests)
"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d");
}
BOOST_AUTO_TEST_CASE(countbits_tests)
{
FastRandomContext ctx;
for (unsigned int i = 0; i <= 64; ++i) {
if (i == 0) {
// Check handling of zero.
BOOST_CHECK_EQUAL(CountBits(0), 0U);
} else if (i < 10) {
for (uint64_t j = (uint64_t)1 << (i - 1); (j >> i) == 0; ++j) {
// Exhaustively test up to 10 bits
BOOST_CHECK_EQUAL(CountBits(j), i);
}
} else {
for (int k = 0; k < 1000; k++) {
// Randomly test 1000 samples of each length above 10 bits.
uint64_t j = ((uint64_t)1) << (i - 1) | ctx.randbits(i - 1);
BOOST_CHECK_EQUAL(CountBits(j), i);
}
}
}
}
BOOST_AUTO_TEST_CASE(sha256d64)
{
for (int i = 0; i <= 32; ++i) {

View File

@ -450,6 +450,8 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
peerLogic->Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode));
BOOST_CHECK(banman->IsDiscouraged(addr));
banman->ClearDiscouraged();
BOOST_CHECK(!banman->IsDiscouraged(addr));
peerLogic->FinalizeNode(dummyNode);
}

View File

@ -75,7 +75,6 @@ FUZZ_TARGET_INIT(integer, initialize_integer)
static const uint256 u256_max(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
const std::vector<uint256> v256{u256, u256_min, u256_max};
(void)ComputeMerkleRoot(v256);
(void)CountBits(u64);
(void)DecompressAmount(u64);
{

View File

@ -9,7 +9,7 @@
#include <attributes.h>
#include <chainparamsbase.h>
#include <coins.h>
#include <compat.h>
#include <compat/compat.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <key.h>

View File

@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <compat.h>
#include <compat/compat.h>
#include <netaddress.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <util/strencodings.h>

View File

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <compat.h>
#include <compat/compat.h>
#include <net.h>
#include <net_processing.h>
#include <netaddress.h>

View File

@ -6,7 +6,7 @@
#include <chainparams.h>
#include <clientversion.h>
#include <compat.h>
#include <compat/compat.h>
#include <net.h>
#include <net_processing.h>
#include <netaddress.h>

View File

@ -4,8 +4,8 @@
#include <event2/event.h>
#include <cstdlib>
#include <map>
#include <stdlib.h>
#include <support/events.h>

View File

@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <compat.h>
#include <compat/compat.h>
#include <test/util/setup_common.h>
#include <threadinterrupt.h>
#include <util/sock.h>

View File

@ -5,7 +5,7 @@
#ifndef BITCOIN_TEST_UTIL_NET_H
#define BITCOIN_TEST_UTIL_NET_H
#include <compat.h>
#include <compat/compat.h>
#include <net.h>
#include <net_permissions.h>
#include <net_processing.h>

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#include <timedata.h>
#include <netaddress.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/system.h>

View File

@ -7,7 +7,7 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <compat.h>
#include <compat/compat.h>
#include <crypto/hmac_sha256.h>
#include <net.h>
#include <netaddress.h>

View File

@ -6,7 +6,7 @@
#include <txdb.h>
#include <chain.h>
#include <node/ui_interface.h>
#include <node/interface_ui.h>
#include <pow.h>
#include <random.h>
#include <shutdown.h>

Some files were not shown because too many files have changed in this diff Show More