Merge bitcoin/bitcoin#31161: cmake: Set top-level target output locations

568fcdddae scripted-diff: Adjust documentation per top-level target output location (Hennadii Stepanov)
026bb226e9 cmake: Set top-level target output locations (Hennadii Stepanov)

Pull request description:

  This PR sets the target output locations to the `bin` and `lib` subdirectories within the build tree, creating a directory structure that mirrors that of the installed targets.

  This approach is widely adopted by the large projects, such as [LLVM](e146c1867e/lldb/cmake/modules/LLDBStandalone.cmake (L128-L130)):
  ```cmake
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  ```

  The `libsecp256k1` project has also recently [adopted](https://github.com/bitcoin-core/secp256k1/pull/1553) this approach.

  With this PR, all binaries are conveniently located. For example, run:
  ```
  $ ./build/bin/fuzz
  ```
  instead of:
  ```
  $ ./build/src/test/fuzz/fuzz
  ```

  On Windows, all required DLLs are now located in the same directory as the executables, allowing to run `bitcoin-chainstate.exe` (which loads `bitcoinkernel.dll`) without the need to copy DLLs or modify the `PATH` variable.

  The idea was briefly discussed among the build team during the recent CoreDev meeting.

  ---

  **Warning**: This PR changes build locations of newly built executables like `bitcoind` and `test_bitcoin` from `src/` to `bin/` without deleting previously built executables. A clean build is recommended to avoid accidentally running old binaries.

ACKs for top commit:
  theStack:
    Light re-ACK 568fcdddae
  ryanofsky:
    Code review ACK 568fcdddae. Only change since last review was rebasing. I'm ok with this PR in its current form if other developers are happy with it. I just personally think it is inappropriate to \*silently\* break an everyday developer workflow like `git pull; make bitcoind`. I wouldn't have a problem with this PR if it triggered an explicit error, or if the problem was limited to less common workflows like changing cmake options in an existing build.
  TheCharlatan:
    Re-ACK 568fcdddae
  theuni:
    ACK 568fcdddae

Tree-SHA512: 1aa5ecd3cd49bd82f1dcc96c8e171d2d19c58aec8dade4bc329df89311f9e50cbf6cf021d004c58a0e1016c375b0fa348ccd52761bcdd179c2d1e61c105e3b9f
This commit is contained in:
merge-script 2025-03-12 11:19:00 +08:00
commit 502d47203e
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
27 changed files with 164 additions and 145 deletions

View file

@ -238,10 +238,10 @@ jobs:
if: matrix.job-type == 'standard' if: matrix.job-type == 'standard'
working-directory: build working-directory: build
env: env:
BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe' BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe' BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe' BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe' BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
shell: cmd shell: cmd
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA% run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
@ -258,7 +258,7 @@ jobs:
if: matrix.job-type == 'fuzz' if: matrix.job-type == 'fuzz'
working-directory: build working-directory: build
env: env:
BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe' BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
shell: cmd shell: cmd
run: | run: |
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora

View file

@ -615,9 +615,6 @@ endif()
add_subdirectory(test) add_subdirectory(test)
add_subdirectory(doc) add_subdirectory(doc)
include(cmake/crc32c.cmake)
include(cmake/leveldb.cmake)
include(cmake/minisketch.cmake)
add_subdirectory(src) add_subdirectory(src)
include(cmake/tests.cmake) include(cmake/tests.cmake)

View file

@ -8,10 +8,10 @@ declare -A LIBS
LIBS[cli]="libbitcoin_cli.a" LIBS[cli]="libbitcoin_cli.a"
LIBS[common]="libbitcoin_common.a" LIBS[common]="libbitcoin_common.a"
LIBS[consensus]="libbitcoin_consensus.a" LIBS[consensus]="libbitcoin_consensus.a"
LIBS[crypto]="crypto/libbitcoin_crypto.a" LIBS[crypto]="libbitcoin_crypto.a"
LIBS[node]="libbitcoin_node.a" LIBS[node]="libbitcoin_node.a"
LIBS[util]="util/libbitcoin_util.a" LIBS[util]="libbitcoin_util.a"
LIBS[wallet]="wallet/libbitcoin_wallet.a" LIBS[wallet]="libbitcoin_wallet.a"
# Declare allowed dependencies "X Y" where X is allowed to depend on Y. This # Declare allowed dependencies "X Y" where X is allowed to depend on Y. This
# list is taken from doc/design/libraries.md. # list is taken from doc/design/libraries.md.
@ -187,7 +187,7 @@ fi
# shellcheck disable=SC2046 # shellcheck disable=SC2046
cmake --build "$BUILD_DIR" -j"$(nproc)" -t $(lib_targets) cmake --build "$BUILD_DIR" -j"$(nproc)" -t $(lib_targets)
TEMP_DIR="$(mktemp -d)" TEMP_DIR="$(mktemp -d)"
cd "$BUILD_DIR/src" cd "$BUILD_DIR/lib"
extract_symbols "$TEMP_DIR" extract_symbols "$TEMP_DIR"
if check_libraries "$TEMP_DIR"; then if check_libraries "$TEMP_DIR"; then
echo "Success! No unexpected dependencies were detected." echo "Success! No unexpected dependencies were detected."

View file

@ -6,7 +6,7 @@
export LC_ALL=C export LC_ALL=C
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
BUILDDIR=${BUILDDIR:-$TOPDIR/build} BUILDDIR=${BUILDDIR:-$TOPDIR/build}
BINDIR=${BINDIR:-$BUILDDIR/src} BINDIR=${BINDIR:-$BUILDDIR/bin}
BITCOIND=${BITCOIND:-$BINDIR/bitcoind} BITCOIND=${BITCOIND:-$BINDIR/bitcoind}
SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples} SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples}
EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf} EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf}

View file

