@@ -52,6 +52,7 @@ const std::string TX{"tx"};
52
52
const std::string VERSION{" version" };
53
53
const std::string WALLETDESCRIPTOR{" walletdescriptor" };
54
54
const std::string WALLETDESCRIPTORCACHE{" walletdescriptorcache" };
55
+ const std::string WALLETDESCRIPTORLHCACHE{" walletdescriptorlhcache" };
55
56
const std::string WALLETDESCRIPTORCKEY{" walletdescriptorckey" };
56
57
const std::string WALLETDESCRIPTORKEY{" walletdescriptorkey" };
57
58
const std::string WATCHMETA{" watchmeta" };
@@ -248,6 +249,13 @@ bool WalletBatch::WriteDescriptorParentCache(const CExtPubKey& xpub, const uint2
248
249
return WriteIC (std::make_pair (std::make_pair (DBKeys::WALLETDESCRIPTORCACHE, desc_id), key_exp_index), ser_xpub);
249
250
}
250
251
252
+ bool WalletBatch::WriteDescriptorLastHardenedCache (const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index)
253
+ {
254
+ std::vector<unsigned char > ser_xpub (BIP32_EXTKEY_SIZE);
255
+ xpub.Encode (ser_xpub.data ());
256
+ return WriteIC (std::make_pair (std::make_pair (DBKeys::WALLETDESCRIPTORLHCACHE, desc_id), key_exp_index), ser_xpub);
257
+ }
258
+
251
259
bool WalletBatch::WriteDescriptorCacheItems (const uint256& desc_id, const DescriptorCache& cache)
252
260
{
253
261
for (const auto & parent_xpub_pair : cache.GetCachedParentExtPubKeys ()) {
@@ -262,6 +270,11 @@ bool WalletBatch::WriteDescriptorCacheItems(const uint256& desc_id, const Descri
262
270
}
263
271
}
264
272
}
273
+ for (const auto & lh_xpub_pair : cache.GetCachedLastHardenedExtPubKeys ()) {
274
+ if (!WriteDescriptorLastHardenedCache (lh_xpub_pair.second , desc_id, lh_xpub_pair.first )) {
275
+ return false ;
276
+ }
277
+ }
265
278
return true ;
266
279
}
267
280
@@ -619,6 +632,17 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
619
632
} else {
620
633
wss.m_descriptor_caches [desc_id].CacheDerivedExtPubKey (key_exp_index, der_index, xpub);
621
634
}
635
+ } else if (strType == DBKeys::WALLETDESCRIPTORLHCACHE) {
636
+ uint256 desc_id;
637
+ uint32_t key_exp_index;
638
+ ssKey >> desc_id;
639
+ ssKey >> key_exp_index;
640
+
641
+ std::vector<unsigned char > ser_xpub (BIP32_EXTKEY_SIZE);
642
+ ssValue >> ser_xpub;
643
+ CExtPubKey xpub;
644
+ xpub.Decode (ser_xpub.data ());
645
+ wss.m_descriptor_caches [desc_id].CacheLastHardenedExtPubKey (key_exp_index, xpub);
622
646
} else if (strType == DBKeys::WALLETDESCRIPTORKEY) {
623
647
uint256 desc_id;
624
648
CPubKey pubkey;
0 commit comments