Merge pull request #5597 from nuttycom/feature/wallet_orchard-find_spendable_inputs

Select Orchard notes in FindSpendableInputs
This commit is contained in:
Kris Nuttycombe 2022-02-25 08:36:19 -07:00 committed by GitHub
commit f9380572c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -1955,6 +1955,39 @@ SpendableInputs CWallet::FindSpendableInputs(
}
}
// for Orchard, we select both the internal and external IVKs.
auto orchardIvks = std::visit(match {
[&](const libzcash::UnifiedFullViewingKey& ufvk) -> std::vector<OrchardIncomingViewingKey> {
auto fvk = ufvk.GetOrchardKey();
if (fvk.has_value()) {
return {fvk->ToIncomingViewingKey(), fvk->ToInternalIncomingViewingKey()};
}
return {};
},
[&](const AccountZTXOPattern& acct) -> std::vector<OrchardIncomingViewingKey> {
auto ufvk = GetUnifiedFullViewingKeyByAccount(acct.GetAccountId());
if (ufvk.has_value()) {
auto fvk = ufvk->GetOrchardKey();
if (fvk.has_value()) {
return {fvk->ToIncomingViewingKey(), fvk->ToInternalIncomingViewingKey()};
}
}
return {};
},
[&](const auto& addr) -> std::vector<OrchardIncomingViewingKey> { return {}; }
}, selector.GetPattern());
for (const auto& ivk : orchardIvks) {
// TODO ORCHARD: Allow the minimum number of confirmations
// to be specified
std::vector<OrchardNoteMetadata> incomingNotes;
orchardWallet.GetFilteredNotes(incomingNotes, ivk, true, true, true);
unspent.orchardNoteMetadata.insert(
unspent.orchardNoteMetadata.begin(),
incomingNotes.begin(),
incomingNotes.end());
}
return unspent;
}