wallet: importdescriptors update existing
Summary:
Rationale: allow updating existing descriptors with importdescriptors command.
Currently if you run same importdescriptors command twice with a descriptor containing private key you will get very confusing error — Missing required fields. What happens is that Wallet tries to write imported private key to the disk, but it exists already so we get DB_KEYEXIST (-30995) from BerkelyDB. Please note, that we set DB_NOOVERWRITE (I guess not to lose some keys accidentally). The exception is caught in catch (...) in rpcdump.cpp with a generic error.
With this PR if a descriptor is already present than we will update its activeness, internalness, label, range and next_index.
For the range only expansion is allowed (range start can only decrease, range end increase).
wallet: allow to import same descriptor twice
wallet: don't mute exceptions in importdescriptors
wallet: maintain SPK consistency on internal flag change
test: wallet importdescriptors update existing
wallet: deactivate descriptor
This is a backport of core#19651
Test Plan:
ninja all check-all
$ ecashaddress convert mpA2Wh9dvZT7yfELq1UnrUmAoc5qCkMetg --prefix ecregtest ecregtest:qp0v86h53rc92hjrlpwzpjtdlgzsxu25svv6g40fpl
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14207