Repository: bitcoin/bitcoin
File: src/script/descriptor.h (C/C++)

Code before:
     *
     * @param use_max_sig Whether to assume ECDSA signatures will have a high-r.
     */
    virtual std::optional<int64_t> MaxSatisfactionWeight(bool use_max_sig) const = 0;

    /** Get the maximum size number of stack elements for satisfying this descriptor. */
    virtual std::optional<int64_t> MaxSatisfactionElems() const = 0;

    /** Return all (extended) public keys for this descriptor, including any from subdescriptors.
     *
     * @param[out] pubkeys Any public keys
     * @param[out] ext_pubs Any extended public keys
     */
    virtual void GetPubKeys(std::set<CPubKey>& pubkeys, std::set<CExtPubKey>& ext_pubs) const = 0;
};

/** Parse a `descriptor` string. Included private keys are put in `out`.
 *
 * 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, an empty vector is returned.
 */
std::vector<std::unique_ptr<Descriptor>> Parse(std::span<const char> descriptor, FlatSigningProvider& out, std::string& error, bool require_checksum = false);

/** 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.
 */
std::string GetDescriptorChecksum(const std::string& descriptor);

/** 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.
 *
 * For public keys with key origin information, this information will be 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 information.
 * - Failing that, if `script` corresponds to a known address type, an "addr()" descriptor will be
 *   returned (which is not IsSolvable()).
 * - Failing that, a "raw()" descriptor is returned.
 */
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);

/** Unique identifier that may not change over time, unless explicitly marked as not backwards compatible.

Review comment (suggestion):
string_view is already on `const char` and the const here can be removed. See also a bit related: https://github.com/bitcoin/bitcoin/pull/31650

Code after:
     *
     * @param use_max_sig Whether to assume ECDSA signatures will have a high-r.
     */
    virtual std::optional<int64_t> MaxSatisfactionWeight(bool use_max_sig) const = 0;

    /** Get the maximum size number of stack elements for satisfying this descriptor. */
    virtual std::optional<int64_t> MaxSatisfactionElems() const = 0;

    /** Return all (extended) public keys for this descriptor, including any from subdescriptors.
     *
     * @param[out] pubkeys Any public keys
     * @param[out] ext_pubs Any extended public keys
     */
    virtual void GetPubKeys(std::set<CPubKey>& pubkeys, std::set<CExtPubKey>& ext_pubs) const = 0;
};

/** Parse a `descriptor` string. Included private keys are put in `out`.
 *
 * 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, an empty vector is returned.
 */
std::vector<std::unique_ptr<Descriptor>> Parse(std::string_view descriptor, FlatSigningProvider& out, std::string& error, bool require_checksum = false);

/** 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.
 */
std::string GetDescriptorChecksum(const std::string& descriptor);

/** 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.
 *
 * For public keys with key origin information, this information will be 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 information.
 * - Failing that, if `script` corresponds to a known address type, an "addr()" descriptor will be
 *   returned (which is not IsSolvable()).
 * - Failing that, a "raw()" descriptor is returned.
 */
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);

/** Unique identifier that may not change over time, unless explicitly marked as not backwards compatible.