Context
The wallet’s m_address_book
field is being accessed directly from several places across the sources.
Problem
Code structure wise, we shouldn’t be accessing it directly. It could end up being modified by mistake (from a place that has nothing to do with the wallet like an RPC command or the GUI) and cause a bigger issue: like an address book entry ‘purpose’ string change, which if done badly (from ‘send’ to ‘receive’), could end up in a user sharing a “receive” address that he/she doesn’t own.
Solution
Encapsulate m_address_book
access inside the wallet.
Extra Note:
This is the initial step towards decoupling the address book functionality from the wallet’s sources. In other words, the creation of the AddressBookManager
(which will be coming in a follow-up PR).