Merge 983b268768 into merged_master (Bitcoin PR bitcoin/bitcoin#32589)

This commit is contained in:
ivanlele 2026-07-13 15:36:36 +00:00
commit af7d5e9a2d
No known key found for this signature in database
29 changed files with 173 additions and 40 deletions

View file

@ -319,7 +319,7 @@ Source: https://logs.guix.gnu.org/guix/2020-11-12.log#232527
Start by cloning Guix:
```
git clone https://git.savannah.gnu.org/git/guix.git
git clone https://codeberg.org/guix/guix.git
cd guix
```
@ -607,7 +607,7 @@ checklist.
```
Generation 38 Feb 22 2021 16:39:31 (current)
guix f350df4
repository URL: https://git.savannah.gnu.org/git/guix.git
repository URL: https://codeberg.org/guix/guix.git
branch: version-1.2.0
commit: f350df405fbcd5b9e27e6b6aa500da7f101f41e7
```
@ -760,8 +760,8 @@ Please see the following links for more details:
- An upstream coreutils bug has been filed: [debbugs#47940](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47940)
- A Guix bug detailing the underlying problem has been filed: [guix-issues#47935](https://issues.guix.gnu.org/47935), [guix-issues#49985](https://issues.guix.gnu.org/49985#5)
- A commit to skip this test in Guix has been merged into the core-updates branch:
[savannah/guix@6ba1058](https://git.savannah.gnu.org/cgit/guix.git/commit/?id=6ba1058df0c4ce5611c2367531ae5c3cdc729ab4)
- A commit to skip this test is included since Guix 1.4.0:
[codeberg/guix@6ba1058](https://codeberg.org/guix/guix/commit/6ba1058df0c4ce5611c2367531ae5c3cdc729ab4)
[install-script]: #options-1-and-2-using-the-official-shell-installer-script-or-binary-tarball

View file

@ -69,6 +69,24 @@ fi
mkdir -p "$VERSION_BASE"
################
# SOURCE_DATE_EPOCH should not unintentionally be set
################
if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then
cat << EOF
ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.
Aborting...
Hint: You may want to:
1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding
2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on
using your own epoch
EOF
exit 1
fi
################
# Build directories should not exist
################

View file

@ -54,7 +54,7 @@ int trace_inbound_message(struct pt_regs *ctx) {
bpf_probe_read_user_str(&msg.peer_addr, sizeof(msg.peer_addr), paddr);
bpf_usdt_readarg(3, ctx, &pconn_type);
bpf_probe_read_user_str(&msg.peer_conn_type, sizeof(msg.peer_conn_type), pconn_type);
bpf_usdt_readarg(4, ctx, &pconn_type);
bpf_usdt_readarg(4, ctx, &pmsg_type);
bpf_probe_read_user_str(&msg.msg_type, sizeof(msg.msg_type), pmsg_type);
bpf_usdt_readarg(5, ctx, &msg.msg_size);
@ -71,7 +71,7 @@ int trace_outbound_message(struct pt_regs *ctx) {
bpf_probe_read_user_str(&msg.peer_addr, sizeof(msg.peer_addr), paddr);
bpf_usdt_readarg(3, ctx, &pconn_type);
bpf_probe_read_user_str(&msg.peer_conn_type, sizeof(msg.peer_conn_type), pconn_type);
bpf_usdt_readarg(4, ctx, &pconn_type);
bpf_usdt_readarg(4, ctx, &pmsg_type);
bpf_probe_read_user_str(&msg.msg_type, sizeof(msg.msg_type), pmsg_type);
bpf_usdt_readarg(5, ctx, &msg.msg_size);

View file

@ -90,15 +90,15 @@ For linux S390X cross compilation:
### Install the required dependencies: FreeBSD
pkg install bash
pkg install bash cmake curl gmake
### Install the required dependencies: NetBSD
pkgin install bash gmake
pkgin install bash cmake curl gmake perl
### Install the required dependencies: OpenBSD
pkg_add bash gmake gtar
pkg_add bash cmake curl gmake gtar
### Dependency Options

View file

@ -1,7 +1,7 @@
build_openbsd_CC = clang
build_openbsd_CXX = clang++
build_openbsd_SHA256SUM = sha256
build_openbsd_SHA256SUM = sha256 -r
build_openbsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o
build_openbsd_TAR = gtar

View file

@ -4,6 +4,7 @@ $(package)_download_path=https://download.savannah.gnu.org/releases/$(package)
$(package)_file_name=$(package)-$($(package)_version).tar.xz
$(package)_sha256_hash=8bee39bd3968c4804b70614a0a3ad597299ad0e824bc8aad5ce8aaf48067bde7
$(package)_build_subdir=build
$(package)_patches += cmake_minimum.patch
define $(package)_set_vars
$(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DBUILD_SHARED_LIBS=TRUE
@ -12,6 +13,10 @@ define $(package)_set_vars
$(package)_config_opts += -DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch
endef
define $(package)_config_cmds
$($(package)_cmake) -S .. -B .
endef

View file

@ -1,9 +1,9 @@
package=native_capnp
$(package)_version=1.1.0
$(package)_version=1.2.0
$(package)_download_path=https://capnproto.org/
$(package)_download_file=capnproto-c++-$($(package)_version).tar.gz
$(package)_file_name=capnproto-cxx-$($(package)_version).tar.gz
$(package)_sha256_hash=07167580e563f5e821e3b2af1c238c16ec7181612650c5901330fa9a0da50939
$(package)_sha256_hash=ed00e44ecbbda5186bc78a41ba64a8dc4a861b5f8d4e822959b0144ae6fd42ef
define $(package)_set_vars
$(package)_config_opts := -DBUILD_TESTING=OFF

View file

@ -21,6 +21,8 @@ define $(package)_build_cmds
$(MAKE)
endef
# mkdir detection is broken on Alpine. Set MKDIRPROG to ensure we always
# use "mkdir -p", and avoid parallelism issues during install.
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install
$(MAKE) MKDIRPROG="mkdir -p" DESTDIR=$($(package)_staging_dir) install
endef

View file

@ -0,0 +1,13 @@
build: set minimum required CMake to 3.12
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,7 +97,7 @@
# FreeType explicitly marks the API to be exported and relies on the compiler
# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
# starting with 2.8.12.
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.12)
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
# Allow symbol visibility settings also on static libraries. CMake < 3.3

View file

@ -58,7 +58,8 @@ BIPs that are implemented by Bitcoin Core:
Validation rules for Taproot (including Schnorr signatures and Tapscript
leaves) are implemented as of **v0.21.0** ([PR 19953](https://github.com/bitcoin/bitcoin/pull/19953)),
with mainnet activation as of **v0.21.1** ([PR 21377](https://github.com/bitcoin/bitcoin/pull/21377),
[PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)).
[PR 21686](https://github.com/bitcoin/bitcoin/pull/21686)),
always active as of **v24.0** ([PR 23536](https://github.com/bitcoin/bitcoin/pull/23536)).
* [`BIP 350`](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki): Addresses for native v1+ segregated Witness outputs use Bech32m instead of Bech32 as of **v22.0** ([PR 20861](https://github.com/bitcoin/bitcoin/pull/20861)).
* [`BIP 371`](https://github.com/bitcoin/bips/blob/master/bip-0371.mediawiki): Taproot fields for PSBT as of **v24.0** ([PR 22558](https://github.com/bitcoin/bitcoin/pull/22558)).
* [`BIP 379`](https://github.com/bitcoin/bips/blob/master/bip-0379.md): Miniscript was partially implemented in **v24.0** ([PR 24148](https://github.com/bitcoin/bitcoin/pull/24148)), and fully implemented as of **v26.0** ([PR 27255](https://github.com/bitcoin/bitcoin/pull/27255)).

View file

@ -60,7 +60,7 @@ executables, which are based on BerkeleyDB 4.8. Otherwise, you can build Berkele
To build Bitcoin Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
ZMQ dependencies (provides ZMQ API):
ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
sudo apt-get install libzmq3-dev
@ -114,7 +114,7 @@ are based on Berkeley DB 4.8. Otherwise, you can build Berkeley DB [yourself](#b
To build Bitcoin Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
ZMQ dependencies (provides ZMQ API):
ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
sudo dnf install zeromq-devel

View file

@ -2,7 +2,7 @@ Bitcoin Core version 29.x is now available from:
<https://bitcoincore.org/bin/bitcoin-core-29.x/>
This release includes new features, various bug fixes and performance
This release includes various bug fixes and performance
improvements, as well as updated translations.
Please report bugs using the issue tracker at GitHub:
@ -39,6 +39,7 @@ Notable changes
### Wallet
- #31757 wallet: fix crash on double block disconnection
- #32553 wallet: Fix logging of wallet version
### Test
@ -47,6 +48,8 @@ Notable changes
- #32312 test: Fix feature_pruning test after nTime typo fix
- #32336 test: Suppress upstream -Wduplicate-decl-specifier in bpfcc
- #32483 test: fix two intermittent failures in wallet_basic.py
- #32630 test: fix sync function in rpc_psbt.py
- #32765 test: Fix list index out of range error in feature_bip68_sequence.py
### Util
@ -57,6 +60,12 @@ Notable changes
- #32356 cmake: Respect user-provided configuration-specific flags
- #32437 crypto: disable ASan for sha256_sse4 with Clang
- #32469 cmake: Allow WITH_DBUS on all Unix-like systems
- #32439 guix: accomodate migration to codeberg
- #32551 cmake: Add missed SSE41_CXXFLAGS
- #32568 depends: use "mkdir -p" when installing xproto
- #32678 guix: warn and abort when SOURCE_DATE_EPOCH is set
- #32690 depends: fix SHA256SUM command on OpenBSD (use GNU mode output)
- #32760 depends: capnp 1.2.0
### Gui
@ -65,8 +74,18 @@ Notable changes
### Doc
- #32333 doc: Add missing top-level description to pruneblockchain RPC
- #32353 doc: Fix fuzz test_runner.py path
- #32389 doc: Fix test_bitcoin path
- #32607 rpc: Note in fundrawtransaction doc, fee rate is for package
- #32679 doc: update tor docs to use bitcoind binary from path
- #32693 depends: fix cmake compatibility error for freetype
- #32696 doc: make -DWITH_ZMQ=ON explicit on build-unix.md
- #32708 rpc, doc: update listdescriptors RCP help
- #32711 doc: add missing packages for BSDs (cmake, gmake, curl) to depends/README.md
- #32719 doc, windows: CompanyName "Bitcoin" => "Bitcoin Core project"
- #32776 doc: taproot became always active in v24.0
- #32777 doc: fix Transifex 404s
### CI
@ -76,6 +95,7 @@ Notable changes
- #32187 refactor: Remove spurious virtual from final ~CZMQNotificationInterface
- #32454 tracing: fix invalid argument in mempool_monitor
- #32771 contrib: tracing: Fix read of pmsg_type in p2p_monitor.py
Credits
=======
@ -83,16 +103,28 @@ Credits
Thanks to everyone who directly contributed to this release:
- achow101
- benthecarman
- Brandon Odiwuor
- davidgumberg
- enirox001
- fanquake
- furszy
- Hennadii Stepanov
- hodlinator
- ismaelsadeeq
- jb55
- josibake
- laanwj
- luisschwab
- MarcoFalke
- Martin Zumsande
- monlovesmango
- nervana21
- rkrux
- Sjors
- theStack
- willcl-ark
- zaidmstrr
As well as to everyone that helped with translations on
[Transifex](https://www.transifex.com/bitcoin/bitcoin/).
[Transifex](https://explore.transifex.com/bitcoin/bitcoin/).

View file

@ -57,10 +57,10 @@ Release Process
- Clear the release notes and move them to the wiki (see "Write the release notes" below).
- Translations on Transifex:
- Pull translations from Transifex into the master branch.
- Create [a new resource](https://www.transifex.com/bitcoin/bitcoin/content/) named after the major version with the slug `qt-translation-<RRR>x`, where `RRR` is the major branch number padded with zeros. Use `src/qt/locale/bitcoin_en.xlf` to create it.
- Create [a new resource](https://app.transifex.com/bitcoin/bitcoin/content/) named after the major version with the slug `qt-translation-<RRR>x`, where `RRR` is the major branch number padded with zeros. Use `src/qt/locale/bitcoin_en.xlf` to create it.
- In the project workflow settings, ensure that [Translation Memory Fill-up](https://help.transifex.com/en/articles/6224817-setting-up-translation-memory-fill-up) is enabled and that [Translation Memory Context Matching](https://help.transifex.com/en/articles/6224753-translation-memory-with-context) is disabled.
- Update the Transifex slug in [`.tx/config`](/.tx/config) to the slug of the resource created in the first step. This identifies which resource the translations will be synchronized from.
- Make an announcement that translators can start translating for the new version. You can use one of the [previous announcements](https://www.transifex.com/bitcoin/communication/) as a template.
- Make an announcement that translators can start translating for the new version. You can use one of the [previous announcements](https://app.transifex.com/bitcoin/communication/) as a template.
- Change the auto-update URL for the resource to `master`, e.g. `https://raw.githubusercontent.com/bitcoin/bitcoin/master/src/qt/locale/bitcoin_en.xlf`. (Do this only after the previous steps, to prevent an auto-update from interfering.)
#### After branch-off (on the major release branch)

View file

@ -62,7 +62,7 @@ outgoing connections, but more is possible.
In a typical situation, this suffices to run behind a Tor proxy:
./bitcoind -proxy=127.0.0.1:9050
bitcoind -proxy=127.0.0.1:9050
## 2. Automatically create a Bitcoin Core onion service
@ -187,25 +187,25 @@ should be equal to binding address and port for inbound Tor connections (127.0.0
In a typical situation, where you're only reachable via Tor, this should suffice:
./bitcoind -proxy=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -listen
bitcoind -proxy=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -listen
(obviously, replace the .onion address with your own). It should be noted that you still
listen on all devices and another node could establish a clearnet connection, when knowing
your address. To mitigate this, additionally bind the address of your Tor proxy:
./bitcoind ... -bind=127.0.0.1:8334=onion
bitcoind ... -bind=127.0.0.1:8334=onion
If you don't care too much about hiding your node, and want to be reachable on IPv4
as well, use `discover` instead:
./bitcoind ... -discover
bitcoind ... -discover
and open port 8333 on your firewall (or use port mapping, i.e., `-natpmp`).
If you only want to use Tor to reach .onion addresses, but not use it as a proxy
for normal IPv4/IPv6 communication, use:
./bitcoind -onion=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -discover
bitcoind -onion=127.0.0.1:9050 -externalip=7zvj7a2imdgkdbg4f2dryd5rgtrn7upivr5eeij4cicjh65pooxeshid.onion -discover
## 4. Privacy recommendations

View file

@ -41,7 +41,7 @@ git commit
### Creating a Transifex account
Visit the [Transifex Signup](https://www.transifex.com/signup/) page to create an account. Take note of your username and password, as they will be required to configure the command-line tool.
You can find the Bitcoin translation project at [https://www.transifex.com/bitcoin/bitcoin/](https://www.transifex.com/bitcoin/bitcoin/).
You can find the Bitcoin translation project at [https://explore.transifex.com/bitcoin/bitcoin/](https://explore.transifex.com/bitcoin/bitcoin/).
### Installing the Transifex client command-line tool
The client is used to fetch updated translations. Please check installation instructions and any other details at https://developers.transifex.com/docs/cli.

View file

@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Elements Project"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "elements-cli (JSON-RPC client for " CLIENT_NAME ")"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "elements-cli"

View file

@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Elements Project"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin-tx (CLI Elements transaction editor utility)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin-tx"

View file

@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Bitcoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin-util (CLI Bitcoin utility)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin-util"

View file

@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Bitcoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin-wallet (CLI tool for " CLIENT_NAME " wallets)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin-wallet"

View file

@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Elements Project"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "elementsd (Elements node with a JSON-RPC server)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "elementsd"

View file

@ -47,7 +47,7 @@ if(HAVE_SSE41 AND HAVE_X86_SHANI)
target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_SSE41 ENABLE_X86_SHANI)
target_sources(bitcoin_crypto PRIVATE sha256_x86_shani.cpp)
set_property(SOURCE sha256_x86_shani.cpp PROPERTY
COMPILE_OPTIONS ${X86_SHANI_CXXFLAGS}
COMPILE_OPTIONS ${SSE41_CXXFLAGS} ${X86_SHANI_CXXFLAGS}
)
endif()

View file

@ -21,7 +21,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Elements"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", CLIENT_NAME
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "elements-qt"

View file

@ -974,7 +974,9 @@ std::optional<int> GetPruneHeight(const BlockManager& blockman, const CChain& ch
static RPCHelpMan pruneblockchain()
{
return RPCHelpMan{"pruneblockchain", "",
return RPCHelpMan{"pruneblockchain",
"Attempts to delete block and undo data up to a specified height or timestamp, if eligible for pruning.\n"
"Requires `-prune` to be enabled at startup. While pruned data may be re-fetched in some cases (e.g., via `getblockfrompeer`), local deletion is irreversible.\n",
{
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block height to prune up to. May be set to a discrete height, or to a " + UNIX_EPOCH_TIME + "\n"
" to prune blocks whose block time is at least 2 hours older than the provided timestamp."},

View file

@ -1831,7 +1831,7 @@ RPCHelpMan listdescriptors()
{
return RPCHelpMan{
"listdescriptors",
"\nList descriptors imported into a descriptor-enabled wallet.\n",
"\nList all descriptors present in a descriptor-enabled wallet.\n",
{
{"private", RPCArg::Type::BOOL, RPCArg::Default{false}, "Show private descriptors."}
},

View file

@ -854,7 +854,10 @@ RPCHelpMan fundrawtransaction()
"Note that all inputs selected must be of standard form and P2SH scripts must be\n"
"in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
"You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
"Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
"Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only.\n"
"Note that if specifying an exact fee rate, the resulting transaction may have a higher fee rate\n"
"if the transaction has unconfirmed inputs. This is because the wallet will attempt to make the\n"
"entire package have the given fee rate, not the resulting transaction.\n",
{
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
{"options", RPCArg::Type::OBJ_NAMED_PARAMS, RPCArg::Optional::OMITTED, "For backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}",

View file

@ -1556,8 +1556,11 @@ void CWallet::blockDisconnected(const interfaces::BlockInfo& block)
int disconnect_height = block.height;
for (const CTransactionRef& ptx : Assert(block.data)->vtx) {
SyncTransaction(ptx, TxStateInactive{});
for (size_t index = 0; index < block.data->vtx.size(); index++) {
const CTransactionRef& ptx = Assert(block.data)->vtx[index];
// Coinbase transactions are not only inactive but also abandoned,
// meaning they should never be relayed standalone via the p2p protocol.
SyncTransaction(ptx, TxStateInactive{/*abandoned=*/index == 0});
for (const CTxIn& tx_in : ptx->vin) {
// No other wallet transactions conflicted with this transaction

View file

@ -154,8 +154,10 @@ class BIP68Test(BitcoinTestFramework):
# between height/time locking). Small random chance of making the locks
# all pass.
for _ in range(400):
available_utxos = len(utxos)
# Randomly choose up to 10 inputs
num_inputs = random.randint(1, 10)
num_inputs = random.randint(1, min(10, available_utxos))
random.shuffle(utxos)
# Track whether any sequence locks used should fail

View file

@ -93,7 +93,7 @@ class PSBTTest(BitcoinTestFramework):
wallet = node.get_wallet_rpc(self.default_wallet_name)
address = wallet.getnewaddress()
wallet.sendtoaddress(address=address, amount=1.0)
self.generate(node, nblocks=1, sync_fun=lambda: self.sync_all(self.nodes[:2]))
self.generate(node, nblocks=1)
# utxos = wallet.listunspent(addresses=[address])
# psbt = wallet.createpsbt([{"txid": utxos[0]["txid"], "vout": utxos[0]["vout"]}], [{wallet.getnewaddress(): 0.9999}])

View file

@ -19,6 +19,7 @@ import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error
)
@ -91,6 +92,54 @@ class ReorgsRestoreTest(BitcoinTestFramework):
# Verify the coinbase descendant was also marked as abandoned
assert_equal(wallet0.gettransaction(descendant_tx_id)['details'][0]['abandoned'], True)
def test_reorg_handling_during_unclean_shutdown(self):
self.log.info("Test that wallet doesn't crash due to a duplicate block disconnection event after an unclean shutdown")
node = self.nodes[0]
# Receive coinbase reward on a new wallet
node.createwallet(wallet_name="reorg_crash", load_on_startup=True)
wallet = node.get_wallet_rpc("reorg_crash")
self.generatetoaddress(node, 1, wallet.getnewaddress(), sync_fun=self.no_op)
# Restart to ensure node and wallet are flushed
self.restart_node(0)
wallet = node.get_wallet_rpc("reorg_crash")
assert_greater_than(wallet.getwalletinfo()['immature_balance']['bitcoin'], 0)
# Disconnect tip and sync wallet state
tip = wallet.getbestblockhash()
wallet.invalidateblock(tip)
wallet.syncwithvalidationinterfacequeue()
# Tip was disconnected, ensure coinbase has been abandoned
assert_equal(wallet.getwalletinfo()['immature_balance']['bitcoin'], 0)
coinbase_tx_id = wallet.getblock(tip, verbose=1)["tx"][0]
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
# Abort process abruptly to mimic an unclean shutdown (no chain state flush to disk)
node.process.kill()
# Restart the node and confirm that it has not persisted the last chain state changes to disk
self.start_node(0)
assert_equal(node.getbestblockhash(), tip)
# Due to an existing bug, the wallet incorrectly keeps the transaction in an abandoned state, even though that's
# no longer the case (after the unclean shutdown, the node's chain returned to the pre-invalidation tip).
# This issue blocks any future spending and results in an incorrect balance display.
wallet = node.get_wallet_rpc("reorg_crash")
assert_equal(wallet.getwalletinfo()['immature_balance']['bitcoin'], 0) # FIXME: #31824.
# Previously, a bug caused the node to crash if two block disconnection events occurred consecutively.
# Ensure this is no longer the case by simulating a new reorg.
node.invalidateblock(tip)
assert(node.getbestblockhash() != tip)
# Ensure wallet state is consistent now
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
assert_equal(wallet.getwalletinfo()['immature_balance']['bitcoin'], 0)
# And finally, verify the state if the block ends up being into the best chain again
node.reconsiderblock(tip)
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], False)
assert_greater_than(wallet.getwalletinfo()['immature_balance']['bitcoin'], 0)
def run_test(self):
# Send a tx from which to conflict outputs later
@ -164,6 +213,9 @@ class ReorgsRestoreTest(BitcoinTestFramework):
# Verify we mark coinbase txs, and their descendants, as abandoned during startup
self.test_coinbase_automatic_abandon_during_startup()
# Verify reorg behavior during an unclean shutdown
self.test_reorg_handling_during_unclean_shutdown()
if __name__ == '__main__':
ReorgsRestoreTest(__file__).main()