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).