MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / UpgradeDescriptorCache

Method UpgradeDescriptorCache

src/wallet/scriptpubkeyman.cpp:1570–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570void DescriptorScriptPubKeyMan::UpgradeDescriptorCache()
1571{
1572 LOCK(cs_desc_man);
1573 if (m_storage.IsLocked() || m_storage.IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
1574 return;
1575 }
1576
1577 // Skip if we have the last hardened xpub cache
1578 if (m_wallet_descriptor.cache.GetCachedLastHardenedExtPubKeys().size() > 0) {
1579 return;
1580 }
1581
1582 // Expand the descriptor
1583 FlatSigningProvider provider;
1584 provider.keys = GetKeys();
1585 FlatSigningProvider out_keys;
1586 std::vector<CScript> scripts_temp;
1587 DescriptorCache temp_cache;
1588 if (!m_wallet_descriptor.descriptor->Expand(0, provider, scripts_temp, out_keys, &temp_cache)){
1589 throw std::runtime_error("Unable to expand descriptor");
1590 }
1591
1592 // Cache the last hardened xpubs
1593 DescriptorCache diff = m_wallet_descriptor.cache.MergeAndDiff(temp_cache);
1594 if (!WalletBatch(m_storage.GetDatabase()).WriteDescriptorCacheItems(GetID(), diff)) {
1595 throw std::runtime_error(std::string(__func__) + ": writing cache items failed");
1596 }
1597}
1598
1599util::Result<void> DescriptorScriptPubKeyMan::UpdateWalletDescriptor(WalletDescriptor& descriptor, const FlatSigningProvider& provider)
1600{

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected