wallet: Fix Sapling address bug in `listaddresses`

`CWallet::FindUnifiedAddressByReceiver` is a wrapper around the visitor
`UnifiedAddressForReceiver`, which looks up the Unified Address (if any)
corresponding to the given receiver. However, this only returns external
UAs, and returns `std::nullopt` both if the receiver does not correspond
to a UFVK, and if it does but is derived from an internal FVK. By using
this method as a filter, `listaddresses` was not filtering out internal
Sapling receivers, and thus was leaking Sapling change addresses for
accounts (which we do not want revealed in the UI anywhere).

Instead, we now check for UFVK metadata directly, which verifies that
the Sapling receiver is derived from a UFVK without any extra filtering.
This commit is contained in:
Jack Grigg 2022-03-22 13:04:19 +00:00
parent 24089109b2
commit d4e47e4720
1 changed files with 1 additions and 2 deletions

View File

@ -555,8 +555,7 @@ UniValue listaddresses(const UniValue& params, bool fHelp)
SaplingIncomingViewingKey ivkRet;
if (pwalletMain->GetSaplingIncomingViewingKey(addr, ivkRet)) {
// Do not include any address that is associated with a unified key.
auto ua = pwalletMain->FindUnifiedAddressByReceiver(addr);
if (!ua.has_value()) {
if (!pwalletMain->GetUFVKMetadataForReceiver(addr).has_value()) {
ivkAddrs[ivkRet].push_back(addr);
}
}