Skip to content

Commit 2e68ffa

Browse files
committed
[doc] descriptor: explain GetPubKey() usage with cached public key
Plus a few typo fixes.
1 parent 2290269 commit 2e68ffa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/script/descriptor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,11 @@ class BIP32PubkeyProvider final : public PubkeyProvider
207207
/** Base class for all Descriptor implementations. */
208208
class DescriptorImpl : public Descriptor
209209
{
210-
//! Public key arguments for this descriptor (size 1 for PK, PKH, WPKH; any size of Multisig).
210+
//! Public key arguments for this descriptor (size 1 for PK, PKH, WPKH; any size for Multisig).
211211
const std::vector<std::unique_ptr<PubkeyProvider>> m_pubkey_args;
212212
//! The sub-descriptor argument (nullptr for everything but SH and WSH).
213+
//! In doc/descriptors.m this is referred to as SCRIPT expressions sh(SCRIPT)
214+
//! and wsh(SCRIPT), and distinct from KEY expressions and ADDR expressions.
213215
const std::unique_ptr<DescriptorImpl> m_subdescriptor_arg;
214216
//! The string name of the descriptor function.
215217
const std::string m_name;
@@ -295,6 +297,8 @@ class DescriptorImpl : public Descriptor
295297
// Construct temporary data in `entries` and `subscripts`, to avoid producing output in case of failure.
296298
for (const auto& p : m_pubkey_args) {
297299
entries.emplace_back();
300+
// If we have a cache, we don't need GetPubKey to compute the public key.
301+
// Pass in nullptr to signify only origin info is desired.
298302
if (!p->GetPubKey(pos, arg, cache_read ? nullptr : &entries.back().first, entries.back().second)) return false;
299303
if (cache_read) {
300304
// Cached expanded public key exists, use it.

src/script/descriptor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ struct Descriptor {
4646
*
4747
* pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored.
4848
* provider: the provider to query for private keys in case of hardened derivation.
49-
* output_script: the expanded scriptPubKeys will be put here.
49+
* output_scripts: the expanded scriptPubKeys will be put here.
5050
* out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider).
51-
* cache: vector which will be overwritten with cache data necessary to-evaluate the descriptor at this point without access to private keys.
51+
* cache: vector which will be overwritten with cache data necessary to evaluate the descriptor at this point without access to private keys.
5252
*/
5353
virtual bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out, std::vector<unsigned char>* cache = nullptr) const = 0;
5454

5555
/** Expand a descriptor at a specified position using cached expansion data.
5656
*
5757
* pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored.
5858
* cache: vector from which cached expansion data will be read.
59-
* output_script: the expanded scriptPubKeys will be put here.
59+
* output_scripts: the expanded scriptPubKeys will be put here.
6060
* out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider).
6161
*/
6262
virtual bool ExpandFromCache(int pos, const std::vector<unsigned char>& cache, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const = 0;

0 commit comments

Comments
 (0)