diff options
author | MeshCollider <dobsonsa68@gmail.com> | 2018-12-12 16:31:52 +1300 |
---|---|---|
committer | MeshCollider <dobsonsa68@gmail.com> | 2018-12-12 17:24:26 +1300 |
commit | 3fff1ab817e7995720c3aa0374807ed70d1a4d24 (patch) | |
tree | 74d615745c2e2356eff2178f93d646c316d789b7 /src/script/descriptor.h | |
parent | f65bce858f266b352c9ddd1f5480431dca56fcae (diff) | |
parent | 26879509f1a3b9fc0fa616164e5a88fdb344ac4d (diff) |
Merge #14646: Add expansion cache functions to descriptors (unused for now)
26879509f Add comments to descriptor tests (Pieter Wuille)
82df4c64f Add descriptor expansion cache (Pieter Wuille)
1eda33aab [refactor] Combine the ToString and ToPrivateString implementations (Pieter Wuille)
24d3a7b3a [refactor] Use DescriptorImpl internally, permitting access to new methods (Pieter Wuille)
6be0fb4b3 [refactor] Add a base DescriptorImpl with most common logic (Pieter Wuille)
Pull request description:
This patch modifies the internal `Descriptor` class to optionally construct and use an "expansion cache". Such a cache is a byte array that encodes all information necessary to expand a `Descriptor` a second time without access to private keys, and without the need to perform expensive BIP32 derivations. For all currently defined descriptors, the cache simply contains a concatenation of all public keys used.
This is motivated by the goal of importing a descriptor into the wallet and using it as a replacement for the keypool, where it would be impossible to expand descriptors if they use hardened derivation.
Tree-SHA512: f531a0a82ec1eecc30b78ba8a31724d1249826b028cc3543ad32372e1aedd537f137ab03dbffc222c5df444d5865ecd5cec754c1ae1d4989b6e9baeaffade32a
Diffstat (limited to 'src/script/descriptor.h')
-rw-r--r-- | src/script/descriptor.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/script/descriptor.h b/src/script/descriptor.h index 0111972f85..44f0efca03 100644 --- a/src/script/descriptor.h +++ b/src/script/descriptor.h @@ -48,8 +48,18 @@ struct Descriptor { * provider: the provider to query for private keys in case of hardened derivation. * output_script: the expanded scriptPubKeys will be put here. * out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider). + * cache: vector which will be overwritten with cache data necessary to-evaluate the descriptor at this point without access to private keys. */ - virtual bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const = 0; + virtual bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out, std::vector<unsigned char>* cache = nullptr) const = 0; + + /** Expand a descriptor at a specified position using cached expansion data. + * + * pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored. + * cache: vector from which cached expansion data will be read. + * output_script: the expanded scriptPubKeys will be put here. + * out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider). + */ + virtual bool ExpandFromCache(int pos, const std::vector<unsigned char>& cache, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const = 0; }; /** Parse a descriptor string. Included private keys are put in out. Returns nullptr if parsing fails. */ |