aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-02-02 14:17:05 -0500
committerAva Chow <github@achow101.com>2024-02-16 14:36:10 -0500
commit39640dd34e980e69d13664ddbc2a7612a1888ab4 (patch)
tree2786cc6e6c57d35d6a7fe03e8c7359d8b36e61dd /src/wallet/wallet.cpp
parentb410f68791143800968f4c628beda1c9f898b4f6 (diff)
downloadbitcoin-39640dd34e980e69d13664ddbc2a7612a1888ab4.tar.xz
wallet: Use scriptPubKeyCache in GetSolvingProvider
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index e43243cb55..ad09dcd38d 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3467,11 +3467,17 @@ 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 for relevant SPKMs instead of iterating m_spk_managers
+ const auto& it = m_cached_spks.find(script);
+ if (it != m_cached_spks.end()) {
+ // All spkms for a given script must already be able to make a SigningProvider for the script, so just return the first one.
+ Assume(it->second.at(0)->CanProvide(script, sigdata));
+ return it->second.at(0)->GetSolvingProvider(script);
}
+
+ // Legacy wallet
+ if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) return GetLegacyScriptPubKeyMan()->GetSolvingProvider(script);
+
return nullptr;
}