mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
Merge bitcoin/bitcoin#31374: wallet: fix crash during watch-only wallet migration
cdd207c0e4test: add coverage for migrating standalone imported keys (furszy)297a876c98test: add coverage for migrating watch-only script (furszy)932cd1e92bwallet: fix crash during watch-only wallet migration (furszy) Pull request description: The crash occurs because we assume the cached scripts structure will not be empty, but it can be empty for watch-only wallets that start blank. This also adds test coverage for standalone imported keys, which were also crashing because pubkey imports are treated the same way as hex script imports through `importaddress()`. Testing Notes: This can be verified by cherry-picking and running any of the test commits on master. It will crash there but pass on this branch. ACKs for top commit: theStack: re-ACKcdd207c0e4brunoerg: reACKcdd207c0e4achow101: ACKcdd207c0e4Tree-SHA512: e05c77cf3e9f35f10f122a73680b3f131f683c56685c1e26b5ffc857f95195b64c8c9d4535960ed3d6f931935aa79b0b1242537462006126bdb68251f0452954
This commit is contained in:
@@ -4085,7 +4085,11 @@ util::Result<void> CWallet::ApplyMigrationData(WalletBatch& local_wallet_batch,
|
||||
if (ExtractDestination(script, dest)) not_migrated_dests.emplace(dest);
|
||||
}
|
||||
|
||||
Assume(!m_cached_spks.empty());
|
||||
// When the legacy wallet has no spendable scripts, the main wallet will be empty, leaving its script cache empty as well.
|
||||
// The watch-only and/or solvable wallet(s) will contain the scripts in their respective caches.
|
||||
if (!data.desc_spkms.empty()) Assume(!m_cached_spks.empty());
|
||||
if (!data.watch_descs.empty()) Assume(!data.watchonly_wallet->m_cached_spks.empty());
|
||||
if (!data.solvable_descs.empty()) Assume(!data.solvable_wallet->m_cached_spks.empty());
|
||||
|
||||
for (auto& desc_spkm : data.desc_spkms) {
|
||||
if (m_spk_managers.count(desc_spkm->GetID()) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user