| 1568 | } |
| 1569 | |
| 1570 | void 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 | |
| 1599 | util::Result<void> DescriptorScriptPubKeyMan::UpdateWalletDescriptor(WalletDescriptor& descriptor, const FlatSigningProvider& provider) |
| 1600 | { |
nothing calls this directly
no test coverage detected