diff --git a/src/script/descriptor.h b/src/script/descriptor.h --- a/src/script/descriptor.h +++ b/src/script/descriptor.h @@ -11,22 +11,24 @@ #include -// Descriptors are strings that describe a set of scriptPubKeys, together with -// all information necessary to solve them. By combining all information into -// one, they avoid the need to separately import keys and scripts. -// -// Descriptors may be ranged, which occurs when the public keys inside are -// specified in the form of HD chains (xpubs). -// -// Descriptors always represent public information - public keys and scripts - -// but in cases where private keys need to be conveyed along with a descriptor, -// they can be included inside by changing public keys to private keys (WIF -// format), and changing xpubs by xprvs. -// -// Reference documentation about the descriptor language can be found in -// doc/descriptors.md. - -/** Interface for parsed descriptor objects. */ +/** + * \brief Interface for parsed descriptor objects. + * + * Descriptors are strings that describe a set of scriptPubKeys, together with + * all information necessary to solve them. By combining all information into + * one, they avoid the need to separately import keys and scripts. + * + * Descriptors may be ranged, which occurs when the public keys inside are + * specified in the form of HD chains (xpubs). + * + * Descriptors always represent public information - public keys and scripts - + * but in cases where private keys need to be conveyed along with a descriptor, + * they can be included inside by changing public keys to private keys (WIF + * format), and changing xpubs by xprvs. + * + * Reference documentation about the descriptor language can be found in + * doc/descriptors.md. + */ struct Descriptor { virtual ~Descriptor() = default; @@ -53,16 +55,15 @@ /** * Expand a descriptor at a specified position. * - * pos: the position at which to expand the descriptor. If IsRange() is - * false, this is ignored. - * provider: the provider to query for private keys in case of hardened - * derivation. - * output_scripts: 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. + * @param[in] pos: The position at which to expand the descriptor. If + * IsRange() is false, this is ignored. + * @param[in] provider: The provider to query for private keys in case of + * hardened derivation. + * @param[out] output_scripts: The expanded scriptPubKeys. + * @param[out] out: Scripts and public keys necessary for solving the + * expanded scriptPubKeys (may be equal to `provider`). + * @param[out] cache: 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 &output_scripts, @@ -72,12 +73,12 @@ /** * 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_scripts: 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). + * @param[in] pos: The position at which to expand the descriptor. If + * IsRange() is false, this is ignored. + * @param[in] cache: Cached expansion data. + * @param[out] output_scripts: The expanded scriptPubKeys. + * @param[out] out: Scripts and public keys necessary for solving the + * expanded scriptPubKeys (may be equal to `provider`). */ virtual bool ExpandFromCache(int pos, const std::vector &cache, std::vector &output_scripts, @@ -87,42 +88,41 @@ * Expand the private key for a descriptor at a specified position, if * possible. * - * pos: the position at which to expand the descriptor. If IsRange() is - * false, this is ignored. - * provider: the provider to query for the private keys. - * out: any private keys available for the specified pos will be placed - * here. + * @param[in] pos: The position at which to expand the descriptor. If + * IsRange() is false, this is ignored. + * @param[in] provider: The provider to query for the private keys. + * @param[out] out: Any private keys available for the specified `pos`. */ virtual void ExpandPrivate(int pos, const SigningProvider &provider, FlatSigningProvider &out) const = 0; }; /** - * Parse a descriptor string. Included private keys are put in out. + * Parse a `descriptor` string. Included private keys are put in `out`. * - * If the descriptor has a checksum, it must be valid. If require_checksum + * If the descriptor has a checksum, it must be valid. If `require_checksum` * is set, the checksum is mandatory - otherwise it is optional. * * If a parse error occurs, or the checksum is missing/invalid, or anything - * else is wrong, nullptr is returned. + * else is wrong, `nullptr` is returned. */ std::unique_ptr Parse(const std::string &descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum = false); /** - * Get the checksum for a descriptor. + * Get the checksum for a `descriptor`. * - * If it already has one, and it is correct, return the checksum in the input. - * If it already has one that is wrong, return "". - * If it does not already have one, return the checksum that would need to be + * - If it already has one, and it is correct, return the checksum in the input. + * - If it already has one that is wrong, return "". + * - If it does not already have one, return the checksum that would need to be * added. */ std::string GetDescriptorChecksum(const std::string &descriptor); /** - * Find a descriptor for the specified script, using information from provider - * where possible. + * Find a descriptor for the specified `script`, using information from + * `provider` where possible. * * A non-ranged descriptor which only generates the specified script will be * returned in all circumstances. @@ -131,10 +131,10 @@ * preserved in the returned descriptor. * * - If all information for solving `script` is present in `provider`, a - * descriptor will be returned which is `IsSolvable()` and encapsulates said + * descriptor will be returned which is IsSolvable() and encapsulates said * information. * - Failing that, if `script` corresponds to a known address type, an "addr()" - * descriptor will be returned (which is not `IsSolvable()`). + * descriptor will be returned (which is not IsSolvable()). * - Failing that, a "raw()" descriptor is returned. */ std::unique_ptr InferDescriptor(const CScript &script,