MCPcopy Create free account
hub / github.com/ElementsProject/elements / UpgradeDescriptorCache

Method UpgradeDescriptorCache

src/wallet/scriptpubkeyman.cpp:2340–2367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2338}
2339
2340void DescriptorScriptPubKeyMan::UpgradeDescriptorCache()
2341{
2342 LOCK(cs_desc_man);
2343 if (m_storage.IsLocked() || m_storage.IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
2344 return;
2345 }
2346
2347 // Skip if we have the last hardened xpub cache
2348 if (m_wallet_descriptor.cache.GetCachedLastHardenedExtPubKeys().size() > 0) {
2349 return;
2350 }
2351
2352 // Expand the descriptor
2353 FlatSigningProvider provider;
2354 provider.keys = GetKeys();
2355 FlatSigningProvider out_keys;
2356 std::vector<CScript> scripts_temp;
2357 DescriptorCache temp_cache;
2358 if (!m_wallet_descriptor.descriptor->Expand(0, provider, scripts_temp, out_keys, &temp_cache)){
2359 throw std::runtime_error("Unable to expand descriptor");
2360 }
2361
2362 // Cache the last hardened xpubs
2363 DescriptorCache diff = m_wallet_descriptor.cache.MergeAndDiff(temp_cache);
2364 if (!WalletBatch(m_storage.GetDatabase()).WriteDescriptorCacheItems(GetID(), diff)) {
2365 throw std::runtime_error(std::string(__func__) + ": writing cache items failed");
2366 }
2367}
2368
2369void DescriptorScriptPubKeyMan::UpdateWalletDescriptor(WalletDescriptor& descriptor)
2370{

Callers

nothing calls this directly

Calls 8

WalletBatchClass · 0.85
IsLockedMethod · 0.80
IsWalletFlagSetMethod · 0.80
ExpandMethod · 0.80
MergeAndDiffMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected