Changeset View
Changeset View
Standalone View
Standalone View
src/script/descriptor.cpp
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | uint64_t PolyMod(uint64_t c, int val) { | ||||
} | } | ||||
if (c0 & 16) { | if (c0 & 16) { | ||||
c ^= 0x644d626ffd; | c ^= 0x644d626ffd; | ||||
} | } | ||||
return c; | return c; | ||||
} | } | ||||
std::string DescriptorChecksum(const Span<const char> &span) { | std::string DescriptorChecksum(const Span<const char> &span) { | ||||
/** A character set designed such that: | /** | ||||
* A character set designed such that: | |||||
* - The most common 'unprotected' descriptor characters (hex, keypaths) | * - The most common 'unprotected' descriptor characters (hex, keypaths) | ||||
* are in the first group of 32. | * are in the first group of 32. | ||||
* - Case errors cause an offset that's a multiple of 32. | * - Case errors cause an offset that's a multiple of 32. | ||||
* - As many alphabetic characters are in the same group (while following | * - As many alphabetic characters are in the same group (while following | ||||
* the above restrictions). | * the above restrictions). | ||||
* | * | ||||
* If p(x) gives the position of a character c in this character set, every | * If p(x) gives the position of a character c in this character set, every | ||||
* group of 3 characters (a,b,c) is encoded as the 4 symbols (p(a) & 31, | * group of 3 characters (a,b,c) is encoded as the 4 symbols (p(a) & 31, | ||||
* p(b) & 31, p(c) & 31, (p(a) / 32) + 3 * (p(b) / 32) + 9 * (p(c) / 32). | * p(b) & 31, p(c) & 31, (p(a) / 32) + 3 * (p(b) / 32) + 9 * (p(c) / 32). | ||||
* This means that changes that only affect the lower 5 bits of the | * This means that changes that only affect the lower 5 bits of the | ||||
* position, or only the higher 2 bits, will just affect a single symbol. | * position, or only the higher 2 bits, will just affect a single symbol. | ||||
* | * | ||||
* As a result, within-group-of-32 errors count as 1 symbol, as do | * As a result, within-group-of-32 errors count as 1 symbol, as do | ||||
▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | |||||
protected: | protected: | ||||
//! Return a serialization of anything except pubkey and script arguments, | //! Return a serialization of anything except pubkey and script arguments, | ||||
//! to be prepended to those. | //! to be prepended to those. | ||||
virtual std::string ToStringExtra() const { return ""; } | virtual std::string ToStringExtra() const { return ""; } | ||||
/** | /** | ||||
* A helper function to construct the scripts for this descriptor. | * A helper function to construct the scripts for this descriptor. | ||||
* | * | ||||
* This function is invoked once for every CScript produced by evaluating | * This function is invoked once for every CScript produced by evaluating | ||||
* m_subdescriptor_arg, or just once in case m_subdescriptor_arg is | * m_subdescriptor_arg, or just once in case m_subdescriptor_arg is nullptr. | ||||
nullptr. | * | ||||
* @param pubkeys The evaluations of the m_pubkey_args field. | * @param pubkeys The evaluations of the m_pubkey_args field. | ||||
* @param script The evaluation of m_subdescriptor_arg (or nullptr when | * @param script The evaluation of m_subdescriptor_arg (or nullptr when | ||||
m_subdescriptor_arg is nullptr). | * m_subdescriptor_arg is nullptr). | ||||
* @param out A FlatSigningProvider to put scripts or public keys in that | * @param out A FlatSigningProvider to put scripts or public keys in that | ||||
are necessary to the solver. | * are necessary to the solver. The script arguments to this | ||||
* The script arguments to this function are automatically | * function are automatically added, as is the origin info of the | ||||
added, as is the origin info of the provided pubkeys. | * provided pubkeys. | ||||
* @return A vector with scriptPubKeys for this descriptor. | * @return A vector with scriptPubKeys for this descriptor. | ||||
*/ | */ | ||||
virtual std::vector<CScript> | virtual std::vector<CScript> | ||||
MakeScripts(const std::vector<CPubKey> &pubkeys, const CScript *script, | MakeScripts(const std::vector<CPubKey> &pubkeys, const CScript *script, | ||||
FlatSigningProvider &out) const = 0; | FlatSigningProvider &out) const = 0; | ||||
public: | public: | ||||
DescriptorImpl(std::vector<std::unique_ptr<PubkeyProvider>> pubkeys, | DescriptorImpl(std::vector<std::unique_ptr<PubkeyProvider>> pubkeys, | ||||
std::unique_ptr<DescriptorImpl> script, | std::unique_ptr<DescriptorImpl> script, | ||||
▲ Show 20 Lines • Show All 760 Lines • Show Last 20 Lines |