@ -9,12 +9,12 @@ import tempfile
import argparse import argparse
BINARIES = [ BINARIES = [
'src/bitcoind', 'bin/bitcoind',
'src/bitcoin-cli', 'bin/bitcoin-cli',
'src/bitcoin-tx', 'bin/bitcoin-tx',
'src/bitcoin-wallet', 'bin/bitcoin-wallet',
'src/bitcoin-util', 'bin/bitcoin-util',
'src/qt/bitcoin-qt', 'bin/bitcoin-qt',
] ]
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(

View file

@ -24,7 +24,7 @@ miner
You will first need to pick a difficulty target. Since signet chains are primarily protected by a signature rather than proof of work, there is no need to spend as much energy as possible mining, however you may wish to choose to spend more time than the absolute minimum. The calibrate subcommand can be used to pick a target appropriate for your hardware, eg: You will first need to pick a difficulty target. Since signet chains are primarily protected by a signature rather than proof of work, there is no need to spend as much energy as possible mining, however you may wish to choose to spend more time than the absolute minimum. The calibrate subcommand can be used to pick a target appropriate for your hardware, eg:
MINER="./contrib/signet/miner" MINER="./contrib/signet/miner"
GRIND="./build/src/bitcoin-util grind" GRIND="./build/bin/bitcoin-util grind"
$MINER calibrate --grind-cmd="$GRIND" $MINER calibrate --grind-cmd="$GRIND"
nbits=1e00f403 for 25s average mining time nbits=1e00f403 for 25s average mining time
@ -32,7 +32,7 @@ It defaults to estimating an nbits value resulting in 25s average time to find a
To mine the first block in your custom chain, you can run: To mine the first block in your custom chain, you can run:
CLI="./build/src/bitcoin-cli -conf=mysignet.conf" CLI="./build/bin/bitcoin-cli -conf=mysignet.conf"
ADDR=$($CLI -signet getnewaddress) ADDR=$($CLI -signet getnewaddress)
NBITS=1e00f403 NBITS=1e00f403
$MINER --cli="$CLI" generate --grind-cmd="$GRIND" --address="$ADDR" --nbits=$NBITS $MINER --cli="$CLI" generate --grind-cmd="$GRIND" --address="$ADDR" --nbits=$NBITS

View file

@ -188,7 +188,7 @@ In a different terminal, starting Bitcoin Core in SigNet mode and with
re-indexing enabled. re-indexing enabled.
``` ```
$ ./build/src/bitcoind -signet -reindex $ ./build/bin/bitcoind -signet -reindex
``` ```
This produces the following output. This produces the following output.

View file

@ -16,7 +16,7 @@
This script requires a 'bitcoind' binary compiled with eBPF support and the This script requires a 'bitcoind' binary compiled with eBPF support and the
'validation:block_connected' USDT. By default, it's assumed that 'bitcoind' is 'validation:block_connected' USDT. By default, it's assumed that 'bitcoind' is
located in './build/src/bitcoind'. This can be modified in the script below. located in './build/bin/bitcoind'. This can be modified in the script below.
EXAMPLES: EXAMPLES:
@ -67,7 +67,7 @@ BEGIN
connected block is between the start and end height (or the end height is connected block is between the start and end height (or the end height is
unset). unset).
*/ */
usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/ usdt:./build/bin/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
{ {
$height = arg1; $height = arg1;
$transactions = arg2; $transactions = arg2;
@ -102,7 +102,7 @@ usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2
blocks where the time it took to connect the block is above the blocks where the time it took to connect the block is above the
<logging threshold in ms>. <logging threshold in ms>.
*/ */
usdt:./build/src/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 / usdt:./build/bin/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 /
{ {
$hash = arg0; $hash = arg0;
$height = (int32) arg1; $height = (int32) arg1;

View file

@ -5,7 +5,7 @@ BEGIN
printf("Logging opened, closed, misbehaving, and evicted P2P connections\n") printf("Logging opened, closed, misbehaving, and evicted P2P connections\n")
} }
usdt:./build/src/bitcoind:net:inbound_connection usdt:./build/bin/bitcoind:net:inbound_connection
{ {
$id = (int64) arg0; $id = (int64) arg0;
$addr = str(arg1); $addr = str(arg1);
@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_connection
printf("INBOUND conn from %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing); printf("INBOUND conn from %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
} }
usdt:./build/src/bitcoind:net:outbound_connection usdt:./build/bin/bitcoind:net:outbound_connection
{ {
$id = (int64) arg0; $id = (int64) arg0;
$addr = str(arg1); $addr = str(arg1);
@ -25,7 +25,7 @@ usdt:./build/src/bitcoind:net:outbound_connection
printf("OUTBOUND conn to %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing); printf("OUTBOUND conn to %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
} }
usdt:./build/src/bitcoind:net:closed_connection usdt:./build/bin/bitcoind:net:closed_connection
{ {
$id = (int64) arg0; $id = (int64) arg0;
$addr = str(arg1); $addr = str(arg1);
@ -34,7 +34,7 @@ usdt:./build/src/bitcoind:net:closed_connection
printf("CLOSED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4); printf("CLOSED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
} }
usdt:./build/src/bitcoind:net:evicted_inbound_connection usdt:./build/bin/bitcoind:net:evicted_inbound_connection
{ {
$id = (int64) arg0; $id = (int64) arg0;
$addr = str(arg1); $addr = str(arg1);
@ -43,7 +43,7 @@ usdt:./build/src/bitcoind:net:evicted_inbound_connection
printf("EVICTED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4); printf("EVICTED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
} }
usdt:./build/src/bitcoind:net:misbehaving_connection usdt:./build/bin/bitcoind:net:misbehaving_connection
{ {
$id = (int64) arg0; $id = (int64) arg0;
$message = str(arg1); $message = str(arg1);

View file

@ -5,7 +5,7 @@ BEGIN
printf("Logging P2P traffic\n") printf("Logging P2P traffic\n")
} }
usdt:./build/src/bitcoind:net:inbound_message usdt:./build/bin/bitcoind:net:inbound_message
{ {
$peer_id = (int64) arg0; $peer_id = (int64) arg0;
$peer_addr = str(arg1); $peer_addr = str(arg1);
@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_message
printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len); printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len);
} }
usdt:./build/src/bitcoind:net:outbound_message usdt:./build/bin/bitcoind:net:outbound_message
{ {
$peer_id = (int64) arg0; $peer_id = (int64) arg0;
$peer_addr = str(arg1); $peer_addr = str(arg1);

View file

@ -8,7 +8,7 @@
This script requires a 'bitcoind' binary compiled with eBPF support and the This script requires a 'bitcoind' binary compiled with eBPF support and the
'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is 'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is
located in './build/src/bitcoind'. This can be modified in the script below. located in './build/bin/bitcoind'. This can be modified in the script below.
NOTE: requires bpftrace v0.12.0 or above. NOTE: requires bpftrace v0.12.0 or above.
*/ */
@ -22,7 +22,7 @@ BEGIN
/* /*
Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache. Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache.
*/ */
usdt:./build/src/bitcoind:utxocache:add usdt:./build/bin/bitcoind:utxocache:add
{ {
$txid = arg0; $txid = arg0;
$index = (uint32)arg1; $index = (uint32)arg1;
@ -44,7 +44,7 @@ usdt:./build/src/bitcoind:utxocache:add
/* /*
Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache. Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache.
*/ */
usdt:./build/src/bitcoind:utxocache:spent usdt:./build/bin/bitcoind:utxocache:spent
{ {
$txid = arg0; $txid = arg0;
$index = (uint32)arg1; $index = (uint32)arg1;
@ -66,7 +66,7 @@ usdt:./build/src/bitcoind:utxocache:spent
/* /*
Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache. Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache.
*/ */
usdt:./build/src/bitcoind:utxocache:uncache usdt:./build/bin/bitcoind:utxocache:uncache
{ {
$txid = arg0; $txid = arg0;
$index = (uint32)arg1; $index = (uint32)arg1;

View file

@ -2,14 +2,14 @@
# dependencies that cannot be fixed in-tree. # dependencies that cannot be fixed in-tree.
# #
# Example use: # Example use:
# $ valgrind --suppressions=contrib/valgrind.supp build/src/test/test_bitcoin # $ valgrind --suppressions=contrib/valgrind.supp build/bin/test_bitcoin
# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ # $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
# --show-leak-kinds=all build/src/test/test_bitcoin # --show-leak-kinds=all build/bin/test_bitcoin
# #
# To create suppressions for found issues, use the --gen-suppressions=all option: # To create suppressions for found issues, use the --gen-suppressions=all option:
# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ # $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
# --show-leak-kinds=all --gen-suppressions=all --show-reachable=yes \ # --show-leak-kinds=all --gen-suppressions=all --show-reachable=yes \
# --error-limit=no build/src/test/test_bitcoin # --error-limit=no build/bin/test_bitcoin
# #
# Note that suppressions may depend on OS and/or library versions. # Note that suppressions may depend on OS and/or library versions.
# Tested on: # Tested on:

View file

@ -18,7 +18,7 @@ and lock analysis.
After compiling bitcoin-core, the benchmarks can be run with: After compiling bitcoin-core, the benchmarks can be run with:
build/src/bench/bench_bitcoin build/bin/bench_bitcoin
The output will look similar to: The output will look similar to:
``` ```
@ -40,7 +40,7 @@ The output will look similar to:
Help Help
--------------------- ---------------------
build/src/bench/bench_bitcoin -h build/bin/bench_bitcoin -h
To print the various options, like listing the benchmarks without running them To print the various options, like listing the benchmarks without running them
or using a regex filter to only run certain benchmarks. or using a regex filter to only run certain benchmarks.

View file

@ -201,8 +201,8 @@ cmake --build build --target deploy
## Running Bitcoin Core ## Running Bitcoin Core
Bitcoin Core should now be available at `./build/src/bitcoind`. Bitcoin Core should now be available at `./build/bin/bitcoind`.
If you compiled support for the GUI, it should be available at `./build/src/qt/bitcoin-qt`. If you compiled support for the GUI, it should be available at `./build/bin/bitcoin-qt`.
The first time you run `bitcoind` or `bitcoin-qt`, it will start downloading the blockchain. The first time you run `bitcoind` or `bitcoin-qt`, it will start downloading the blockchain.
This process could take many hours, or even days on slower than average systems. This process could take many hours, or even days on slower than average systems.
@ -232,8 +232,8 @@ tail -f $HOME/Library/Application\ Support/Bitcoin/debug.log
## Other commands: ## Other commands:
```shell ```shell
./build/src/bitcoind -daemon # Starts the bitcoin daemon. ./build/bin/bitcoind -daemon # Starts the bitcoin daemon.
./build/src/bitcoin-cli --help # Outputs a list of command-line options. ./build/bin/bitcoin-cli --help # Outputs a list of command-line options.
./build/src/bitcoin-cli help # Outputs a list of RPC commands when the daemon is running. ./build/bin/bitcoin-cli help # Outputs a list of RPC commands when the daemon is running.
./build/src/qt/bitcoin-qt -server # Starts the bitcoin-qt server mode, allows bitcoin-cli control ./build/bin/bitcoin-qt -server # Starts the bitcoin-qt server mode, allows bitcoin-cli control
``` ```

View file

@ -188,6 +188,6 @@ This example lists the steps necessary to setup and build a command line only di
cmake -B build cmake -B build
cmake --build build cmake --build build
ctest --test-dir build ctest --test-dir build
./build/src/bitcoind ./build/bin/bitcoind
If you intend to work with legacy Berkeley DB wallets, see [Berkeley DB](#berkeley-db) section. If you intend to work with legacy Berkeley DB wallets, see [Berkeley DB](#berkeley-db) section.

View file

@ -475,10 +475,10 @@ which includes known Valgrind warnings in our dependencies that cannot be fixed
in-tree. Example use: in-tree. Example use:
```shell ```shell
$ valgrind --suppressions=contrib/valgrind.supp build/src/test/test_bitcoin $ valgrind --suppressions=contrib/valgrind.supp build/bin/test_bitcoin
$ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
--show-leak-kinds=all build/src/test/test_bitcoin --log_level=test_suite --show-leak-kinds=all build/bin/test_bitcoin --log_level=test_suite
$ valgrind -v --leak-check=full build/src/bitcoind -printtoconsole $ valgrind -v --leak-check=full build/bin/bitcoind -printtoconsole
$ ./build/test/functional/test_runner.py --valgrind $ ./build/test/functional/test_runner.py --valgrind
``` ```

View file

@ -11,7 +11,7 @@ $ cmake --preset=libfuzzer
# macOS users: If you have problem with this step then make sure to read "macOS hints for # macOS users: If you have problem with this step then make sure to read "macOS hints for
# libFuzzer" on https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer # libFuzzer" on https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer
$ cmake --build build_fuzz $ cmake --build build_fuzz
$ FUZZ=process_message build_fuzz/src/test/fuzz/fuzz $ FUZZ=process_message build_fuzz/bin/fuzz
# abort fuzzing using ctrl-c # abort fuzzing using ctrl-c
``` ```
@ -35,7 +35,7 @@ If you specify a corpus directory then any new coverage increasing inputs will b
```sh ```sh
$ mkdir -p process_message-seeded-from-thin-air/ $ mkdir -p process_message-seeded-from-thin-air/
$ FUZZ=process_message build_fuzz/src/test/fuzz/fuzz process_message-seeded-from-thin-air/ $ FUZZ=process_message build_fuzz/bin/fuzz process_message-seeded-from-thin-air/
INFO: Seed: 840522292 INFO: Seed: 840522292
INFO: Loaded 1 modules (424174 inline 8-bit counters): 424174 [0x55e121ef9ab8, 0x55e121f613a6), INFO: Loaded 1 modules (424174 inline 8-bit counters): 424174 [0x55e121ef9ab8, 0x55e121f613a6),
INFO: Loaded 1 PC tables (424174 PCs): 424174 [0x55e121f613a8,0x55e1225da288), INFO: Loaded 1 PC tables (424174 PCs): 424174 [0x55e121f613a8,0x55e1225da288),
@ -79,7 +79,7 @@ of the test. Just make sure to use double-dash to distinguish them from the
fuzzer's own arguments: fuzzer's own arguments:
```sh ```sh
$ FUZZ=address_deserialize_v2 build_fuzz/src/test/fuzz/fuzz -runs=1 fuzz_corpora/address_deserialize_v2 --checkaddrman=5 --printtoconsole=1 $ FUZZ=address_deserialize_v2 build_fuzz/bin/fuzz -runs=1 fuzz_corpora/address_deserialize_v2 --checkaddrman=5 --printtoconsole=1
``` ```
## Fuzzing corpora ## Fuzzing corpora
@ -90,7 +90,7 @@ To fuzz `process_message` using the [`bitcoin-core/qa-assets`](https://github.co
```sh ```sh
$ git clone https://github.com/bitcoin-core/qa-assets $ git clone https://github.com/bitcoin-core/qa-assets
$ FUZZ=process_message build_fuzz/src/test/fuzz/fuzz qa-assets/fuzz_corpora/process_message/ $ FUZZ=process_message build_fuzz/bin/fuzz qa-assets/fuzz_corpora/process_message/
INFO: Seed: 1346407872 INFO: Seed: 1346407872
INFO: Loaded 1 modules (424174 inline 8-bit counters): 424174 [0x55d8a9004ab8, 0x55d8a906c3a6), INFO: Loaded 1 modules (424174 inline 8-bit counters): 424174 [0x55d8a9004ab8, 0x55d8a906c3a6),
INFO: Loaded 1 PC tables (424174 PCs): 424174 [0x55d8a906c3a8,0x55d8a96e5288), INFO: Loaded 1 PC tables (424174 PCs): 424174 [0x55d8a906c3a8,0x55d8a96e5288),
@ -134,7 +134,7 @@ Patience is useful; even with improved throughput, libFuzzer may need days and
more slowly with sanitizers enabled, but a crash should be reproducible very more slowly with sanitizers enabled, but a crash should be reproducible very
quickly from a crash case) quickly from a crash case)
- run the fuzzer with the case number appended to the seed corpus path: - run the fuzzer with the case number appended to the seed corpus path:
`FUZZ=process_message build_fuzz/src/test/fuzz/fuzz `FUZZ=process_message build_fuzz/bin/fuzz
qa-assets/fuzz_corpora/process_message/1bc91feec9fc00b107d97dc225a9f2cdaa078eb6` qa-assets/fuzz_corpora/process_message/1bc91feec9fc00b107d97dc225a9f2cdaa078eb6`
## Submit improved coverage ## Submit improved coverage
@ -189,7 +189,7 @@ $ cmake --build build_fuzz
# try compiling using: AFL_NO_X86=1 cmake --build build_fuzz # try compiling using: AFL_NO_X86=1 cmake --build build_fuzz
$ mkdir -p inputs/ outputs/ $ mkdir -p inputs/ outputs/
$ echo A > inputs/thin-air-input $ echo A > inputs/thin-air-input
$ FUZZ=bech32 ./AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- build_fuzz/src/test/fuzz/fuzz $ FUZZ=bech32 ./AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- build_fuzz/bin/fuzz
# You may have to change a few kernel parameters to test optimally - afl-fuzz # You may have to change a few kernel parameters to test optimally - afl-fuzz
# will print an error and suggestion if so. # will print an error and suggestion if so.
``` ```
@ -216,7 +216,7 @@ $ cmake -B build_fuzz \
-DSANITIZERS=address,undefined -DSANITIZERS=address,undefined
$ cmake --build build_fuzz $ cmake --build build_fuzz
$ mkdir -p inputs/ $ mkdir -p inputs/
$ FUZZ=process_message ./honggfuzz/honggfuzz -i inputs/ -- build_fuzz/src/test/fuzz/fuzz $ FUZZ=process_message ./honggfuzz/honggfuzz -i inputs/ -- build_fuzz/bin/fuzz
``` ```
Read the [Honggfuzz documentation](https://github.com/google/honggfuzz/blob/master/docs/USAGE.md) for more information. Read the [Honggfuzz documentation](https://github.com/google/honggfuzz/blob/master/docs/USAGE.md) for more information.

View file

@ -21,8 +21,8 @@ make -C depends NO_QT=1 MULTIPROCESS=1
HOST_PLATFORM="x86_64-pc-linux-gnu" HOST_PLATFORM="x86_64-pc-linux-gnu"
cmake -B build --toolchain=depends/$HOST_PLATFORM/toolchain.cmake cmake -B build --toolchain=depends/$HOST_PLATFORM/toolchain.cmake
cmake --build build cmake --build build
build/src/bitcoin-node -regtest -printtoconsole -debug=ipc build/bin/bitcoin-node -regtest -printtoconsole -debug=ipc
BITCOIND=$(pwd)/build/src/bitcoin-node build/test/functional/test_runner.py BITCOIND=$(pwd)/build/bin/bitcoin-node build/test/functional/test_runner.py
``` ```
The `cmake` build will pick up settings and library locations from the depends directory, so there is no need to pass `-DWITH_MULTIPROCESS=ON` as a separate flag when using the depends system (it's controlled by the `MULTIPROCESS=1` option). The `cmake` build will pick up settings and library locations from the depends directory, so there is no need to pass `-DWITH_MULTIPROCESS=ON` as a separate flag when using the depends system (it's controlled by the `MULTIPROCESS=1` option).

View file

@ -9,7 +9,7 @@ This tutorial uses [jq](https://github.com/stedolan/jq) JSON processor to proces
Before starting this tutorial, start the bitcoin node on the signet network. Before starting this tutorial, start the bitcoin node on the signet network.
```bash ```bash
./build/src/bitcoind -signet -daemon ./build/bin/bitcoind -signet -daemon
``` ```
This tutorial also uses the default WPKH derivation path to get the xpubs and does not conform to [BIP 45](https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki) or [BIP 87](https://github.com/bitcoin/bips/blob/master/bip-0087.mediawiki). This tutorial also uses the default WPKH derivation path to get the xpubs and does not conform to [BIP 45](https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki) or [BIP 87](https://github.com/bitcoin/bips/blob/master/bip-0087.mediawiki).
@ -27,7 +27,7 @@ These three wallets should not be used directly for privacy reasons (public key
```bash ```bash
for ((n=1;n<=3;n++)) for ((n=1;n<=3;n++))
do do
./build/src/bitcoin-cli -signet createwallet "participant_${n}" ./build/bin/bitcoin-cli -signet createwallet "participant_${n}"
done done
``` ```
@ -47,9 +47,9 @@ declare -A xpubs
for ((n=1;n<=3;n++)) for ((n=1;n<=3;n++))
do do
xpubs["internal_xpub_${n}"]=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/1/*"))][0] | .desc' | grep -Po '(?<=\().*(?=\))') xpubs["internal_xpub_${n}"]=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/1/*"))][0] | .desc' | grep -Po '(?<=\().*(?=\))')
xpubs["external_xpub_${n}"]=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/0/*") )][0] | .desc' | grep -Po '(?<=\().*(?=\))') xpubs["external_xpub_${n}"]=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/0/*") )][0] | .desc' | grep -Po '(?<=\().*(?=\))')
done done
``` ```
@ -71,8 +71,8 @@ Define the external and internal multisig descriptors, add the checksum and then
external_desc="wsh(sortedmulti(2,${xpubs["external_xpub_1"]},${xpubs["external_xpub_2"]},${xpubs["external_xpub_3"]}))" external_desc="wsh(sortedmulti(2,${xpubs["external_xpub_1"]},${xpubs["external_xpub_2"]},${xpubs["external_xpub_3"]}))"
internal_desc="wsh(sortedmulti(2,${xpubs["internal_xpub_1"]},${xpubs["internal_xpub_2"]},${xpubs["internal_xpub_3"]}))" internal_desc="wsh(sortedmulti(2,${xpubs["internal_xpub_1"]},${xpubs["internal_xpub_2"]},${xpubs["internal_xpub_3"]}))"
external_desc_sum=$(./build/src/bitcoin-cli -signet getdescriptorinfo $external_desc | jq '.descriptor') external_desc_sum=$(./build/bin/bitcoin-cli -signet getdescriptorinfo $external_desc | jq '.descriptor')
internal_desc_sum=$(./build/src/bitcoin-cli -signet getdescriptorinfo $internal_desc | jq '.descriptor') internal_desc_sum=$(./build/bin/bitcoin-cli -signet getdescriptorinfo $internal_desc | jq '.descriptor')
multisig_ext_desc="{\"desc\": $external_desc_sum, \"active\": true, \"internal\": false, \"timestamp\": \"now\"}" multisig_ext_desc="{\"desc\": $external_desc_sum, \"active\": true, \"internal\": false, \"timestamp\": \"now\"}"
multisig_int_desc="{\"desc\": $internal_desc_sum, \"active\": true, \"internal\": true, \"timestamp\": \"now\"}" multisig_int_desc="{\"desc\": $internal_desc_sum, \"active\": true, \"internal\": true, \"timestamp\": \"now\"}"
@ -94,7 +94,7 @@ There are other fields that can be added to the descriptors:
* `internal`: Indicates whether matching outputs should be treated as something other than incoming payments (e.g. change). * `internal`: Indicates whether matching outputs should be treated as something other than incoming payments (e.g. change).
* `timestamp`: Sets the time from which to start rescanning the blockchain for the descriptor, in UNIX epoch time. * `timestamp`: Sets the time from which to start rescanning the blockchain for the descriptor, in UNIX epoch time.
Documentation for these and other parameters can be found by typing `./build/src/bitcoin-cli help importdescriptors`. Documentation for these and other parameters can be found by typing `./build/bin/bitcoin-cli help importdescriptors`.
`multisig_desc` concatenates external and internal descriptors in a JSON array and then it will be used to create the multisig wallet. `multisig_desc` concatenates external and internal descriptors in a JSON array and then it will be used to create the multisig wallet.
@ -107,17 +107,17 @@ Then import the descriptors created in the previous step using the `importdescri
After that, `getwalletinfo` can be used to check if the wallet was created successfully. After that, `getwalletinfo` can be used to check if the wallet was created successfully.
```bash ```bash
./build/src/bitcoin-cli -signet -named createwallet wallet_name="multisig_wallet_01" disable_private_keys=true blank=true ./build/bin/bitcoin-cli -signet -named createwallet wallet_name="multisig_wallet_01" disable_private_keys=true blank=true
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" importdescriptors "$multisig_desc" ./build/bin/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" importdescriptors "$multisig_desc"
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getwalletinfo ./build/bin/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getwalletinfo
``` ```
Once the wallets have already been created and this tutorial needs to be repeated or resumed, it is not necessary to recreate them, just load them with the command below: Once the wallets have already been created and this tutorial needs to be repeated or resumed, it is not necessary to recreate them, just load them with the command below:
```bash ```bash
for ((n=1;n<=3;n++)); do ./build/src/bitcoin-cli -signet loadwallet "participant_${n}"; done for ((n=1;n<=3;n++)); do ./build/bin/bitcoin-cli -signet loadwallet "participant_${n}"; done
``` ```
### 1.4 Fund the wallet ### 1.4 Fund the wallet
@ -131,9 +131,9 @@ The url used by the script can also be accessed directly. At time of writing, th
Coins received by the wallet must have at least 1 confirmation before they can be spent. It is necessary to wait for a new block to be mined before continuing. Coins received by the wallet must have at least 1 confirmation before they can be spent. It is necessary to wait for a new block to be mined before continuing.
```bash ```bash
receiving_address=$(./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getnewaddress) receiving_address=$(./build/bin/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getnewaddress)
./contrib/signet/getcoins.py -c ./build/src/bitcoin-cli -a $receiving_address ./contrib/signet/getcoins.py -c ./build/bin/bitcoin-cli -a $receiving_address
``` ```
To copy the receiving address onto the clipboard, use the following command. This can be useful when getting coins via the signet faucet mentioned above. To copy the receiving address onto the clipboard, use the following command. This can be useful when getting coins via the signet faucet mentioned above.
@ -145,7 +145,7 @@ echo -n "$receiving_address" | xclip -sel clip
The `getbalances` RPC may be used to check the balance. Coins with `trusted` status can be spent. The `getbalances` RPC may be used to check the balance. Coins with `trusted` status can be spent.
```bash ```bash
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalances ./build/bin/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalances
``` ```
### 1.5 Create a PSBT ### 1.5 Create a PSBT
@ -161,13 +161,13 @@ For simplicity, the destination address is taken from the `participant_1` wallet
The `walletcreatefundedpsbt` RPC is used to create and fund a transaction in the PSBT format. It is the first step in creating the PSBT. The `walletcreatefundedpsbt` RPC is used to create and fund a transaction in the PSBT format. It is the first step in creating the PSBT.
```bash ```bash
balance=$(./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalance) balance=$(./build/bin/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalance)
amount=$(echo "$balance * 0.8" | bc -l | sed -e 's/^\./0./' -e 's/^-\./-0./') amount=$(echo "$balance * 0.8" | bc -l | sed -e 's/^\./0./' -e 's/^-\./-0./')
destination_addr=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" getnewaddress) destination_addr=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_1" getnewaddress)
funded_psbt=$(./build/src/bitcoin-cli -signet -named -rpcwallet="multisig_wallet_01" walletcreatefundedpsbt outputs="{\"$destination_addr\": $amount}" | jq -r '.psbt') funded_psbt=$(./build/bin/bitcoin-cli -signet -named -rpcwallet="multisig_wallet_01" walletcreatefundedpsbt outputs="{\"$destination_addr\": $amount}" | jq -r '.psbt')
``` ```
There is also the `createpsbt` RPC, which serves the same purpose, but it has no access to the wallet or to the UTXO set. It is functionally the same as `createrawtransaction` and just drops the raw transaction into an otherwise blank PSBT. [[source](https://bitcointalk.org/index.php?topic=5131043.msg50573609#msg50573609)] In most cases, `walletcreatefundedpsbt` solves the problem. There is also the `createpsbt` RPC, which serves the same purpose, but it has no access to the wallet or to the UTXO set. It is functionally the same as `createrawtransaction` and just drops the raw transaction into an otherwise blank PSBT. [[source](https://bitcointalk.org/index.php?topic=5131043.msg50573609#msg50573609)] In most cases, `walletcreatefundedpsbt` solves the problem.
@ -181,9 +181,9 @@ Optionally, the PSBT can be decoded to a JSON format using `decodepsbt` RPC.
The `analyzepsbt` RPC analyzes and provides information about the current status of a PSBT and its inputs, e.g. missing signatures. The `analyzepsbt` RPC analyzes and provides information about the current status of a PSBT and its inputs, e.g. missing signatures.
```bash ```bash
./build/src/bitcoin-cli -signet decodepsbt $funded_psbt ./build/bin/bitcoin-cli -signet decodepsbt $funded_psbt
./build/src/bitcoin-cli -signet analyzepsbt $funded_psbt ./build/bin/bitcoin-cli -signet analyzepsbt $funded_psbt
``` ```
### 1.7 Update the PSBT ### 1.7 Update the PSBT
@ -193,9 +193,9 @@ In the code above, two PSBTs are created. One signed by `participant_1` wallet a
The `walletprocesspsbt` is used by the wallet to sign a PSBT. The `walletprocesspsbt` is used by the wallet to sign a PSBT.
```bash ```bash
psbt_1=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq '.psbt') psbt_1=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq '.psbt')
psbt_2=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $funded_psbt | jq '.psbt') psbt_2=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $funded_psbt | jq '.psbt')
``` ```
### 1.8 Combine the PSBT ### 1.8 Combine the PSBT
@ -203,7 +203,7 @@ psbt_2=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_2" walletproces
The PSBT, if signed separately by the co-signers, must be combined into one transaction before being finalized. This is done by `combinepsbt` RPC. The PSBT, if signed separately by the co-signers, must be combined into one transaction before being finalized. This is done by `combinepsbt` RPC.
```bash ```bash
combined_psbt=$(./build/src/bitcoin-cli -signet combinepsbt "[$psbt_1, $psbt_2]") combined_psbt=$(./build/bin/bitcoin-cli -signet combinepsbt "[$psbt_1, $psbt_2]")
``` ```
There is an RPC called `joinpsbts`, but it has a different purpose than `combinepsbt`. `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT. There is an RPC called `joinpsbts`, but it has a different purpose than `combinepsbt`. `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT.
@ -217,9 +217,9 @@ The `finalizepsbt` RPC is used to produce a network serialized transaction which
It checks that all inputs have complete scriptSigs and scriptWitnesses and, if so, encodes them into network serialized transactions. It checks that all inputs have complete scriptSigs and scriptWitnesses and, if so, encodes them into network serialized transactions.
```bash ```bash
finalized_psbt_hex=$(./build/src/bitcoin-cli -signet finalizepsbt $combined_psbt | jq -r '.hex') finalized_psbt_hex=$(./build/bin/bitcoin-cli -signet finalizepsbt $combined_psbt | jq -r '.hex')
./build/src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex ./build/bin/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
``` ```
### 1.10 Alternative Workflow (PSBT sequential signatures) ### 1.10 Alternative Workflow (PSBT sequential signatures)
@ -229,11 +229,11 @@ Instead of each wallet signing the original PSBT and combining them later, the w
After that, the rest of the process is the same: the PSBT is finalized and transmitted to the network. After that, the rest of the process is the same: the PSBT is finalized and transmitted to the network.
```bash ```bash
psbt_1=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq -r '.psbt') psbt_1=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq -r '.psbt')
psbt_2=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $psbt_1 | jq -r '.psbt') psbt_2=$(./build/bin/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $psbt_1 | jq -r '.psbt')
finalized_psbt_hex=$(./build/src/bitcoin-cli -signet finalizepsbt $psbt_2 | jq -r '.hex') finalized_psbt_hex=$(./build/bin/bitcoin-cli -signet finalizepsbt $psbt_2 | jq -r '.hex')
./build/src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex ./build/bin/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
``` ```

View file

@ -25,7 +25,7 @@ We are going to first create an `offline_wallet` on the offline host. We will th
1. On the offline machine create a wallet named `offline_wallet` secured by a wallet `passphrase`. This wallet will contain private keys and must remain unconnected to any networks at all times. 1. On the offline machine create a wallet named `offline_wallet` secured by a wallet `passphrase`. This wallet will contain private keys and must remain unconnected to any networks at all times.
```sh ```sh
[offline]$ ./build/src/bitcoin-cli -signet -named createwallet \ [offline]$ ./build/bin/bitcoin-cli -signet -named createwallet \
wallet_name="offline_wallet" \ wallet_name="offline_wallet" \
passphrase="** enter passphrase **" passphrase="** enter passphrase **"
@ -40,7 +40,7 @@ We are going to first create an `offline_wallet` on the offline host. We will th
2. Export the public key-only descriptors from the offline host to a JSON file named `descriptors.json`. We use `jq` here to extract the `.descriptors` field from the full RPC response. 2. Export the public key-only descriptors from the offline host to a JSON file named `descriptors.json`. We use `jq` here to extract the `.descriptors` field from the full RPC response.
```sh ```sh
[offline]$ ./build/src/bitcoin-cli -signet -rpcwallet="offline_wallet" listdescriptors \ [offline]$ ./build/bin/bitcoin-cli -signet -rpcwallet="offline_wallet" listdescriptors \
| jq -r '.descriptors' \ | jq -r '.descriptors' \
>> /path/to/descriptors.json >> /path/to/descriptors.json
``` ```
@ -58,7 +58,7 @@ The `watch_only_wallet` wallet will be used to track and validate incoming trans
> `disable_private_keys` indicates that the wallet should refuse to import private keys, i.e. will be a dedicated watch-only wallet. > `disable_private_keys` indicates that the wallet should refuse to import private keys, i.e. will be a dedicated watch-only wallet.
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -named createwallet \ [online]$ ./build/bin/bitcoin-cli -signet -named createwallet \
wallet_name="watch_only_wallet" \ wallet_name="watch_only_wallet" \
disable_private_keys=true \ disable_private_keys=true \
blank=true blank=true
@ -71,7 +71,7 @@ The `watch_only_wallet` wallet will be used to track and validate incoming trans
2. Import the `offline_wallet`s public key descriptors to the online `watch_only_wallet` using the `descriptors.json` file created on the offline wallet. 2. Import the `offline_wallet`s public key descriptors to the online `watch_only_wallet` using the `descriptors.json` file created on the offline wallet.
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" importdescriptors "$(cat /path/to/descriptors.json)" [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" importdescriptors "$(cat /path/to/descriptors.json)"
[ [
{ {
@ -110,7 +110,7 @@ At this point, it's important to understand that both the `offline_wallet` and o
1. Generate an address to receive coins. You can use _either_ the `offline_wallet` or the online `watch_only_wallet` to generate this address, as they will produce the same addresses. For the sake of this guide, we'll use the online `watch_only_wallet` to generate the address. 1. Generate an address to receive coins. You can use _either_ the `offline_wallet` or the online `watch_only_wallet` to generate this address, as they will produce the same addresses. For the sake of this guide, we'll use the online `watch_only_wallet` to generate the address.
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" getnewaddress [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" getnewaddress
tb1qtu5qgc6ddhmqm5yqjvhg83qgk2t4ewajg0h6yh tb1qtu5qgc6ddhmqm5yqjvhg83qgk2t4ewajg0h6yh
``` ```
@ -120,7 +120,7 @@ tb1qtu5qgc6ddhmqm5yqjvhg83qgk2t4ewajg0h6yh
3. Confirm that coins were received using the online `watch_only_wallet`. Note that the transaction may take a few moments before being received on your local node, depending on its connectivity. Just re-run the command periodically until the transaction is received. 3. Confirm that coins were received using the online `watch_only_wallet`. Note that the transaction may take a few moments before being received on your local node, depending on its connectivity. Just re-run the command periodically until the transaction is received.
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" listunspent [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" listunspent
[ [
{ {
@ -149,7 +149,7 @@ tb1qtu5qgc6ddhmqm5yqjvhg83qgk2t4ewajg0h6yh
2. Create a funded but unsigned PSBT to the destination address with the online `watch_only_wallet` by using `send [{"address":amount},...]` and export the unsigned PSBT to a file `funded_psbt.txt` for easy portability to the `offline_wallet` for signing: 2. Create a funded but unsigned PSBT to the destination address with the online `watch_only_wallet` by using `send [{"address":amount},...]` and export the unsigned PSBT to a file `funded_psbt.txt` for easy portability to the `offline_wallet` for signing:
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" send \ [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" send \
'{"tb1q9k5w0nhnhyeh78snpxh0t5t7c3lxdeg3erez32": 0.009}' \ '{"tb1q9k5w0nhnhyeh78snpxh0t5t7c3lxdeg3erez32": 0.009}' \
| jq -r '.psbt' \ | jq -r '.psbt' \
>> /path/to/funded_psbt.txt >> /path/to/funded_psbt.txt
@ -166,13 +166,13 @@ cHNidP8BAHECAAAAAWLHKR9/xAjetzL/FCmZU5lbfINRMWPRPHWO68PfUzkPAQAAAAD9////AoA4AQAA
Decode and analyze the unsigned PSBT on the `offline_wallet` using the `funded_psbt.txt` file: Decode and analyze the unsigned PSBT on the `offline_wallet` using the `funded_psbt.txt` file:
```sh ```sh
[offline]$ ./build/src/bitcoin-cli -signet decodepsbt $(cat /path/to/funded_psbt.txt) [offline]$ ./build/bin/bitcoin-cli -signet decodepsbt $(cat /path/to/funded_psbt.txt)
{ {
... ...
} }
[offline]$ ./build/src/bitcoin-cli -signet analyzepsbt $(cat /path/to/funded_psbt.txt) [offline]$ ./build/bin/bitcoin-cli -signet analyzepsbt $(cat /path/to/funded_psbt.txt)
{ {
"inputs": [ "inputs": [
@ -203,13 +203,13 @@ Notice that the analysis of the PSBT shows that "signatures" are missing and sho
Use the walletpassphrase command to unlock the `offline_wallet` with the passphrase. You should specify the passphrase and a timeout (in seconds) for how long you want the wallet to remain unlocked. Use the walletpassphrase command to unlock the `offline_wallet` with the passphrase. You should specify the passphrase and a timeout (in seconds) for how long you want the wallet to remain unlocked.
```sh ```sh
[offline]$ ./build/src/bitcoin-cli -signet -rpcwallet="offline_wallet" walletpassphrase "** enter passphrase **" 60 [offline]$ ./build/bin/bitcoin-cli -signet -rpcwallet="offline_wallet" walletpassphrase "** enter passphrase **" 60
``` ```
2. Process, sign and finalize the PSBT on the `offline_wallet` using the `walletprocesspsbt` command, saving the output to a file `final_psbt.txt`. 2. Process, sign and finalize the PSBT on the `offline_wallet` using the `walletprocesspsbt` command, saving the output to a file `final_psbt.txt`.
```sh ```sh
[offline]$ ./build/src/bitcoin-cli -signet -rpcwallet="offline_wallet" walletprocesspsbt \ [offline]$ ./build/bin/bitcoin-cli -signet -rpcwallet="offline_wallet" walletprocesspsbt \
$(cat /path/to/funded_psbt.txt) \ $(cat /path/to/funded_psbt.txt) \
| jq -r .hex \ | jq -r .hex \
>> /path/to/final_psbt.txt >> /path/to/final_psbt.txt
@ -219,7 +219,7 @@ Use the walletpassphrase command to unlock the `offline_wallet` with the passphr
Broadcast the funded, signed and finalized PSBT `final_psbt.txt` using `sendrawtransaction` with an online node: Broadcast the funded, signed and finalized PSBT `final_psbt.txt` using `sendrawtransaction` with an online node:
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet sendrawtransaction $(cat /path/to/final_psbt.txt) [online]$ ./build/bin/bitcoin-cli -signet sendrawtransaction $(cat /path/to/final_psbt.txt)
c2430a0e46df472b04b0ca887bbcd5c4abf7b2ce2eb71de981444a80e2b96d52 c2430a0e46df472b04b0ca887bbcd5c4abf7b2ce2eb71de981444a80e2b96d52
``` ```
@ -229,7 +229,7 @@ c2430a0e46df472b04b0ca887bbcd5c4abf7b2ce2eb71de981444a80e2b96d52
Confirm the updated balance of the offline wallet using the `watch_only_wallet`. Confirm the updated balance of the offline wallet using the `watch_only_wallet`.
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" getbalances [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" getbalances
{ {
"mine": { "mine": {
@ -248,7 +248,7 @@ Confirm the updated balance of the offline wallet using the `watch_only_wallet`.
You can also show transactions related to the wallet using `listtransactions` You can also show transactions related to the wallet using `listtransactions`
```sh ```sh
[online]$ ./build/src/bitcoin-cli -signet -rpcwallet="watch_only_wallet" listtransactions [online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" listtransactions
{ {
... ...

View file

@ -430,13 +430,13 @@ USDT support.
To list probes in Bitcoin Core, use `info probes` in `gdb`: To list probes in Bitcoin Core, use `info probes` in `gdb`:
``` ```
$ gdb ./build/src/bitcoind $ gdb ./build/bin/bitcoind
(gdb) info probes (gdb) info probes
Type Provider Name Where Semaphore Object Type Provider Name Where Semaphore Object
stap net inbound_message 0x000000000014419e 0x0000000000d29bd2 /build/src/bitcoind stap net inbound_message 0x000000000014419e 0x0000000000d29bd2 /build/bin/bitcoind
stap net outbound_message 0x0000000000107c05 0x0000000000d29bd0 /build/src/bitcoind stap net outbound_message 0x0000000000107c05 0x0000000000d29bd0 /build/bin/bitcoind
stap validation block_connected 0x00000000002fb10c 0x0000000000d29bd8 /build/src/bitcoind stap validation block_connected 0x00000000002fb10c 0x0000000000d29bd8 /build/bin/bitcoind
``` ```
@ -446,7 +446,7 @@ The `readelf` tool can be used to display the USDT tracepoints in Bitcoin Core.
Look for the notes with the description `NT_STAPSDT`. Look for the notes with the description `NT_STAPSDT`.
``` ```
$ readelf -n ./build/src/bitcoind | grep NT_STAPSDT -A 4 -B 2 $ readelf -n ./build/bin/bitcoind | grep NT_STAPSDT -A 4 -B 2
Displaying notes found in: .note.stapsdt Displaying notes found in: .note.stapsdt
Owner Data size Description Owner Data size Description
stapsdt 0x0000005d NT_STAPSDT (SystemTap probe descriptors) stapsdt 0x0000005d NT_STAPSDT (SystemTap probe descriptors)
@ -470,7 +470,7 @@ between distributions. For example, on
[ubuntu binary]: https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---binary [ubuntu binary]: https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---binary
``` ```
$ tplist -l ./build/src/bitcoind -v $ tplist -l ./build/bin/bitcoind -v
b'net':b'outbound_message' [sema 0xd29bd0] b'net':b'outbound_message' [sema 0xd29bd0]
1 location(s) 1 location(s)
6 argument(s) 6 argument(s)

View file

@ -7,28 +7,18 @@ include(AddWindowsResources)
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY) configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(generate_build_info #=============================
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h # Subprojects
COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake #=============================
COMMENT "Generating bitcoin-build-info.h" # Subprojects include subdirectories that do or could have tests
VERBATIM # and/or benchmark binaries, such as all subtrees and univalue.
) # These need to be included before CMAKE_*_OUTPUT_DIRECTORY variables
add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL # are set, so output locations of subproject tests and libraries are
clientversion.cpp # not overridden.
) include(../cmake/crc32c.cmake)
target_link_libraries(bitcoin_clientversion include(../cmake/leveldb.cmake)
PRIVATE include(../cmake/minisketch.cmake)
core_interface
)
add_dependencies(bitcoin_clientversion generate_build_info)
add_subdirectory(crypto)
add_subdirectory(univalue) add_subdirectory(univalue)
add_subdirectory(util)
if(WITH_MULTIPROCESS)
add_subdirectory(ipc)
endif()
#============================= #=============================
# secp256k1 subtree # secp256k1 subtree
#============================= #=============================
@ -78,6 +68,38 @@ set_target_properties(secp256k1 PROPERTIES
) )
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set top-level target output locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
add_custom_target(generate_build_info
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h
COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake
COMMENT "Generating bitcoin-build-info.h"
VERBATIM
)
add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL
clientversion.cpp
)
target_link_libraries(bitcoin_clientversion
PRIVATE
core_interface
)
add_dependencies(bitcoin_clientversion generate_build_info)
add_subdirectory(crypto)
add_subdirectory(util)
if(WITH_MULTIPROCESS)
add_subdirectory(ipc)
endif()
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
arith_uint256.cpp arith_uint256.cpp
consensus/merkle.cpp consensus/merkle.cpp

View file

@ -11,7 +11,7 @@ When following your systems build instructions, make sure to install the `Qt` de
To run: To run:
```sh ```sh
./build/src/qt/bitcoin-qt ./build/bin/bitcoin-qt
``` ```
## Files and Directories ## Files and Directories

View file

@ -24,7 +24,7 @@ tests from subtrees.
Run `test_bitcoin --list_content` for the full list of tests. Run `test_bitcoin --list_content` for the full list of tests.
To run the unit tests manually, launch `build/src/test/test_bitcoin`. To recompile To run the unit tests manually, launch `build/bin/test_bitcoin`. To recompile
after a test file was modified, run `cmake --build build` and then run the test again. If you after a test file was modified, run `cmake --build build` and then run the test again. If you
modify a non-test file, use `cmake --build build --target test_bitcoin` to recompile only what's needed modify a non-test file, use `cmake --build build --target test_bitcoin` to recompile only what's needed
to run the unit tests. to run the unit tests.
@ -33,7 +33,7 @@ To add more unit tests, add `BOOST_AUTO_TEST_CASE` functions to the existing
.cpp files in the `test/` directory or add new .cpp files that .cpp files in the `test/` directory or add new .cpp files that
implement new `BOOST_AUTO_TEST_SUITE` sections. implement new `BOOST_AUTO_TEST_SUITE` sections.
To run the GUI unit tests manually, launch `build/src/qt/test/test_bitcoin-qt` To run the GUI unit tests manually, launch `build/bin/test_bitcoin-qt`
To add more GUI unit tests, add them to the `src/qt/test/` directory and To add more GUI unit tests, add them to the `src/qt/test/` directory and
the `src/qt/test/test_main.cpp` file. the `src/qt/test/test_main.cpp` file.
@ -50,19 +50,19 @@ test_bitcoin --help
For example, to run only the tests in the `getarg_tests` file, with full logging: For example, to run only the tests in the `getarg_tests` file, with full logging:
```bash ```bash
build/src/test/test_bitcoin --log_level=all --run_test=getarg_tests build/bin/test_bitcoin --log_level=all --run_test=getarg_tests
``` ```
or or
```bash ```bash
build/src/test/test_bitcoin -l all -t getarg_tests build/bin/test_bitcoin -l all -t getarg_tests
``` ```
or to run only the doubledash test in `getarg_tests` or to run only the doubledash test in `getarg_tests`
```bash ```bash
build/src/test/test_bitcoin --run_test=getarg_tests/doubledash build/bin/test_bitcoin --run_test=getarg_tests/doubledash
``` ```
The `--log_level=` (or `-l`) argument controls the verbosity of the test output. The `--log_level=` (or `-l`) argument controls the verbosity of the test output.
@ -71,7 +71,7 @@ The `test_bitcoin` runner also accepts some of the command line arguments accept
`bitcoind`. Use `--` to separate these sets of arguments: `bitcoind`. Use `--` to separate these sets of arguments:
```bash ```bash
build/src/test/test_bitcoin --log_level=all --run_test=getarg_tests -- -printtoconsole=1 build/bin/test_bitcoin --log_level=all --run_test=getarg_tests -- -printtoconsole=1
``` ```
The `-printtoconsole=1` after the two dashes sends debug logging, which The `-printtoconsole=1` after the two dashes sends debug logging, which
@ -98,7 +98,7 @@ what the test wrote to `debug.log` after it completes, for example.
so no leftover state is used.) so no leftover state is used.)
```bash ```bash
$ build/src/test/test_bitcoin --run_test=getarg_tests/doubledash -- -testdatadir=/somewhere/mydatadir $ build/bin/test_bitcoin --run_test=getarg_tests/doubledash -- -testdatadir=/somewhere/mydatadir
Test directory (will not be deleted): "/somewhere/mydatadir/test_common bitcoin/getarg_tests/doubledash/datadir" Test directory (will not be deleted): "/somewhere/mydatadir/test_common bitcoin/getarg_tests/doubledash/datadir"
Running 1 test case... Running 1 test case...
@ -138,13 +138,13 @@ For debugging you can launch the `test_bitcoin` executable with `gdb` or `lldb`
start debugging, just like you would with any other program: start debugging, just like you would with any other program:
```bash ```bash
gdb build/src/test/test_bitcoin gdb build/bin/test_bitcoin
``` ```
#### Segmentation faults #### Segmentation faults
If you hit a segmentation fault during a test run, you can diagnose where the fault If you hit a segmentation fault during a test run, you can diagnose where the fault
is happening by running `gdb ./build/src/test/test_bitcoin` and then using the `bt` command is happening by running `gdb ./build/bin/test_bitcoin` and then using the `bt` command
within gdb. within gdb.
Another tool that can be used to resolve segmentation faults is Another tool that can be used to resolve segmentation faults is
@ -162,7 +162,7 @@ Running the tests and hitting a segmentation fault should now produce a file cal
You can then explore the core dump using You can then explore the core dump using
```bash ```bash
gdb build/src/test/test_bitcoin core gdb build/bin/test_bitcoin core
(gdb) bt # produce a backtrace for where a segfault occurred (gdb) bt # produce a backtrace for where a segfault occurred
``` ```

View file

@ -255,7 +255,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
for binary, [attribute_name, env_variable_name] in binaries.items(): for binary, [attribute_name, env_variable_name] in binaries.items():
default_filename = os.path.join( default_filename = os.path.join(
self.config["environment"]["BUILDDIR"], self.config["environment"]["BUILDDIR"],
"src", "bin",
binary + self.config["environment"]["EXEEXT"], binary + self.config["environment"]["EXEEXT"],
) )
setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename)) setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename))
@ -272,8 +272,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.set_binary_paths() self.set_binary_paths()
os.environ['PATH'] = os.pathsep.join([ os.environ['PATH'] = os.pathsep.join([
os.path.join(config['environment']['BUILDDIR'], 'src'), os.path.join(config['environment']['BUILDDIR'], 'bin'),
os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'), os.environ['PATH'] os.environ['PATH']
]) ])
# Set up temp directory and start logging # Set up temp directory and start logging

View file

@ -109,7 +109,7 @@ def main():
logging.error("Must have fuzz executable built") logging.error("Must have fuzz executable built")
sys.exit(1) sys.exit(1)
fuzz_bin=os.getenv("BITCOINFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz')) fuzz_bin=os.getenv("BITCOINFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'bin', 'fuzz'))
# Build list of tests # Build list of tests
test_list_all = parse_test_list( test_list_all = parse_test_list(

View file

@ -73,7 +73,7 @@ def bctest(testDir, testObj, buildenv):
are not as expected. Error is caught by bctester() and reported. are not as expected. Error is caught by bctester() and reported.
""" """
# Get the exec names and arguments # Get the exec names and arguments
execprog = os.path.join(buildenv["BUILDDIR"], "src", testObj["exec"] + buildenv["EXEEXT"]) execprog = os.path.join(buildenv["BUILDDIR"], "bin", testObj["exec"] + buildenv["EXEEXT"])
if testObj["exec"] == "./bitcoin-util": if testObj["exec"] == "./bitcoin-util":
execprog = os.getenv("BITCOINUTIL", default=execprog) execprog = os.getenv("BITCOINUTIL", default=execprog)
elif testObj["exec"] == "./bitcoin-tx": elif testObj["exec"] == "./bitcoin-tx":