Merge pull request #5833 from therealyingtong/fix-orchard-z_listunspent

Correctly derive UAs for unknown Orchard receivers.
This commit is contained in:
Kris Nuttycombe 2022-04-06 14:54:25 -06:00 committed by GitHub
commit 834162a25e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -2612,10 +2612,9 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
if (account.has_value()) {
obj.pushKV("account", (uint64_t) account.value());
}
if (!isInternal) {
auto ua = pwalletMain->FindUnifiedAddressByReceiver(entry.GetAddress());
assert(ua.has_value());
obj.pushKV("address", keyIO.EncodePaymentAddress(ua.value()));
auto addr = pwalletMain->GetPaymentAddressForRecipient(entry.GetOutPoint().hash, entry.GetAddress());
if (addr.second != RecipientType::WalletInternalAddress) {
obj.pushKV("address", keyIO.EncodePaymentAddress(addr.first));
}
obj.pushKV("amount", ValueFromAmount(entry.GetNoteValue()));
obj.pushKV("memo", HexStr(entry.GetMemo()));
@ -4514,10 +4513,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
auto noteValue = orchardActionSpend.GetNoteValue();
std::optional<std::string> addrStr;
if (!pwalletMain->IsInternalRecipient(receivedAt)) {
auto ua = pwalletMain->FindUnifiedAddressByReceiver(receivedAt);
assert(ua.has_value());
addrStr = keyIO.EncodePaymentAddress(ua.value());
auto addr = pwalletMain->GetPaymentAddressForRecipient(txid, receivedAt);
if (addr.second != RecipientType::WalletInternalAddress) {
addrStr = keyIO.EncodePaymentAddress(addr.first);
}
UniValue entry(UniValue::VOBJ);