7068 Commits

Author SHA1 Message Date
Luke Dashjr
65173944ed QA: tool_wallet: Check that db.log is deleted with a lone legacy wallet, but not with a shared db environment 2026-01-23 13:18:41 +00:00
Ava Chow
f4b78c42e5 test: Add a test for anchor outputs in the wallet
Github-Pull: #33268
Rebased-From: 609d265ebc51abfe9a9ce570da647b6839dc1214
2026-01-14 10:07:46 -08:00
Ava Chow
71633a9b5c test: Test wallet 'from me' status change
If something is imported into the wallet, it can change the 'from me'
status of a transaction. This status is only visible through
gettransaction's "fee" field which is only shown for transactions that
are 'from me'.

Github-Pull: #33268
Rebased-From: e76c2f7a4111f87080e31539f83c21390fcd8f3b
2026-01-13 16:40:30 -08:00
merge-script
6e7ea3cf2a
Merge bitcoin/bitcoin#33788: [29.x] Backport fixes for CVE-2025-46598
6f136cd3914b001752cce02adde00fccaed0ad48 tests: drop expect_disconnect behaviour for tx relay (Anthony Towns)
be0857745a5a0154d89a2aa9ddaa2a84e912598a validation: only check input scripts once (Anthony Towns)
65bcbbc538234957b1f7f76b2f21ad7c138efb87 net_processing: drop MaybePunishNodeForTx (Anthony Towns)
f24291bd96f92ecc0fc04317fd93747eeb2d557a qa: unit test sighash caching (Antoine Poinsot)
73d3ab8fc93119f14f72a6c5f3cdd9eedcb36a20 qa: simple differential fuzzing for sighash with/without caching (Antoine Poinsot)
ddfb9150b80c0c692c06b91cefa988c7773b15ff script: (optimization) introduce sighash midstate caching (Pieter Wuille)
354d46bc10c61c45140be7a425c5c29fed934d32 script: (refactor) prepare for introducing sighash midstate cache (Pieter Wuille)
5a0506eea03e423121dd2112c2ba5fb4320022e3 tests: add sighash caching tests to feature_taproot (Pieter Wuille)
020ed613bed1148888692cb37e3522202bfca44e validation: detect witness stripping without re-running Script checks (Antoine Poinsot)
56626300b80dced9e111a39d5c560b0b81276cb8 policy: introduce a helper to detect whether a transaction spends Segwit outputs (Antoine Poinsot)
97088fa75aa0af5355587ce3522320f459e35204 qa: test witness stripping in p2p_segwit (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  sipa:
    Code review ACK 6f136cd3914b001752cce02adde00fccaed0ad48
  glozow:
    ACK 6f136cd3914b001752cce02adde00fccaed0ad48, looks correct
  darosior:
    ACK 6f136cd3914b001752cce02adde00fccaed0ad48

Tree-SHA512: 445d770ae10bf1c4766810f945a8e5d83bfa0869d346b0f93c237b91101c9af45d6c935414e79ebf5e0c7089599a9a5a96cff82d9703b1d9573ce9deb21971fd
2026-01-12 11:40:55 -08:00
David Gumberg
76cdeb7b06 wallet: test: Failed migration cleanup
Refactor a common way to perform the failed migration test that exists
for default wallets, and add relative-path wallets and absolute-path
wallets.

Github-Pull: 34226
Rebased-From: eeaf28dbe0e09819ab0e95bb7762b29536bdeef6
2026-01-09 12:56:19 -08:00
furszy
9405e915e7 test: coverage for migration failure when last sync is beyond prune height
Github-Pull: bitcoin/bitcoin#34156
Rebased-From: b7c34d08dd9549a95cffc6ec1ffa4bb4f81e35eb
2026-01-09 12:52:57 -08:00
furszy
5e8ad98163 wallet: migration, fix watch-only and solvables wallets names
Because the default wallet has no name, the watch-only and solvables
wallets created during migration end up having no name either.

This fixes it by applying the same prefix name we use for the backup
file for an unnamed default wallet.

Before: watch-only wallet named "_watchonly"
After:  watch-only wallet named "default_wallet_watchonly"

Github-Pull: bitcoin/bitcoin#34156
Rebased-From: 82caa8193a3e36f248dcc949e0cd41def191efac
2026-01-09 12:52:57 -08:00
furszy
9ea84c08d7 test: restorewallet, coverage for existing dirs, unnamed wallet and prune failure
The first test verifies that restoring into an existing empty directory
or a directory with no .dat db files succeeds, while restoring into a
dir with a .dat file fails.

The second test covers restoring into the default unnamed wallet
(wallet.dat), which also implicitly exercises the recovery path used
after a failed migration.

The third test covers failure during restore on a prune node. When
the wallet last sync was beyond the pruning height.

Github-Pull: bitcoin/bitcoin#34156
Rebased-From: f011e0f0680a8c39988ae57dae57eb86e92dd449
2026-01-09 12:52:57 -08:00
furszy
833848e9b8 test: add coverage for unnamed wallet migration failure
Verifies that a failed migration of the unnamed (default) wallet
does not erase the main /wallets/ directory, and also that the
backup file exists.

Github-Pull: bitcoin/bitcoin#34156
Rebased-From: 36093bde63286e19821a9e62cdff1712b6245dc7
2026-01-09 12:52:10 -08:00
furszy
a074d36254 wallet: fix unnamed wallet migration failure
When migrating any legacy unnamed wallet, a failed migration would
cause the cleanup logic to remove its parent directory. Since this
type of legacy wallet lives directly in the main '/wallets/' folder,
this resulted in unintentionally erasing all wallets, including the
backup file.

To be fully safe, we will no longer call `fs::remove_all`. Instead,
we only erase the individual db files we have created, leaving
everything else intact. The created wallets parent directories are
erased only if they are empty.
As part of this last change, `RestoreWallet` was modified to allow
an existing directory as the destination, since we no longer remove
the original wallet directory (we only remove the files we created
inside it). This also fixes the restore of top-level default wallets
during failures, which were failing due to the directory existence
check that always returns true for the /wallets/ directory.

This bug started after:
f6ee59b6e2
Previously, the `fs::copy_file` call was failing for top-level wallets,
which prevented the `fs::remove_all` call from being reached.

Github-Pull: bitcoin/bitcoin#34156
Rebased-From: f4c7e28e80bf9af50b03a770b641fd309a801589
2026-01-09 10:39:43 -08:00
Ava Chow
cc324aa2be wallettool: do not use fs::remove_all in createfromdump cleanup
Github-Pull: bitcoin/bitcoin#34215
Rebased-From: f78f6f1dc8e16d5a8a23749e77bc3bf17c91ae42
2026-01-08 18:10:04 -08:00
Anthony Towns
6f136cd391 tests: drop expect_disconnect behaviour for tx relay
Github-Pull: #33050
Rebased-From: 876dbdfb4702410dfd4037614dc9298a0c09c63e
2025-11-03 21:50:28 +00:00
Anthony Towns
be0857745a validation: only check input scripts once
Previously, we would check failing input scripts twice when considering
a transaction for the mempool, in order to distinguish policy failures
from consensus failures. This allowed us both to provide a different
error message and to discourage peers for consensus failures. Because we
are no longer discouraging peers for consensus failures during tx relay,
and because checking a script can be expensive, only do this once.

Also renames non-mandatory-script-verify-flag error to
mempool-script-verify-flag-failed.

NOTE: Backport required additional adjustment in test/functional/feature_block

Github-Pull: #33050
Rebased-From: b29ae9efdfeeff774e32ee433ce67d8ed8ecd49f
2025-11-03 21:50:28 +00:00
Anthony Towns
65bcbbc538 net_processing: drop MaybePunishNodeForTx
Do not discourage nodes even when they send us consensus invalid
transactions.

Because we do not discourage nodes for transactions we consider
non-standard, we don't get any DoS protection from this check in
adversarial scenarios, so remove the check entirely both to simplify the
code and reduce the risk of splitting the network due to changes in tx
relay policy.

NOTE: Backport required additional adjustment in test/functional/p2p_invalid_tx

Github-Pull: #33050
Rebased-From: 266dd0e10d08c0bfde63205db15d6c210a021b90
2025-11-03 21:50:28 +00:00
Pieter Wuille
5a0506eea0 tests: add sighash caching tests to feature_taproot
Github-Pull: #32473
Rebased-From: 9014d4016ad9351cb59b587541895e55f5d589cc
2025-11-03 21:50:28 +00:00
Antoine Poinsot
97088fa75a qa: test witness stripping in p2p_segwit
A stripped witness is detected as a special case in mempool acceptance to make sure we do not add
the wtxid (which is =txid since witness is stripped) to the reject filter. This is because it may
interfere with 1p1c parent relay which currently uses orphan reconciliation (and originally it was
until wtxid-relay was widely adopted on the network.

This commit adds a test for this special case in the p2p_segwit function test, both when spending
a native segwit output and when spending a p2sh-wrapped segwit output.

Thanks to Eugene Siegel for pointing out the p2sh-wrapped detection did not have test coverage by
finding a bug in a related patch of mine.

Github-Pull: #33105
Rebased-From: eb073209db9efdbc2c94bc1f535a27ec6b20d954
2025-11-03 21:50:28 +00:00
Eugene Siegel
554ff3f7f3
test: change log rate limit version gate from 299900 to 290100
Github-Pull: #33612
Rebased-From: 7b544341c0021dd713f05bc439ee190de911930c
2025-10-14 17:30:06 +01:00
Greg Sanders
a8bb76b61f
test: add more TRUC reorg coverge
Github-Pull: #33504
Rebased-From: 06df14ba75be5f48cf9c417424900ace17d1cf4d
2025-10-02 15:17:34 +01:00
Sjors Provoost
22ab141243
rpc: fix getblock(header) returns target for tip
A target field was added to the getblock and getblockheader RPC calls in bitcoin#31583, but it mistakingly always used the tip value.

Because regtest does not have difficulty adjustment, a test is added for mainnet instead.

Github-Pull: #33446
Rebased-From: bf7996cbc3becf329d8b1cd2f1007fec9b3a3188
2025-09-24 10:34:21 -04:00
Sjors Provoost
118abf4c30
test: add block 2016 to mock mainnet
The next commit requires an additional mainnet block which changes the difficulty.

Also fix a few minor mistakes in the test (suite):
- rename the create_coinbase retarger_period argument to halving_period. Before bitcoin#31583 this was hardcoded for regtest where these values are the same.
- drop unused fees argument from mine helper

Finally the CPU miner instructions for generating the alternative mainnet chain are expanded.

Github-Pull: #33446
Rebased-From: 4c3c1f42cf705e039751395799240da33ca969bd
2025-09-24 10:25:02 -04:00
Eugene Siegel
1288d44804
test: send duplicate blocktxn message in p2p_compactblocks.py
Add test_multiple_blocktxn_response that checks that the peer is
disconnected.

Github-Pull: #33296
Rebased-From: 8b6264768030db1840041abeeaeefd6c227a2644
2025-09-12 15:44:07 +01:00
Martin Zumsande
fcac8022d8
test: index with an unclean restart after a reorg
This test fails without the previous commit.

Github-Pull: #33212
Rebased-From: a602f6fb7bf5f9e57299f4d6e246c82379fad8d2
2025-08-24 22:51:07 +01:00
glozow
9dd7efc8c3 [policy] lower default minrelaytxfee and incrementalrelayfee to 100sat/kvB
Let's say an attacker wants to use/exhaust the network's bandwidth, and
has the choice between renting resources from a commercial provider and
getting the network to "spam" itself it by sending unconfirmed
transactions. We'd like the latter to be more expensive than the former.

The bandwidth for relaying a transaction across the network is roughly
its serialized size (plus relay overhead) x number of nodes. A 1000vB
transaction is 1000-4000B serialized. With 100k nodes, that's 0.1-0.4GB
If the going rate for commercial services is 10c/GB, that's like 1-4c per kvB
of transaction data, so a 1000vB transaction should pay at least $0.04.

At a price of 120k USD/BTC, 100sat is about $0.12. This price allows us
to tolerate a large decrease in the conversion rate or increase in the
number of nodes.

Github-Pull: #33106
Rebased-From: 6da5de58cabc4133c379baa50845e30e5bc6b3e4
2025-08-20 10:19:23 -04:00
glozow
bbdab3ef7b [prep/test] make wallet_fundrawtransaction's minrelaytxfee assumption explicit
Github-Pull: #33106
Rebased-From: 2e515d2897eaa5a9b012eb78aef105e1cf80d42b
2025-08-20 10:19:23 -04:00
glozow
a0ae3fc8a7 [prep/test] replace magic number 1000 with respective feerate vars
Github-Pull: #33106
Rebased-From: 3eab8b724044dc321f70e5eed66b149713158a04
2025-08-20 10:19:23 -04:00
glozow
1c1970fb45 [miner] lower default -blockmintxfee to 1sat/kvB
Back when we implemented coin age priority as a miner policy, miners
mempools might admit transactions paying very low fees, but then want to
set a higher fee for block inclusion. However, since coin age priority
was removed in v0.15, the block assembly policy is solely based on fees,
so we do not need to apply minimum feerate rules in multiple places. In
fact, the block assembly policy ignoring transactions that are added to
the mempool is likely undesirable as we waste resources accepting and
storing this transaction.

Instead, rely on mempool policy to enforce a minimum entry feerate to
the mempool (minrelaytxfee). Set the minimum block feerate to the
minimum non-zero amount (1sat/kvB) so it collects everything it finds in
mempool into the block.

Github-Pull: #33106
Rebased-From:  5f2df0ef78be7b24798d0983c9b962740608f1f4
2025-08-20 10:19:23 -04:00
glozow
567c3ee3cb [test] explicitly check default -minrelaytxfee and -incrementalrelayfee
Github-Pull: #33106
Rebased-From:  1fbee5d7b61b83e68e4230c8a97ca308de92c4c3
2025-08-20 10:19:23 -04:00
glozow
6b5396c4b1 [test] RBF rule 4 for various incrementalrelayfee settings
Github-Pull: #33106
Rebased-From: 72dc18467dbfc16cdbda2dd109b087243b397799
2025-08-20 10:19:23 -04:00
glozow
03da7aff99 [test] check bypass of minrelay for various minrelaytxfee settings
Github-Pull: #33106
Rebased-From: 85f498893f54ea7d84f2bdf12aa35d198edf8a72
2025-08-20 10:19:23 -04:00
glozow
4e3cfa660d [test] check miner doesn't select 0fee transactions
Github-Pull: #33106
Rebased-From: e5f896bb1f052fb8c7811c6024cb49143b427512
2025-08-20 10:19:15 -04:00
Eugene Siegel
206f5902db
config: add DEBUG_ONLY -logratelimit
Use -nologratelimit by default in functional tests if the bitcoind
version supports it.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>

Github-Pull: #33011
Rebased-From: 5c74a0b397cb3db94761bad78801eed4544155b9
2025-08-20 12:01:35 +01:00
Eugene Siegel
a0992a842e
log: use std::source_location in place of __func__, __FILE__, __LINE__
The std::source_location conveniently stores the file name, line number,
and function name of a source code location. We switch to using it instead
of the __func__ identifier and the __FILE__ and __LINE__ macros.

BufferedLog is changed to have a std::source_location member, replacing the
source_file, source_line, and logging_function members. As a result,
MemUsage no longer explicitly counts source_file or logging_function as the
std::source_location memory usage is included in the MallocUsage call.

This also changes the behavior of -logsourcelocations as std::source_location
includes the entire function signature. Because of this, the functional test
feature_config_args.py must be changed to no longer include the function
signature as the function signature can differ across platforms.

Co-Authored-By: Niklas Gogge <n.goeggi@gmail.com>
Co-Authored-By: stickies-v <stickies-v@protonmail.com>

Github-Pull: #32604
Rebased-From: a6a35cc0c23d0d529bfeb2f40d83d61f15ca7b40
2025-08-20 11:42:01 +01:00
Chris Stewart
2b9738a083
test: Fix 'getdescriptoractivity' RPCHelpMan, add test to verify 'spend_vin' is the correct field
Github-Pull: #33119
Rebased-From: 3543bfdfec345cf2c952143c31674ef02de2a64b
2025-08-06 11:17:38 +01:00
merge-script
4bf77955ed
Merge bitcoin/bitcoin#33013: [29.x] Backport #32521
f25dc84b2892e6bdbbd0471add9fcb2757700981 doc: update release notes for 29.x (Antoine Poinsot)
313023369b8e4ffb268cb642101680fe7f746fea qa: functional test a transaction running into the legacy sigop limit (Antoine Poinsot)
0a4671d5eba2499a27e530536b48b86166319fe8 qa: unit test standardness of inputs packed with legacy sigops (Antoine Poinsot)
204b96591542373dc75c6a6401b477f4b6615e69 policy: make pathological transactions packed with legacy sigops non-standard. (Antoine Poinsot)

Pull request description:

  This backports PR #32521 to make the change available to miners who can't (or don't want to) upgrade past version 29.

ACKs for top commit:
  marcofleon:
    reACK f25dc84b2892e6bdbbd0471add9fcb2757700981
  glozow:
    ACK f25dc84b2892e6bdbbd0471add9fcb2757700981

Tree-SHA512: d5e06618720ed1a96d8a5fccdd8d1dbcbb5748505aa0df69198326828fe13f220e55bbce813f6f2daae82d23348e1f83a3a20a28639ec3fc2455c5b6e79a56e6
2025-07-24 12:32:38 -04:00
furszy
380b5aded2
test: fix intermittent failure in wallet_reorgsrestore.py
Wait until the node's process has fully stopped before starting a new instance.

Since the same code is used in tool_wallet.py, this consolidates the behavior
into a 'kill_process()' function.

Github-Pull: bitcoin/bitcoin#32069
Rebased-From: 36b0713edc4655f6e0c291975d6d280fbc89cf2e
2025-07-24 09:29:11 -04:00
MarcoFalke
5e327e6703
test: Log KeyboardInterrupt as exception
log.exception is more verbose and useful to debug timeouts.

Also, log stderr for CalledProcessError to make debugging easier.

Github-Pull: #33001
Rebased-From: faa3e684118bffa7a98cf76eeeb59243219df900
2025-07-23 16:47:12 +01:00
MarcoFalke
79e1a3c9c6
test: Do not pass tests on unhandled exceptions
This adds a missing catch for BaseException (e.g. SystemExit), which
would otherwise be silently ignored.

Also, remove the redundant other catches, which are just calling
log.exception with a redundant log message.

Github-Pull: #33001
Rebased-From: fa30b34026f76a5b8af997152fced2d281782e0d
2025-07-23 16:46:48 +01:00
Antoine Poinsot
313023369b
qa: functional test a transaction running into the legacy sigop limit
It's useful to have an end-to-end test in addition to the unit test to sanity check the RPC error as
well as making sure the transaction is otherwise fully standard.

Github-Pull: bitcoin/bitcoin#32521
Rebased-From: 96da68a38fa295d2414685739c41b8626e198d27
2025-07-18 16:51:54 -04:00
ismaelsadeeq
f85d41c224
test: retain the intended behavior of feature_fee_estimation.py nodes
- Increase block weight by 4000 for all nodes with custom -blockmaxweight.
  Prior to this commit, we generated blocks with 4000 weight units less worth of transactions.
  See https://github.com/bitcoin/bitcoin/issues/32461#issuecomment-2925282272 for details.
  This commit fixes it by increasing the block weight by 4000.

Github-Pull: #32463
Rebased-From: 9b75cfda4d62a0a3bde402503244dd57e1621a12
2025-07-04 09:34:31 +01:00
ismaelsadeeq
84c0c0e64b
test: fix incorrect subtest in feature_fee_estimation.py
- Update `check_smart_estimates` to calculate the fee rate ceiling
   by taking the maximum of fees seen, minrelaytxfee, and mempoolminfee.
- Improve the subtest name and comments.

Github-Pull: #32463
Rebased-From: 5c1236f04a24716b2cbd9b9b283863d3a8a6fa87
2025-07-04 09:34:28 +01:00
Greg Sanders
59a83fb8d1
functional test: correctly detect nonstd TRUC tx vsize in feature_taproot
Github-Pull: #32859
Rebased-From: f0524cda3995cf65adab3d0ca8da0dee4e31c79b
2025-07-03 12:03:30 +01:00
Greg Sanders
9f3690b978
feature_taproot: sample tx version border values more
Currently if the version 3 is selected for an otherwise
standard spender, the test will fail. It's unlikely but
possible, so change the test to update expectations and
sample more aggressively on border values to instigate
failures much quicker in the future if another version is
made standard.

Github-Pull: #32841
Rebased-From: 4be81e9746e9e18923386d6f4945a33885fd98a7
2025-07-03 12:03:06 +01:00
pablomartin4btc
3a57bfaaf9
test: Use rehash() in outbound eviction block-relay
Ensure that tip_header.rehash() is used instead of tip_header.hash, which is None when the header is deserialized from hex.

This avoids depending on wait_for_getheaders() falling back to any received message, making the test more explicit and robust.

Github-Pull: #32823
Rebased-From: ec004cdb86e6471915e1033f390c76ee0428e415
2025-07-03 11:58:03 +01:00
pablomartin4btc
f82015ccfc
test: Clarify roles in outbound eviction comments
Some ambiguous uses of "we" referring to either the node or the peer are replaced with clearer phrasing.

Also rephrase some comments for consistency and readability.

Applies to all relevant outbound eviction tests in p2p_eviction_logic.py.

Github-Pull: #32823
Rebased-From: 26598ed21ea7228c4ecf85da24527c88f9c1f1c1
2025-07-03 11:58:03 +01:00
dergoegge
4b656e2023
test: Add msgtype to msg_generic slots
Github-Pull: #32833
Rebased-From: 7dc43ea503a2c145ffd4fe14b794300bfc2bcdee
2025-06-30 13:28:55 +01:00
Sebastian Falbesoner
5987c1b6ab
test: fix catchup loop in outbound eviction functional test
The catchup loop in the outbound eviction functional test currently has
a small flaw, as the contained waiting for a `getheaders` message just
waits for any such message instead of one with the intended block hash.
The reason is that the `prev_prev_hash` variable is set incorrectly,
since the `tip_header` instance is not updated and its field `.hash` is
None. Fix that by updating `tip_header` and use the correct field -- we
want the tip header's previous hash (`.hashPrevBlock`).

Github-Pull: #32742
Rebased-From: dd8447f70faf6419b4617da3c1b57098e9cd66a6
2025-06-26 11:24:02 +01:00
zaidmstrr
4c7ed36c96
test: Fix list index out of range error in feature_bip68_sequence.py
Github-Pull: #32765
Rebased-From: e285e691b7a311e278f89e9fe423716de1ee268b
2025-06-19 15:06:14 +01:00
Martin Zumsande
8246c6a65f
test: wallet, coverage for crash on dup block disconnection during unclean shutdown
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>

Github-Pull: #31757
Rebased-From: 11f8ab140fe63857f6a93b81021efda8f90ceeda
2025-06-19 10:39:27 +01:00
Martin Zumsande
646fa1d028
test: fix sync function in rpc_psbt.py
It currently only syncs between the first two nodes,
which may do nothing when the block is created on the
third node.

Github-Pull: #32630
Rebased-From: 4df4df45d7bc2e8be99325d40cda936aab87c083
2025-05-29 12:31:10 +01:00
Ava Chow
6c0f26d3bd
test: check that creating a wallet does not log version info
Github-Pull: #32553
Rebased-From: 4b2cd0b41ff4800c8801f2c44883eaec60a035fa
2025-05-20 12:29:25 +01:00