HomePhabricator

walletdb: don't reinitialize desc cache with multiple cache entries

Description

walletdb: don't reinitialize desc cache with multiple cache entries

Summary:

When loading descriptor caches, we would accidentally reinitialize the
descriptor cache when seeing that one already exists. This should have
only been initializing the cache when one does not exist. However this
code itself is unnecessary as the act of looking up the cache to add to
it will initialize it if it didn't already exist.

This issue could be hit by trying to load a wallet that had imported a
multisig descriptor. The wallet would fail to load.

A test has been added to wallet_importdescriptors.py to catch this case.
Another test case has also been added to check that loading a wallet
with only single key descriptors works.

This is a backport of core#19441

Test Plan:
ninja all check-all

I confirmed that before the change in walletdb.cpp, the new test fails with an error Error: Unable to expand wallet descriptor from cache (-4). And the change fixes it.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D9991

Details

Provenance
Andrew Chow <achow101-github@achow101.com>Authored on Jul 4 2020, 01:15
PiRKCommitted on Aug 31 2021, 12:58
PiRKPushed on Aug 31 2021, 12:58
Reviewer
Restricted Project
Differential Revision
D9991: walletdb: don't reinitialize desc cache with multiple cache entries
Parents
rABC392ddaff12ab: Fix ZapSelectTx to sync wallet spends
Branches
Unknown
Tags
Unknown