Page MenuHomePhabricator

wallet: importdescriptors update existing
ClosedPublic

Authored by PiRK on Jul 4 2023, 07:42.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC33d78b3c5575: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jul 4 2023, 07:42
Fabien requested changes to this revision.Jul 4 2023, 13:56
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/wallet/rpc/backup.cpp
2103 ↗(On Diff #41232)

Make this a single if

src/wallet/wallet.cpp
3399 ↗(On Diff #41232)

I don't see why id couldn't be a const ref

test/functional/wallet_importdescriptors.py
790 ↗(On Diff #41232)

nice

This revision now requires changes to proceed.Jul 4 2023, 13:56
This revision is now accepted and ready to land.Jul 4 2023, 16:14