mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge bitcoin/bitcoin#25337: refactor: encapsulate wallet's address book access
d69045e291test: add coverage for 'listreceivedbyaddress' no change addrs return (furszy)324f00a642refactor: 'ListReceived' use optional for filtered address (furszy)b459fc122frefactor: RPC 'ListReceived', encapsulate m_address_book access (furszy)fa9f2ab8fdrefactor: RPC 'listlabels', encapsulate 'CWallet::ListAddrBookLabels' functionality (furszy)83e42c4b94refactor: use 'ForEachAddrBookEntry' in RPC 'getaddressesbylabel' (furszy)2b48642499refactor: use ForEachAddrBookEntry in interfaces::getAddresses (furszy)032842ae41wallet: implement ForEachAddrBookEntry method (furszy)09649bc95drefactor: implement general 'ListAddrBookAddresses' for addressbook destinations lookup (furszy)192eb1e61crefactor: getAddress don't access m_address_book, use FindAddressEntry function (furszy) Pull request description: ### 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). ACKs for top commit: achow101: ACKd69045e291theStack: ACKd69045e291✅ w0xlt: ACKd69045e291Tree-SHA512: dba17acd86f171b4e9af0223bbbcad380048570f6a2f6a92732a51f01abe8806debaf65c9e9e5569fa76a541903cbb50adcb5f56ef77858151c698ae6b218e2a
This commit is contained in:
@@ -57,6 +57,11 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||
{"address": empty_addr},
|
||||
{"address": empty_addr, "label": "", "amount": 0, "confirmations": 0, "txids": []})
|
||||
|
||||
# No returned addy should be a change addr
|
||||
for node in self.nodes:
|
||||
for addr_obj in node.listreceivedbyaddress():
|
||||
assert_equal(node.getaddressinfo(addr_obj["address"])["ischange"], False)
|
||||
|
||||
# Test Address filtering
|
||||
# Only on addr
|
||||
expected = {"address": addr, "label": "", "amount": Decimal("0.1"), "confirmations": 10, "txids": [txid, ]}
|
||||
|
||||
Reference in New Issue
Block a user