| 2338 | } |
| 2339 | |
| 2340 | void 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 | |
| 2369 | void DescriptorScriptPubKeyMan::UpdateWalletDescriptor(WalletDescriptor& descriptor) |
| 2370 | { |
nothing calls this directly
no test coverage detected