z_getbalance: Handle Unified Address case.

This commit is contained in:
therealyingtong 2022-03-14 21:37:20 +08:00 committed by Kris Nuttycombe
parent c3c5236cee
commit 6caec7aef1
2 changed files with 15 additions and 3 deletions

View File

@ -3706,9 +3706,18 @@ UniValue z_getbalance(const UniValue& params, bool fHelp)
nBalance = getBalanceZaddr(addr, nMinDepth, INT_MAX, false);
},
[&](const libzcash::UnifiedAddress& addr) {
throw JSONRPCError(
RPC_INVALID_ADDRESS_OR_KEY,
"Unified addresses are not yet supported for z_getbalance.");
auto selector = pwalletMain->ZTXOSelectorForAddress(addr, true);
auto spendableInputs = pwalletMain->FindSpendableInputs(selector.value(), true, nMinDepth);
for (const auto& t : spendableInputs.utxos) {
nBalance += t.Value();
}
for (const auto& t : spendableInputs.saplingNoteEntries) {
nBalance += t.note.value();
}
for (const auto& t : spendableInputs.orchardNoteMetadata) {
nBalance += t.GetNoteValue();
}
},
}, pa.value());

View File

@ -6341,6 +6341,9 @@ NoteFilter NoteFilter::ForPaymentAddresses(const std::vector<libzcash::PaymentAd
[&](const libzcash::UnifiedAddress& uaddr) {
for (auto& receiver : uaddr) {
std::visit(match {
[&](const libzcash::OrchardRawAddress& addr) {
addrs.orchardAddresses.insert(addr);
},
[&](const libzcash::SaplingPaymentAddress& addr) {
addrs.saplingAddresses.insert(addr);
},