Changeset View
Changeset View
Standalone View
Standalone View
src/script/descriptor.cpp
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | |||||
class AddressDescriptor final : public Descriptor { | class AddressDescriptor final : public Descriptor { | ||||
CTxDestination m_destination; | CTxDestination m_destination; | ||||
public: | public: | ||||
AddressDescriptor(CTxDestination destination) | AddressDescriptor(CTxDestination destination) | ||||
: m_destination(std::move(destination)) {} | : m_destination(std::move(destination)) {} | ||||
bool IsRange() const override { return false; } | bool IsRange() const override { return false; } | ||||
bool IsSolvable() const override { return false; } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
return "addr(" + EncodeDestination(m_destination, GetConfig()) + ")"; | return "addr(" + EncodeDestination(m_destination, GetConfig()) + ")"; | ||||
} | } | ||||
bool ToPrivateString(const SigningProvider &arg, | bool ToPrivateString(const SigningProvider &arg, | ||||
std::string &out) const override { | std::string &out) const override { | ||||
out = ToString(); | out = ToString(); | ||||
return true; | return true; | ||||
} | } | ||||
Show All 9 Lines | |||||
/** A parsed raw(H) descriptor. */ | /** A parsed raw(H) descriptor. */ | ||||
class RawDescriptor final : public Descriptor { | class RawDescriptor final : public Descriptor { | ||||
CScript m_script; | CScript m_script; | ||||
public: | public: | ||||
RawDescriptor(CScript script) : m_script(std::move(script)) {} | RawDescriptor(CScript script) : m_script(std::move(script)) {} | ||||
bool IsRange() const override { return false; } | bool IsRange() const override { return false; } | ||||
bool IsSolvable() const override { return false; } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
return "raw(" + HexStr(m_script.begin(), m_script.end()) + ")"; | return "raw(" + HexStr(m_script.begin(), m_script.end()) + ")"; | ||||
} | } | ||||
bool ToPrivateString(const SigningProvider &arg, | bool ToPrivateString(const SigningProvider &arg, | ||||
std::string &out) const override { | std::string &out) const override { | ||||
out = ToString(); | out = ToString(); | ||||
return true; | return true; | ||||
} | } | ||||
Show All 13 Lines | |||||
public: | public: | ||||
SingleKeyDescriptor(std::unique_ptr<PubkeyProvider> prov, | SingleKeyDescriptor(std::unique_ptr<PubkeyProvider> prov, | ||||
const std::function<CScript(const CPubKey &)> &fn, | const std::function<CScript(const CPubKey &)> &fn, | ||||
const std::string &name) | const std::string &name) | ||||
: m_script_fn(fn), m_fn_name(name), m_provider(std::move(prov)) {} | : m_script_fn(fn), m_fn_name(name), m_provider(std::move(prov)) {} | ||||
bool IsRange() const override { return m_provider->IsRange(); } | bool IsRange() const override { return m_provider->IsRange(); } | ||||
bool IsSolvable() const override { return true; } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
return m_fn_name + "(" + m_provider->ToString() + ")"; | return m_fn_name + "(" + m_provider->ToString() + ")"; | ||||
} | } | ||||
bool ToPrivateString(const SigningProvider &arg, | bool ToPrivateString(const SigningProvider &arg, | ||||
std::string &out) const override { | std::string &out) const override { | ||||
std::string ret; | std::string ret; | ||||
if (!m_provider->ToPrivateString(arg, ret)) { | if (!m_provider->ToPrivateString(arg, ret)) { | ||||
return false; | return false; | ||||
Show All 37 Lines | bool IsRange() const override { | ||||
for (const auto &p : m_providers) { | for (const auto &p : m_providers) { | ||||
if (p->IsRange()) { | if (p->IsRange()) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
bool IsSolvable() const override { return true; } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
std::string ret = strprintf("multi(%i", m_threshold); | std::string ret = strprintf("multi(%i", m_threshold); | ||||
for (const auto &p : m_providers) { | for (const auto &p : m_providers) { | ||||
ret += "," + p->ToString(); | ret += "," + p->ToString(); | ||||
} | } | ||||
return std::move(ret) + ")"; | return std::move(ret) + ")"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
public: | public: | ||||
ConvertorDescriptor(std::unique_ptr<Descriptor> descriptor, | ConvertorDescriptor(std::unique_ptr<Descriptor> descriptor, | ||||
const std::function<CScript(const CScript &)> &fn, | const std::function<CScript(const CScript &)> &fn, | ||||
const std::string &name) | const std::string &name) | ||||
: m_convert_fn(fn), m_fn_name(name), | : m_convert_fn(fn), m_fn_name(name), | ||||
m_descriptor(std::move(descriptor)) {} | m_descriptor(std::move(descriptor)) {} | ||||
bool IsRange() const override { return m_descriptor->IsRange(); } | bool IsRange() const override { return m_descriptor->IsRange(); } | ||||
bool IsSolvable() const override { return m_descriptor->IsSolvable(); } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
return m_fn_name + "(" + m_descriptor->ToString() + ")"; | return m_fn_name + "(" + m_descriptor->ToString() + ")"; | ||||
} | } | ||||
bool ToPrivateString(const SigningProvider &arg, | bool ToPrivateString(const SigningProvider &arg, | ||||
std::string &out) const override { | std::string &out) const override { | ||||
std::string ret; | std::string ret; | ||||
if (!m_descriptor->ToPrivateString(arg, ret)) { | if (!m_descriptor->ToPrivateString(arg, ret)) { | ||||
return false; | return false; | ||||
Show All 26 Lines | |||||
class ComboDescriptor final : public Descriptor { | class ComboDescriptor final : public Descriptor { | ||||
std::unique_ptr<PubkeyProvider> m_provider; | std::unique_ptr<PubkeyProvider> m_provider; | ||||
public: | public: | ||||
ComboDescriptor(std::unique_ptr<PubkeyProvider> provider) | ComboDescriptor(std::unique_ptr<PubkeyProvider> provider) | ||||
: m_provider(std::move(provider)) {} | : m_provider(std::move(provider)) {} | ||||
bool IsRange() const override { return m_provider->IsRange(); } | bool IsRange() const override { return m_provider->IsRange(); } | ||||
bool IsSolvable() const override { return true; } | |||||
std::string ToString() const override { | std::string ToString() const override { | ||||
return "combo(" + m_provider->ToString() + ")"; | return "combo(" + m_provider->ToString() + ")"; | ||||
} | } | ||||
bool ToPrivateString(const SigningProvider &arg, | bool ToPrivateString(const SigningProvider &arg, | ||||
std::string &out) const override { | std::string &out) const override { | ||||
std::string ret; | std::string ret; | ||||
if (!m_provider->ToPrivateString(arg, ret)) { | if (!m_provider->ToPrivateString(arg, ret)) { | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |