Skip to content

wallet: deprecate the legacy account RPCs (+ migratelabels)#3099

Open
PrestackI wants to merge 4 commits into
gridcoin-community:developmentfrom
PrestackI:wallet/deprecate-accounts
Open

wallet: deprecate the legacy account RPCs (+ migratelabels)#3099
PrestackI wants to merge 4 commits into
gridcoin-community:developmentfrom
PrestackI:wallet/deprecate-accounts

Conversation

@PrestackI

Copy link
Copy Markdown
Contributor

Phase 3 of 3 in retiring the legacy accounts system (#3086). Stacked on #3098#3097.

Stacking note: this branch builds on #3098 (which builds on #3097), so its diff
currently includes both of those PRs' commits. Review the top two commits here
(wallet: deprecate the legacy account RPCs and wallet: add migratelabels...); the lower
commits belong to #3097/#3098. I'll rebase to drop them as the parents merge. Draft until then.

What this adds

Now that labels are first-class (#3097) and the label RPCs exist (#3098), mark the account
surface deprecated and gate the parts with no label replacement.

  • Bridge RPCs keep working, with a one-time deprecation log warning: getaccount returns
    the label, getaddressesbyaccount keeps its flat-array shape, setaccount now also tags
    purpose like setlabel. setaccount's account-only "unused current key" fixup (no label
    analogue) runs only under -enableaccounts.
  • Account-only RPCs gated via the existing -enableaccounts mechanism: sendfrom and the
    named-fromaccount path of sendmany take the full accounting gate (-enableaccounts +
    staking=0); getaccountaddress takes a lighter gate (-enableaccounts only — it touches
    no ledger, so it must not force staking off). sendmany "" and getbalance "*" stay
    ungated (those sentinels are baseline functionality, not account usage).
  • Accounting ledger preserved read-only: the acentry/acc records and CAccountingEntry
    machinery are untouched and still usable under -enableaccounts; nothing is deleted.
    accounting_tests stays green. Record removal is left to the later removal phase.
  • migratelabels — one-time maintenance RPC for the deprecation window: backfills purpose
    (receive/send) on address-book entries that predate labels (loaded as unknown).
    Names need no conversion — an account name already is the label — so this only fills the
    missing purpose. Returns {examined, updated}, idempotent.

addressbook_tests gains cases for the bridge RPCs working flag-free, the account-only RPCs
throwing without -enableaccounts, and the migratelabels backfill/idempotency.

Not included — removal

Removal (deleting the RPCs, the ledger machinery, -enableaccounts) is deliberately left for
after a deprecation window — see the discussion on #3086. Open questions there: window
length, and the fate of existing acentry/acc records on disk.

Wallet-local, no consensus impact. Refs #3086.

Promote mapAddressBook's value from a bare std::string to a first-class
CAddressBookData{name, purpose}, mirroring Bitcoin 0.17. The single string
previously served simultaneously as the address-book label and the legacy
account grouping key; this separates the label half so it can survive
independently of the account system that is slated for retirement (gridcoin-community#3086).

- Add CAddressBookData (name + "unknown"-defaulted purpose). No implicit
  std::string conversion and no unit serialization: the two fields persist
  as separate "name"/"purpose" walletdb records assembled at load, and every
  consumer must read .name explicitly so the disentanglement surfaces at
  compile time.
- Add SetAddressBookPurpose and WritePurpose/ErasePurpose; ReadKeyValue loads
  the new "purpose" record alongside "name". Old wallets (name only) default
  purpose to "unknown" with no migration write, preserving downgrade safety.
- DelAddressBookName erases both records on one CWalletDB with no short-circuit.
- NotifyAddressBookChanged carries the purpose (6-arg); emits, the Qt free
  function, and the bind placeholders update in lockstep. The GUI slot stays
  4-arg for now (purpose accepted but not yet surfaced).
- Migrate all value-read sites to .name across wallet, rpc and qt.
- Add addressbook_tests: struct defaults, name/purpose round-trip, legacy
  name-only compat, del-erases-both, and the new signal arity.

Wallet-local, no consensus impact.
Add the Bitcoin 0.17 label RPC surface that Gridcoin skipped, built on the
CAddressBookData storage from the previous commit. These give first-class,
account-free access to address-book labels:

- setlabel(address, label): sets the label and tags purpose "receive" for
  owned addresses, "send" otherwise.
- getaddressesbylabel(label): returns the Bitcoin-shaped object keyed by
  address with a {purpose} value; throws RPC_WALLET_INVALID_LABEL_NAME when no
  address carries the label.
- listlabels(purpose?): sorted, de-duplicated label names, optionally filtered
  by purpose, excluding the implicit empty default label.

Adds a LabelFromValue helper (mirrors AccountFromValue), registers all three in
server.h (function + helpman externs) and the server.cpp dispatch table, wires
them into the rpchelpman help-render coverage, and extends addressbook_tests
with RPC-level round-trip, unknown-label, and purpose-filter cases.

Wallet-local, no consensus impact.
Phase C of retiring the accounts subsystem (gridcoin-community#3086): now that labels are
first-class (CAddressBookData) and the label RPCs exist, mark the account
surface deprecated and gate the parts that have no label replacement.

- Bridge RPCs keep working, with a one-time deprecation log warning:
  getaccount returns the label, getaddressesbyaccount lists addresses, and
  setaccount now also tags purpose like setlabel. setaccount's account-only
  "unused current key" fixup (no label analogue) runs only under
  -enableaccounts.
- Account-only RPCs are gated: sendfrom (spends an account-ledger balance) and
  the named-fromaccount path of sendmany take the full accounting gate
  (-enableaccounts + staking=0); getaccountaddress takes a lighter gate
  (-enableaccounts only -- it touches no ledger, so it must not force staking
  off). `sendmany "" {...}` and `getbalance "*"` stay ungated.
- The on-disk acentry/acc ledger is preserved read-only: nothing is deleted,
  and it stays usable under -enableaccounts; record removal is left to the
  later removal phase. accounting_tests is therefore unaffected.

Adds addressbook_tests cases for the bridge RPCs working flag-free and the
account-only RPCs throwing without -enableaccounts.

Wallet-local, no consensus impact.
During the accounts deprecation window, give users a one-time maintenance
command for the labels transition. Address-book *names* need no conversion —
an account name already is the label (shared field) — but entries that predate
the label system load with purpose "unknown", so `listlabels "receive"` won't
find them until re-set.

`migratelabels` walks the address book and backfills purpose on every
"unknown" entry: owned addresses become "receive", others "send". It returns
{examined, updated}, leaves entries that already have a purpose untouched, and
is safe to run repeatedly.

Registered in server.h/server.cpp and the rpchelpman help-render coverage;
addressbook_tests gains a backfill + idempotency case.

Wallet-local, no consensus impact.
@PrestackI PrestackI force-pushed the wallet/deprecate-accounts branch from e6581c5 to 19db0be Compare June 22, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant