Changeset View
Changeset View
Standalone View
Standalone View
src/script/descriptor.cpp
Show First 20 Lines • Show All 700 Lines • ▼ Show 20 Lines | void ExpandPrivate(int pos, const SigningProvider &provider, | ||||
} | } | ||||
if (m_subdescriptor_arg) { | if (m_subdescriptor_arg) { | ||||
FlatSigningProvider subprovider; | FlatSigningProvider subprovider; | ||||
m_subdescriptor_arg->ExpandPrivate(pos, provider, subprovider); | m_subdescriptor_arg->ExpandPrivate(pos, provider, subprovider); | ||||
out = Merge(out, subprovider); | out = Merge(out, subprovider); | ||||
} | } | ||||
} | } | ||||
Optional<OutputType> GetOutputType() const override { return nullopt; } | std::optional<OutputType> GetOutputType() const override { | ||||
return std::nullopt; | |||||
} | |||||
}; | }; | ||||
/** A parsed addr(A) descriptor. */ | /** A parsed addr(A) descriptor. */ | ||||
class AddressDescriptor final : public DescriptorImpl { | class AddressDescriptor final : public DescriptorImpl { | ||||
const CTxDestination m_destination; | const CTxDestination m_destination; | ||||
protected: | protected: | ||||
std::string ToStringExtra() const override { | std::string ToStringExtra() const override { | ||||
return EncodeDestination(m_destination, GetConfig()); | return EncodeDestination(m_destination, GetConfig()); | ||||
} | } | ||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey> &, | std::vector<CScript> MakeScripts(const std::vector<CPubKey> &, | ||||
const CScript *, | const CScript *, | ||||
FlatSigningProvider &) const override { | FlatSigningProvider &) const override { | ||||
return Vector(GetScriptForDestination(m_destination)); | return Vector(GetScriptForDestination(m_destination)); | ||||
} | } | ||||
public: | public: | ||||
AddressDescriptor(CTxDestination destination) | AddressDescriptor(CTxDestination destination) | ||||
: DescriptorImpl({}, {}, "addr"), | : DescriptorImpl({}, {}, "addr"), | ||||
m_destination(std::move(destination)) {} | m_destination(std::move(destination)) {} | ||||
bool IsSolvable() const final { return false; } | bool IsSolvable() const final { return false; } | ||||
Optional<OutputType> GetOutputType() const override { | std::optional<OutputType> GetOutputType() const override { | ||||
switch (m_destination.which()) { | switch (m_destination.which()) { | ||||
case 1 /* PKHash */: | case 1 /* PKHash */: | ||||
case 2 /* ScriptHash */: | case 2 /* ScriptHash */: | ||||
return OutputType::LEGACY; | return OutputType::LEGACY; | ||||
case 0 /* CNoDestination */: | case 0 /* CNoDestination */: | ||||
default: | default: | ||||
return nullopt; | return std::nullopt; | ||||
} | } | ||||
} | } | ||||
bool IsSingleType() const final { return true; } | bool IsSingleType() const final { return true; } | ||||
}; | }; | ||||
/** A parsed raw(H) descriptor. */ | /** A parsed raw(H) descriptor. */ | ||||
class RawDescriptor final : public DescriptorImpl { | class RawDescriptor final : public DescriptorImpl { | ||||
const CScript m_script; | const CScript m_script; | ||||
protected: | protected: | ||||
std::string ToStringExtra() const override { | std::string ToStringExtra() const override { | ||||
return HexStr(m_script.begin(), m_script.end()); | return HexStr(m_script.begin(), m_script.end()); | ||||
} | } | ||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey> &, | std::vector<CScript> MakeScripts(const std::vector<CPubKey> &, | ||||
const CScript *, | const CScript *, | ||||
FlatSigningProvider &) const override { | FlatSigningProvider &) const override { | ||||
return Vector(m_script); | return Vector(m_script); | ||||
} | } | ||||
public: | public: | ||||
RawDescriptor(CScript script) | RawDescriptor(CScript script) | ||||
: DescriptorImpl({}, {}, "raw"), m_script(std::move(script)) {} | : DescriptorImpl({}, {}, "raw"), m_script(std::move(script)) {} | ||||
bool IsSolvable() const final { return false; } | bool IsSolvable() const final { return false; } | ||||
Optional<OutputType> GetOutputType() const override { | std::optional<OutputType> GetOutputType() const override { | ||||
CTxDestination dest; | CTxDestination dest; | ||||
ExtractDestination(m_script, dest); | ExtractDestination(m_script, dest); | ||||
switch (dest.which()) { | switch (dest.which()) { | ||||
case 1 /* PKHash */: | case 1 /* PKHash */: | ||||
case 2 /* ScriptHash */: | case 2 /* ScriptHash */: | ||||
return OutputType::LEGACY; | return OutputType::LEGACY; | ||||
case 0 /* CNoDestination */: | case 0 /* CNoDestination */: | ||||
default: | default: | ||||
return nullopt; | return std::nullopt; | ||||
} | } | ||||
} | } | ||||
bool IsSingleType() const final { return true; } | bool IsSingleType() const final { return true; } | ||||
}; | }; | ||||
/** A parsed pk(P) descriptor. */ | /** A parsed pk(P) descriptor. */ | ||||
class PKDescriptor final : public DescriptorImpl { | class PKDescriptor final : public DescriptorImpl { | ||||
protected: | protected: | ||||
Show All 18 Lines | std::vector<CScript> MakeScripts(const std::vector<CPubKey> &keys, | ||||
CKeyID id = keys[0].GetID(); | CKeyID id = keys[0].GetID(); | ||||
out.pubkeys.emplace(id, keys[0]); | out.pubkeys.emplace(id, keys[0]); | ||||
return Vector(GetScriptForDestination(PKHash(id))); | return Vector(GetScriptForDestination(PKHash(id))); | ||||
} | } | ||||
public: | public: | ||||
PKHDescriptor(std::unique_ptr<PubkeyProvider> prov) | PKHDescriptor(std::unique_ptr<PubkeyProvider> prov) | ||||
: DescriptorImpl(Vector(std::move(prov)), {}, "pkh") {} | : DescriptorImpl(Vector(std::move(prov)), {}, "pkh") {} | ||||
Optional<OutputType> GetOutputType() const override { | std::optional<OutputType> GetOutputType() const override { | ||||
return OutputType::LEGACY; | return OutputType::LEGACY; | ||||
} | } | ||||
bool IsSingleType() const final { return true; } | bool IsSingleType() const final { return true; } | ||||
}; | }; | ||||
/** A parsed combo(P) descriptor. */ | /** A parsed combo(P) descriptor. */ | ||||
class ComboDescriptor final : public DescriptorImpl { | class ComboDescriptor final : public DescriptorImpl { | ||||
protected: | protected: | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | std::vector<CScript> MakeScripts(const std::vector<CPubKey> &, | ||||
const CScript *script, | const CScript *script, | ||||
FlatSigningProvider &) const override { | FlatSigningProvider &) const override { | ||||
return Vector(GetScriptForDestination(ScriptHash(*script))); | return Vector(GetScriptForDestination(ScriptHash(*script))); | ||||
} | } | ||||
public: | public: | ||||
SHDescriptor(std::unique_ptr<DescriptorImpl> desc) | SHDescriptor(std::unique_ptr<DescriptorImpl> desc) | ||||
: DescriptorImpl({}, std::move(desc), "sh") {} | : DescriptorImpl({}, std::move(desc), "sh") {} | ||||
Optional<OutputType> GetOutputType() const override { | std::optional<OutputType> GetOutputType() const override { | ||||
return OutputType::LEGACY; | return OutputType::LEGACY; | ||||
} | } | ||||
bool IsSingleType() const final { return true; } | bool IsSingleType() const final { return true; } | ||||
}; | }; | ||||
//////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////// | ||||
// Parser // | // Parser // | ||||
//////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////// | ||||
▲ Show 20 Lines • Show All 466 Lines • Show Last 20 Lines |