-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: bitcoin#25383, 25535, 25337 #6524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2903,21 +2903,44 @@ void CWallet::MarkDestinationsDirty(const std::set<CTxDestination>& destinations | |
| } | ||
| } | ||
|
|
||
| std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) const | ||
| void CWallet::ForEachAddrBookEntry(const ListAddrBookFunc& func) const | ||
| { | ||
| LOCK(cs_wallet); | ||
| std::set<CTxDestination> result; | ||
| for (const std::pair<const CTxDestination, CAddressBookData>& item : m_address_book) | ||
| { | ||
| if (item.second.IsChange()) continue; | ||
| const CTxDestination& address = item.first; | ||
| const std::string& strName = item.second.GetLabel(); | ||
| if (strName == label) | ||
| result.insert(address); | ||
| for (const std::pair<const CTxDestination, CAddressBookData>& item : m_address_book) { | ||
|
||
| const auto& entry = item.second; | ||
| func(item.first, entry.GetLabel(), entry.purpose, entry.IsChange()); | ||
| } | ||
| } | ||
|
|
||
| std::vector<CTxDestination> CWallet::ListAddrBookAddresses(const std::optional<AddrBookFilter>& _filter) const | ||
| { | ||
| AssertLockHeld(cs_wallet); | ||
| std::vector<CTxDestination> result; | ||
| AddrBookFilter filter = _filter ? *_filter : AddrBookFilter(); | ||
| ForEachAddrBookEntry([&result, &filter](const CTxDestination& dest, const std::string& label, const std::string& purpose, bool is_change) { | ||
| // Filter by change | ||
| if (filter.ignore_change && is_change) return; | ||
| // Filter by label | ||
| if (filter.m_op_label && *filter.m_op_label != label) return; | ||
| // All good | ||
| result.emplace_back(dest); | ||
| }); | ||
| return result; | ||
| } | ||
|
|
||
| std::set<std::string> CWallet::ListAddrBookLabels(const std::string& purpose) const | ||
| { | ||
| AssertLockHeld(cs_wallet); | ||
| std::set<std::string> label_set; | ||
| ForEachAddrBookEntry([&](const CTxDestination& _dest, const std::string& _label, | ||
| const std::string& _purpose, bool _is_change) { | ||
| if (_is_change) return; | ||
| if (purpose.empty() || _purpose == purpose) { | ||
| label_set.insert(_label); | ||
| } | ||
| }); | ||
| return label_set; | ||
| } | ||
|
|
||
| bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool fInternalIn) | ||
| { | ||
| m_spk_man = pwallet->GetScriptPubKeyMan(fInternalIn); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -791,7 +791,30 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati | |
| std::set<std::set<CTxDestination>> GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||
| std::map<CTxDestination, CAmount> GetAddressBalances() const; | ||
|
|
||
| std::set<CTxDestination> GetLabelAddresses(const std::string& label) const; | ||
| // Filter struct for 'ListAddrBookAddresses' | ||
| struct AddrBookFilter { | ||
| // Fetch addresses with the provided label | ||
| std::optional<std::string> m_op_label{std::nullopt}; | ||
| // Don't include change addresses by default | ||
| bool ignore_change{true}; | ||
| }; | ||
|
|
||
| /** | ||
| * Filter and retrieve destinations stored in the addressbook | ||
| */ | ||
| std::vector<CTxDestination> ListAddrBookAddresses(const std::optional<AddrBookFilter>& filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||
|
|
||
| /** | ||
| * Retrieve all the known labels in the address book | ||
| */ | ||
| std::set<std::string> ListAddrBookLabels(const std::string& purpose) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||
|
|
||
| /** | ||
| * Walk-through the address book entries. | ||
| * Stops when the provided 'ListAddrBookFunc' returns false. | ||
| */ | ||
| using ListAddrBookFunc = std::function<void(const CTxDestination& dest, const std::string& label, const std::string& purpose, bool is_change)>; | ||
| void ForEachAddrBookEntry(const ListAddrBookFunc& func) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||
|
||
|
|
||
| /** | ||
| * Marks all outputs in each one of the destinations dirty, so their cache is | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.