Skip to content

wallet: disentangle address-book labels from accounts (storage)#3097

Open
PrestackI wants to merge 1 commit into
gridcoin-community:developmentfrom
PrestackI:wallet/disentangle-accounts-labels
Open

wallet: disentangle address-book labels from accounts (storage)#3097
PrestackI wants to merge 1 commit into
gridcoin-community:developmentfrom
PrestackI:wallet/disentangle-accounts-labels

Conversation

@PrestackI

Copy link
Copy Markdown
Contributor

First step of retiring the legacy accounts system (#3086), sequenced safely behind a labels disentanglement. Wallet-local, no consensus impact — no fork.

Why

Bitcoin deprecated accounts in 0.17 and removed them in 0.18; crucially 0.17 first introduced the label system so labels could survive the account removal. Gridcoin kept accounts and never took the 0.17 label step. In Gridcoin mapAddressBook is std::map<CTxDestination, std::string> — that one string is simultaneously the address-book label (load-bearing: GUI address book, listreceivedbyaddress, transaction display) and the legacy account grouping key. They cannot be cleanly separated until the label half is formalized.

What this PR does (Phase A — storage)

Promotes mapAddressBook's value to a first-class CAddressBookData{name, purpose}, mirroring Bitcoin 0.17, so labels become independent of accounts.

  • CAddressBookData with 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 (the disentanglement surfaces at compile time).
  • New SetAddressBookPurpose + WritePurpose/ErasePurpose; ReadKeyValue loads the new purpose record alongside name. Old wallets (name only) default purpose to "unknown" with no migration write — downgrade-safe. DelAddressBookName erases both records on one CWalletDB with no short-circuit.
  • NotifyAddressBookChanged carries purpose (6-arg); emits, the Qt free function, and bind placeholders updated in lockstep. The GUI slot stays 4-arg for now (purpose accepted but not yet surfaced).
  • All value-read sites migrated to .name across wallet/rpc/qt.

Tests

New addressbook_tests: struct defaults, name/purpose round-trip, legacy name-only compat, del-erases-both, and the new signal arity. accounting_tests is unaffected (it exercises only the CAccountingEntry ledger).

Sequence

This is PR1 of 3. Phase B (label RPCs setlabel/getaddressesbylabel/listlabels) and Phase C (deprecate the account surface) will follow as stacked PRs. Marked draft pending that sequencing.

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.
@PrestackI PrestackI force-pushed the wallet/disentangle-accounts-labels branch from 43d55b4 to 22b8554 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