Simplify retrieval of unified account by address.
Co-authored-by: ying tong <yingtong@z.cash>
This commit is contained in:
parent
9582a2c1f1
commit
a783de43e3
|
@ -1773,25 +1773,10 @@ std::optional<libzcash::AccountId> CWallet::FindAccountForSelector(const ZTXOSel
|
|||
}
|
||||
},
|
||||
[&](const libzcash::UnifiedAddress& addr) {
|
||||
std::optional<libzcash::AccountId> singleAccount;
|
||||
for (const auto& receiver : addr) {
|
||||
auto meta = GetUFVKMetadataForReceiver(receiver);
|
||||
auto meta = GetUFVKMetadataForAddress(addr);
|
||||
if (meta.has_value()) {
|
||||
auto tmp = self->GetUnifiedAccountId(meta.value().first);
|
||||
if (singleAccount.has_value()) {
|
||||
// If a UA corresponds to more than one account, we cannot return
|
||||
// a sensible result, so we report it as corresponding to no
|
||||
// account.
|
||||
if (tmp.has_value() && singleAccount.value() != tmp.value()) {
|
||||
singleAccount = std::nullopt;
|
||||
break;
|
||||
result = self->GetUnifiedAccountId(meta.value().first);
|
||||
}
|
||||
} else {
|
||||
singleAccount = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = singleAccount;
|
||||
},
|
||||
[&](const libzcash::UnifiedFullViewingKey& vk) {
|
||||
result = self->GetUnifiedAccountId(vk.GetKeyID(Params()));
|
||||
|
|
Loading…
Reference in New Issue