Merge #16947: doc: Doxygen-friendly script/descriptor.h comments

15ac916642f20918f66e32729bb6b0b674e3bc24 doc: Doxygen-friendly descriptor.h comments (Jon Layton)

Pull request description:

  Closes #16942.

  - Make `Descriptor` overview subtext of `Interface for parsed descriptor objects.`
  - Conform to `@param[in, out] argname: Info` in parameter comments. Present in code: feb162d500/src/net_processing.cpp (L1001)
  - Remove redundant argument type, `in` vs `out` mentions
  - Removed unnecessary backticks around `IsSolvable()`, since Doxygen builds a link to the known function's docs
  - Add backticks to refer to `argname`s

  `descriptor.cpp` has more documentation, but Doxygen's output doesn't include anything inside unnamed namespaces for some reason. Tried to access them via searchbar.

Top commit has no ACKs.

Tree-SHA512: 587cc7596de46358a08b0321a7cf08a08785945715dbdce8945d837e1bee0664d1e11b1e47b7be85c4f35262f7ea173fb1f6202efcacc2023e2c6b0bd44133b3
This commit is contained in:
MarcoFalke 2019-10-11 16:27:57 -04:00 committed by Vijay Das Manikpuri
parent 27727c7541
commit 58f232325a
No known key found for this signature in database
GPG Key ID: DB1D81B01DB7C46E

View File

@ -10,22 +10,24 @@
#include <vector>
// 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;
@ -44,43 +46,43 @@ struct Descriptor {
/** 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<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_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<unsigned char>& cache, std::vector<CScript>& output_scripts, 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<Descriptor> 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 added.
* - 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.
@ -89,9 +91,9 @@ std::string GetDescriptorChecksum(const std::string& descriptor);
* descriptor.
*
* - If all information for solving `script` is present in `provider`, a descriptor will be returned
* which is `IsSolvable()` and encapsulates said information.
* 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()`).
* returned (which is not IsSolvable()).
* - Failing that, a "raw()" descriptor is returned.
*/
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);