diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-02-26 16:52:03 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-03-07 10:13:47 -0500 |
commit | deb791c7ba057a3765d09b12bf3e55547a5298e4 (patch) | |
tree | 8ed217eb7166a4a171b55ba4c1ebe90bfc736442 /src/script/descriptor.cpp | |
parent | f76733eda5f4c161e9eb47c74b949582ab8f448a (diff) |
Only cache xpubs that have a hardened last step
Also adds tests for this:
For ranged descriptors with unhardened derivation, we expect to
find parent keys in the cache but no child keys.
For descriptors containing an xpub but do not have unhardened derivation
(i.e. hardened derivation or single xpub with or without derivation),
we expect to find all of the keys in the cache, and the same
number of keys in the cache as in the SigningProvider.
For everything else (no xpub), nothing should be cached at all.
Diffstat (limited to 'src/script/descriptor.cpp')
-rw-r--r-- | src/script/descriptor.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 30384fbd06..588e583339 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -345,10 +345,11 @@ public: key_out = final_extkey.pubkey; if (write_cache) { - write_cache->CacheDerivedExtPubKey(m_expr_index, pos, final_extkey); // Only cache parent if there is any unhardened derivation if (m_derive != DeriveType::HARDENED) { write_cache->CacheParentExtPubKey(m_expr_index, parent_extkey); + } else if (final_info_out.path.size() > 0) { + write_cache->CacheDerivedExtPubKey(m_expr_index, pos, final_extkey); } } |