Skip to content

Commit

Permalink
wallet: Use scriptPubKeyCache in GetSolvingProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Dec 12, 2023
1 parent 66867bf commit 1702a2c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3453,11 +3453,19 @@ std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& scri

std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& script, SignatureData& sigdata) const
{
for (const auto& spk_man_pair : m_spk_managers) {
if (spk_man_pair.second->CanProvide(script, sigdata)) {
return spk_man_pair.second->GetSolvingProvider(script);
// Search the cache first
const auto& it = m_cached_spks.find(script);
if (it != m_cached_spks.end()) {
for (const auto& spkm : it->second) {
if (spkm->CanProvide(script, sigdata)) {
return spkm->GetSolvingProvider(script);
}
}
}

// Legacy wallet
if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) return GetLegacyScriptPubKeyMan()->GetSolvingProvider(script);

return nullptr;
}

Expand Down

0 comments on commit 1702a2c

Please sign in to comment.