Skip to content

Commit 15ac916

Browse files
committed
doc: Doxygen-friendly descriptor.h comments
1 parent 3ce8298 commit 15ac916

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

src/script/descriptor.h

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@
1111

1212
#include <vector>
1313

14-
// Descriptors are strings that describe a set of scriptPubKeys, together with
15-
// all information necessary to solve them. By combining all information into
16-
// one, they avoid the need to separately import keys and scripts.
17-
//
18-
// Descriptors may be ranged, which occurs when the public keys inside are
19-
// specified in the form of HD chains (xpubs).
20-
//
21-
// Descriptors always represent public information - public keys and scripts -
22-
// but in cases where private keys need to be conveyed along with a descriptor,
23-
// they can be included inside by changing public keys to private keys (WIF
24-
// format), and changing xpubs by xprvs.
25-
//
26-
// Reference documentation about the descriptor language can be found in
27-
// doc/descriptors.md.
28-
29-
/** Interface for parsed descriptor objects. */
14+
15+
/** \brief Interface for parsed descriptor objects.
16+
*
17+
* Descriptors are strings that describe a set of scriptPubKeys, together with
18+
* all information necessary to solve them. By combining all information into
19+
* one, they avoid the need to separately import keys and scripts.
20+
*
21+
* Descriptors may be ranged, which occurs when the public keys inside are
22+
* specified in the form of HD chains (xpubs).
23+
*
24+
* Descriptors always represent public information - public keys and scripts -
25+
* but in cases where private keys need to be conveyed along with a descriptor,
26+
* they can be included inside by changing public keys to private keys (WIF
27+
* format), and changing xpubs by xprvs.
28+
*
29+
* Reference documentation about the descriptor language can be found in
30+
* doc/descriptors.md.
31+
*/
3032
struct Descriptor {
3133
virtual ~Descriptor() = default;
3234

@@ -45,51 +47,51 @@ struct Descriptor {
4547

4648
/** Expand a descriptor at a specified position.
4749
*
48-
* pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored.
49-
* provider: the provider to query for private keys in case of hardened derivation.
50-
* output_scripts: the expanded scriptPubKeys will be put here.
51-
* out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider).
52-
* cache: vector which will be overwritten with cache data necessary to evaluate the descriptor at this point without access to private keys.
50+
* @param[in] pos: The position at which to expand the descriptor. If IsRange() is false, this is ignored.
51+
* @param[in] provider: The provider to query for private keys in case of hardened derivation.
52+
* @param[out] output_scripts: The expanded scriptPubKeys.
53+
* @param[out] out: Scripts and public keys necessary for solving the expanded scriptPubKeys (may be equal to `provider`).
54+
* @param[out] cache: Cache data necessary to evaluate the descriptor at this point without access to private keys.
5355
*/
5456
virtual bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out, std::vector<unsigned char>* cache = nullptr) const = 0;
5557

5658
/** Expand a descriptor at a specified position using cached expansion data.
5759
*
58-
* pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored.
59-
* cache: vector from which cached expansion data will be read.
60-
* output_scripts: the expanded scriptPubKeys will be put here.
61-
* out: scripts and public keys necessary for solving the expanded scriptPubKeys will be put here (may be equal to provider).
60+
* @param[in] pos: The position at which to expand the descriptor. If IsRange() is false, this is ignored.
61+
* @param[in] cache: Cached expansion data.
62+
* @param[out] output_scripts: The expanded scriptPubKeys.
63+
* @param[out] out: Scripts and public keys necessary for solving the expanded scriptPubKeys (may be equal to `provider`).
6264
*/
6365
virtual bool ExpandFromCache(int pos, const std::vector<unsigned char>& cache, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const = 0;
6466

6567
/** Expand the private key for a descriptor at a specified position, if possible.
6668
*
67-
* pos: the position at which to expand the descriptor. If IsRange() is false, this is ignored.
68-
* provider: the provider to query for the private keys.
69-
* out: any private keys available for the specified pos will be placed here.
69+
* @param[in] pos: The position at which to expand the descriptor. If IsRange() is false, this is ignored.
70+
* @param[in] provider: The provider to query for the private keys.
71+
* @param[out] out: Any private keys available for the specified `pos`.
7072
*/
7173
virtual void ExpandPrivate(int pos, const SigningProvider& provider, FlatSigningProvider& out) const = 0;
7274
};
7375

74-
/** Parse a descriptor string. Included private keys are put in out.
76+
/** Parse a `descriptor` string. Included private keys are put in `out`.
7577
*
76-
* If the descriptor has a checksum, it must be valid. If require_checksum
78+
* If the descriptor has a checksum, it must be valid. If `require_checksum`
7779
* is set, the checksum is mandatory - otherwise it is optional.
7880
*
7981
* If a parse error occurs, or the checksum is missing/invalid, or anything
80-
* else is wrong, nullptr is returned.
82+
* else is wrong, `nullptr` is returned.
8183
*/
8284
std::unique_ptr<Descriptor> Parse(const std::string& descriptor, FlatSigningProvider& out, std::string& error, bool require_checksum = false);
8385

84-
/** Get the checksum for a descriptor.
86+
/** Get the checksum for a `descriptor`.
8587
*
86-
* If it already has one, and it is correct, return the checksum in the input.
87-
* If it already has one that is wrong, return "".
88-
* If it does not already have one, return the checksum that would need to be added.
88+
* - If it already has one, and it is correct, return the checksum in the input.
89+
* - If it already has one that is wrong, return "".
90+
* - If it does not already have one, return the checksum that would need to be added.
8991
*/
9092
std::string GetDescriptorChecksum(const std::string& descriptor);
9193

92-
/** Find a descriptor for the specified script, using information from provider where possible.
94+
/** Find a descriptor for the specified `script`, using information from `provider` where possible.
9395
*
9496
* A non-ranged descriptor which only generates the specified script will be returned in all
9597
* circumstances.
@@ -98,9 +100,9 @@ std::string GetDescriptorChecksum(const std::string& descriptor);
98100
* descriptor.
99101
*
100102
* - If all information for solving `script` is present in `provider`, a descriptor will be returned
101-
* which is `IsSolvable()` and encapsulates said information.
103+
* which is IsSolvable() and encapsulates said information.
102104
* - Failing that, if `script` corresponds to a known address type, an "addr()" descriptor will be
103-
* returned (which is not `IsSolvable()`).
105+
* returned (which is not IsSolvable()).
104106
* - Failing that, a "raw()" descriptor is returned.
105107
*/
106108
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);

0 commit comments

Comments
 (0)