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

Method MergeAndDiff

src/script/descriptor.cpp:1468–1507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1466}
1467
1468DescriptorCache DescriptorCache::MergeAndDiff(const DescriptorCache& other)
1469{
1470 DescriptorCache diff;
1471 for (const auto& parent_xpub_pair : other.GetCachedParentExtPubKeys()) {
1472 CExtPubKey xpub;
1473 if (GetCachedParentExtPubKey(parent_xpub_pair.first, xpub)) {
1474 if (xpub != parent_xpub_pair.second) {
1475 throw std::runtime_error(std::string(__func__) + ": New cached parent xpub does not match already cached parent xpub");
1476 }
1477 continue;
1478 }
1479 CacheParentExtPubKey(parent_xpub_pair.first, parent_xpub_pair.second);
1480 diff.CacheParentExtPubKey(parent_xpub_pair.first, parent_xpub_pair.second);
1481 }
1482 for (const auto& derived_xpub_map_pair : other.GetCachedDerivedExtPubKeys()) {
1483 for (const auto& derived_xpub_pair : derived_xpub_map_pair.second) {
1484 CExtPubKey xpub;
1485 if (GetCachedDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, xpub)) {
1486 if (xpub != derived_xpub_pair.second) {
1487 throw std::runtime_error(std::string(__func__) + ": New cached derived xpub does not match already cached derived xpub");
1488 }
1489 continue;
1490 }
1491 CacheDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, derived_xpub_pair.second);
1492 diff.CacheDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, derived_xpub_pair.second);
1493 }
1494 }
1495 for (const auto& lh_xpub_pair : other.GetCachedLastHardenedExtPubKeys()) {
1496 CExtPubKey xpub;
1497 if (GetCachedLastHardenedExtPubKey(lh_xpub_pair.first, xpub)) {
1498 if (xpub != lh_xpub_pair.second) {
1499 throw std::runtime_error(std::string(__func__) + ": New cached last hardened xpub does not match already cached last hardened xpub");
1500 }
1501 continue;
1502 }
1503 CacheLastHardenedExtPubKey(lh_xpub_pair.first, lh_xpub_pair.second);
1504 diff.CacheLastHardenedExtPubKey(lh_xpub_pair.first, lh_xpub_pair.second);
1505 }
1506 return diff;
1507}
1508
1509const ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
1510{

Callers 2

TopUpMethod · 0.80

Tested by

no test coverage detected