Commit graph

96 commits

Author SHA1 Message Date
Tom Trevethan
b896c2c6f2 Merge 96d30ed4f9 into merged_master (Bitcoin PR bitcoin/bitcoin#31495) 2026-04-15 14:59:14 +01:00
Tom Trevethan
b408880bd7 Merge 0a77441158 into merged_master (Bitcoin PR bitcoin/bitcoin#31451) 2026-04-09 22:40:50 +01:00
ivanlele
ff3a5007e8
Merge 69e35f5c60 into merged_master (Bitcoin PR bitcoin/bitcoin#31403) 2026-04-09 12:28:10 +00:00
ivanlele
e4670c1695
Merge d5ab5a47f0 into merged_master (Bitcoin PR bitcoin/bitcoin#31452) 2026-04-08 15:48:03 +00:00
ivanlele
ce1172bd1b
Merge 9039d8f1a1 into merged_master (Bitcoin PR bitcoin/bitcoin#31374) 2026-04-08 14:48:55 +00:00
ivanlele
ac8bc8abde
Merge 2eccb8bc5e into merged_master (Bitcoin PR bitcoin/bitcoin#31248) 2026-04-08 13:39:57 +00:00
ivanlele
8d5b1ce230
Merge b21ba081be into merged_master (Bitcoin PR bitcoin/bitcoin#30265) 2026-03-12 16:13:00 +00:00
ivanlele
aa41e29f97
Merge 3a29ff5dea into merged_master (Bitcoin PR bitcoin/bitcoin#30463) 2026-03-09 16:54:19 +00:00
ikripaka
055b97a616
Merge d9aa7b23e4 into merged_master (Bitcoin PR bitcoin/bitcoin#26596) 2026-03-05 18:34:53 +00:00
ivanlele
711e86714a Merge b4a05751b6 into merged_master (Bitcoin PR #29586) 2026-02-12 17:32:36 +00:00
Tom Trevethan
7e6fc14025
resolve fixmes in wallet_migration.py: replaceable=True must be set explicitly in sendtoaddress as walletrbf=0 is set by default in the test_framework wallet config (test_framework/util.py:421)
(cherry picked from commit 860de3c99d8736113e47d3d45c2a0e0a5542e0bb)
2025-12-17 14:31:49 +02:00
Byron Hambly
776d0a85b4
Merge a11585692e into merged_master (Bitcoin PR bitcoin/bitcoin#28868) 2025-11-29 14:47:39 +02:00
Byron Hambly
c34920f56a
Merge 93e10cab5d into merged_master (Bitcoin PR bitcoin/bitcoin#29367) 2025-11-29 14:43:31 +02:00
Byron Hambly
9d50e4e1b4
Merge 5a1473e2c0 into merged_master (Bitcoin PR bitcoin/bitcoin#28976) 2025-11-29 14:11:23 +02:00
Byron Hambly
27dce4469b
Merge fcacbab487 into merged_master (Bitcoin PR bitcoin/bitcoin#29204) 2025-11-18 09:48:58 +02:00
Byron Hambly
720001ebba
Merge c2d04f1319 into merged_master (Bitcoin PR bitcoin/bitcoin#28610) 2025-11-18 08:50:00 +02:00
Byron Hambly
f6bbbcaf08
Merge 2a349f9ea5 into merged_master (Bitcoin PR bitcoin/bitcoin#28264) 2025-11-05 14:53:04 +02:00
Byron Hambly
4c8084b3c0
test: fix wallet_migration.py
when specifying inputs for sendall, fetching the value of the input
incorrectly used the input loop index instead of the actual prevout
index.

this meant that *sometimes* the sendall call would use the wrong input
resulting in a tx that didn't balance - when the loop index was
different to the vout.
2025-10-02 13:18:57 +02:00
Byron Hambly
98d2a8ba83
Merge d724bb5291 into merged_master (Bitcoin PR bitcoin/bitcoin#28609) 2025-08-08 07:58:14 +02:00
Byron Hambly
c1b5207e8c
Merge d98d88c779 into merged_master (Bitcoin PR bitcoin/bitcoin#28392) 2025-08-07 09:16:33 +02:00
Byron Hambly
bbde7e222c
Merge 744157ef1a into merged_master (Bitcoin PR bitcoin/bitcoin#28602) 2025-08-06 20:37:13 +02:00
Byron Hambly
bf24d3692a
Merge 50f250a67d into merged_master (Bitcoin PR bitcoin/bitcoin#28542) 2025-08-05 15:21:35 +02:00
Byron Hambly
52015faa34
Merge abe4fedab7 into merged_master (Bitcoin PR bitcoin/bitcoin#28125) 2025-08-01 12:55:18 +02:00
Byron Hambly
9908be832d Merge 72304ccf1e into merged_master (Bitcoin PR bitcoin/bitcoin#28257) 2025-07-04 09:52:34 +02:00
Byron Hambly
ea86e8f268 Merge 7edce77ff3 into merged_master (Bitcoin PR bitcoin/bitcoin#28067) 2025-07-03 09:42:33 +02:00
Byron Hambly
861d620a00 Merge 87e19b047c into merged_master (Bitcoin PR bitcoin/bitcoin#28038) 2025-07-01 11:18:57 +02:00
Byron Hambly
b71fb23d2d Merge e8543629ae into merged_master (Bitcoin PR bitcoin/bitcoin#27884) 2025-06-30 14:36:23 +02:00
Byron Hambly
459be075a1 Merge ee22ca59a2 into merged_master (Bitcoin PR bitcoin/bitcoin#26740) 2025-06-27 15:40:23 +02:00
Byron Hambly
7f25cff4a2 Merge 34ac3f438a into merged_master (Bitcoin PR bitcoin/bitcoin#26485) 2025-06-27 11:24:52 +02:00
Byron Hambly
5b856b6f5f Merge fa53611cf1 into merged_master (Bitcoin PR bitcoin/bitcoin#26076) 2025-05-16 11:10:32 +02:00
Tom Trevethan
9b8a5eacea Merge 9f6ef0c156 into merged_master (Bitcoin PR bitcoin/bitcoin#27143) 2025-04-08 13:40:24 +00:00
Tom Trevethan
e86b323459 Merge 63893d5eab into merged_master (Bitcoin PR bitcoin/bitcoin#26595) 2025-04-08 12:53:15 +00:00
Byron Hambly
58ed702325 Merge fdd363ebd9 into merged_master (Bitcoin PR bitcoin/bitcoin#26910) 2025-04-05 11:13:37 +02:00
Byron Hambly
620e49c665 Merge b4fb0a3255 into merged_master (Bitcoin PR bitcoin/bitcoin#26761) 2025-04-01 19:31:13 +02:00
Byron Hambly
b4405ba453 Merge e9262ea32a into merged_master (Bitcoin PR bitcoin/bitcoin#26750) 2025-03-31 16:37:52 +02:00
Byron Hambly
df8dcaa38e Merge 8456bfac6b into merged_master (Bitcoin PR bitcoin/bitcoin#26638) 2025-03-31 12:07:25 +02:00
Byron Hambly
073316ddaf Merge e334f7a545 into merged_master (Bitcoin PR bitcoin/bitcoin#26594) 2025-03-04 11:18:49 +02:00
Byron Hambly
0b0d5d214e Merge 8597260872 into merged_master (Bitcoin PR bitcoin/bitcoin#26480) 2025-03-04 10:42:21 +02:00
glozow
96d30ed4f9
Merge bitcoin/bitcoin#31495: wallet: Utilize IsMine() and CanProvide() in migration to cover edge cases
af76664b12 test: Test migration of a solvable script with no privkeys (Ava Chow)
17f01b0795 test: Test migration of taproot output scripts (Ava Chow)
1eb9a2a39f test: Test migration of miniscript in legacy wallets (Ava Chow)
e8c3efc7d8 wallet migration: Determine Solvables with CanProvide (Ava Chow)
fa1b7cd6e2 migration: Skip descriptors which do not parse (Ava Chow)
440ea1ab63 legacy spkm: use IsMine() to extract watched output scripts (Ava Chow)
b777e84cd7 legacy spkm: Move CanProvide to LegacyDataSPKM (Ava Chow)
b1ab927bbf tests: Test migration of additional P2WSH scripts (Ava Chow)
c39b3cfcd1 test: Extra verification that migratewallet migrates (Ava Chow)

Pull request description:

  The legacy wallet `IsMine()` is essentially a black box that would tell us whether the wallet is watching an output script. In order to migrate legacy wallets to descriptor wallets, we need to be able to compute all of the output scripts that a legacy wallet would watch. The original approach for this was to understand `IsMine()` and write a function which would be its inverse. This was partially done in the original migration code, and attempted to be completed in #30328. However, further analysis of `IsMine()` has continued to reveal additional edge cases which make writing an inverse function increasingly difficult to verify correctness.

  This PR instead changes migration to utilize `IsMine()` to produce the output scripts by first computing a superset of all of the output scripts that `IsMine()` would watch and testing each script against `IsMine()` to filter for the ones that actually are watched. The superset is constructed by computing all possible output scripts for the keys and scripts in the wallet - for keys, every key could be a P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH; for scripts, every script could be an output script, the redeemScript of a P2SH, the witnessScript of a P2WSH, and the witnessScript of a P2SH-P2WSH.

  Additionally, the legacy wallet can contain scripts that are redeemScripts and witnessScripts, while not watching for any output script utilizing that script. These are known as solvable scripts and are migrated to a separate "solvables" wallet. The previous approach to identifying these solvables was similar to identifying output scripts - finding known solvable conditions and computing the scripts. However, this also can miss scripts, so the solvables are now identified in a manner similar to the output scripts but using the function `CanProvide()`. Using the same superset as before, all output scripts which are `ISMINE_NO` are put through `CanProvide()` which will perform a dummy signing and then a key lookup to determine whether the legacy wallet could provide any solving data for the output script. The scripts that pass will have their descriptors inferred and the script included in the solvables wallet.

  The main downside of this approach is that `IsMine()` and `CanProvide()` can no longer be deleted. They will need to be refactored to be migration only code instead in #28710.

  Lastly, I've added 2 test cases for the edge cases that prompted this change of approach. In particular, miniscript witnessScripts and `rawtr()` output scripts are  solvable and signable in a legacy wallet, although never `ISMINE_SPENDABLE`.

ACKs for top commit:
  sipa:
    Code review ACK af76664b12; I did not review the tests in detail.
  brunoerg:
    code review ACK af76664b12
  rkrux:
    ACK af76664b12

Tree-SHA512: 7f58a90de6f38fe9801fb6c2a520627072c8d66358652ad0872ff59deb678a82664b99babcfd874288bebcb1487d099a77821f03ae063c2b4cbf2d316e77d141
2025-02-13 12:30:15 -05:00
Ava Chow
af76664b12 test: Test migration of a solvable script with no privkeys
The legacy wallet will be able to solve output scripts where the
redeemScript or witnessScript is known, but does not know any of the
private keys involved in that script. These should be migrated to the
solvables wallet.
2025-02-10 10:10:52 -08:00
Ava Chow
17f01b0795 test: Test migration of taproot output scripts 2025-02-10 10:10:52 -08:00
Ava Chow
1eb9a2a39f test: Test migration of miniscript in legacy wallets 2025-02-10 10:10:52 -08:00
Ava Chow
b1ab927bbf tests: Test migration of additional P2WSH scripts 2025-02-10 09:54:03 -08:00
Ava Chow
c39b3cfcd1 test: Extra verification that migratewallet migrates 2025-01-20 19:03:22 -05:00
Ava Chow
0a77441158
Merge bitcoin/bitcoin#31451: wallet: migration, avoid loading legacy wallet after failure when BDB isn't compiled
589ed1a8ea wallet: migration, avoid loading wallet after failure when it wasn't loaded before (furszy)

Pull request description:

  Fixes #31447.

  During migration failure, only load wallet back into memory when the wallet was
  loaded prior to migration. This fixes the case where BDB is not supported, which
  implies that no legacy wallet can be loaded into memory due to the lack of db
  writing functionality.

  Link to error description https://github.com/bitcoin/bitcoin/issues/31447#issuecomment-2528757140.

  This PR also improves migration backup related comments to better document the
  current workflow.

ACKs for top commit:
  achow101:
    ACK 589ed1a8ea
  rkrux:
    ACK 589ed1a8ea
  pablomartin4btc:
    tACK 589ed1a8ea

Tree-SHA512: c7a489d2b253c574ee0287b691ebe29fe8d026f659f68a3f6108eca8b4e1e420c67ca7803c6bd70c1e1440791833fabca3afbcf8fe8524c6c9fc08de95b618d0
2025-01-09 18:33:23 -05:00
Ava Chow
69e35f5c60
Merge bitcoin/bitcoin#31403: test: Call generate RPCs through test framework only
fa6e599cf9 test: Call generate through test framework only (MarcoFalke)

Pull request description:

  The generate RPCs are special in that they should only be called by the test framework itself. This way, they will call the sync function on the nodes, which can avoid intermittent test issues. Also, when the sync is disabled, it will happen explicitly by setting the `sync_fun`.

  Apply this rule here, so that all generate calls are written consistently.

ACKs for top commit:
  achow101:
    ACK fa6e599cf9
  rkrux:
    tACK fa6e599cf9
  hodlinator:
    ACK fa6e599cf9
  i-am-yuvi:
    Tested ACK fa6e599cf9

Tree-SHA512: 31079997f1e17031ecd577904457e0560388aa53cadb1bbda281865271e8e4cf244bc6bf315838a717bf9d6620c201093e30039aa0007bec3629f7ca56abfba3
2024-12-30 14:19:07 -05:00
furszy
589ed1a8ea
wallet: migration, avoid loading wallet after failure when it wasn't loaded before
During migration failure, only load wallet back into memory when the
wallet was loaded prior to migration. This fixes the case where BDB
is not supported, which implies that no legacy wallet can be loaded
into memory due to the lack of db writing functionality.

This commit also improves migration backup related comments to better
document the current workflow.

Co-authored-by: Ava Chow <github@achow101.com>
2024-12-11 20:26:36 -05:00
Ava Chow
62b2d23edb wallet: Migrate non-HD keys to combo() descriptor
Non-HD keys in legacy wallets without a HD seed ID were being migrated
to separate pk(), pkh(), sh(wpkh()), and wpkh() descriptors for each key.
These could be more compactly represented as combo() descriptors, so
migration should make combo() for them.

It is possible that existing non-HD wallets that were migrated, or
wallets that started blank and had private keys imported into them have
run into this issue. However, as the 4 descriptors produce the same output
scripts as the single combo(), so any previously migrated wallets are
not missing any output scripts. The only observable difference should be
performance related, and the wallet size on disk.
2024-12-09 15:25:57 -05:00
furszy
cdd207c0e4
test: add coverage for migrating standalone imported keys 2024-12-06 14:13:09 -05:00
furszy
297a876c98
test: add coverage for migrating watch-only script 2024-12-06 14:13:09 -05:00