diff options
author | Andrew Chow <github@achow101.com> | 2023-02-20 17:45:32 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-04-11 15:55:31 -0400 |
commit | e83babe3b85b22e2360a99f9827b2b0d107ad0fa (patch) | |
tree | 67baf57399f7b1c386c64317164a0360976d1451 /src/qt/test | |
parent | 2f8000513675467e62bee9d0f836d2fefcc479af (diff) | |
download | bitcoin-e83babe3b85b22e2360a99f9827b2b0d107ad0fa.tar.xz |
wallet: Replace use of purpose strings with an enum
Instead of storing and passing around fixed strings for the purpose of
an address, use an enum.
This also rationalizes the CAddressBookData struct, documenting all fields and
making them public, and simplifying the representation to avoid bugs like
https://github.com/bitcoin/bitcoin/pull/26761#discussion_r1134615114 and make
it not possible to invalid address data like change addresses with labels.
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src/qt/test')
-rw-r--r-- | src/qt/test/addressbooktests.cpp | 4 | ||||
-rw-r--r-- | src/qt/test/wallettests.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index d005e08d14..5706964cc9 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -113,8 +113,8 @@ void TestAddAddressesToSendBook(interfaces::Node& node) { LOCK(wallet->cs_wallet); - wallet->SetAddressBook(r_key_dest, r_label.toStdString(), "receive"); - wallet->SetAddressBook(s_key_dest, s_label.toStdString(), "send"); + wallet->SetAddressBook(r_key_dest, r_label.toStdString(), wallet::AddressPurpose::RECEIVE); + wallet->SetAddressBook(s_key_dest, s_label.toStdString(), wallet::AddressPurpose::SEND); } auto check_addbook_size = [&wallet](int expected_size) { diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index eb7bf33a32..072718fe15 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -221,7 +221,7 @@ std::shared_ptr<CWallet> SetupDescriptorsWallet(interfaces::Node& node, TestChai WalletDescriptor w_desc(std::move(desc), 0, 0, 1, 1); if (!wallet->AddWalletDescriptor(w_desc, provider, "", false)) assert(false); CTxDestination dest = GetDestinationForKey(test.coinbaseKey.GetPubKey(), wallet->m_default_address_type); - wallet->SetAddressBook(dest, "", "receive"); + wallet->SetAddressBook(dest, "", wallet::AddressPurpose::RECEIVE); wallet->SetLastBlockProcessed(105, WITH_LOCK(node.context()->chainman->GetMutex(), return node.context()->chainman->ActiveChain().Tip()->GetBlockHash())); SyncUpWallet(wallet, node); wallet->SetBroadcastTransactions(true); |