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) {
|
[&](const libzcash::UnifiedAddress& addr) {
|
||||||
std::optional<libzcash::AccountId> singleAccount;
|
auto meta = GetUFVKMetadataForAddress(addr);
|
||||||
for (const auto& receiver : addr) {
|
if (meta.has_value()) {
|
||||||
auto meta = GetUFVKMetadataForReceiver(receiver);
|
result = self->GetUnifiedAccountId(meta.value().first);
|
||||||
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;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
singleAccount = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result = singleAccount;
|
|
||||||
},
|
},
|
||||||
[&](const libzcash::UnifiedFullViewingKey& vk) {
|
[&](const libzcash::UnifiedFullViewingKey& vk) {
|
||||||
result = self->GetUnifiedAccountId(vk.GetKeyID(Params()));
|
result = self->GetUnifiedAccountId(vk.GetKeyID(Params()));
|
||||||
|
|
Loading…
Reference in New Issue