diff --git a/src/script/descriptor.h b/src/script/descriptor.h --- a/src/script/descriptor.h +++ b/src/script/descriptor.h @@ -102,6 +102,12 @@ /** Convert the descriptor back to a string, undoing parsing. */ virtual std::string ToString() const = 0; + /** + * Whether this descriptor will return one scriptPubKey or multiple (aka is + * or is not combo) + */ + virtual bool IsSingleType() const = 0; + /** * Convert the descriptor to a private string. This fails if the provided * provider does not have the relevant private keys. diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -739,6 +739,7 @@ return nullopt; } } + bool IsSingleType() const final { return true; } }; /** A parsed raw(H) descriptor. */ @@ -772,6 +773,7 @@ return nullopt; } } + bool IsSingleType() const final { return true; } }; /** A parsed pk(P) descriptor. */ @@ -786,6 +788,7 @@ public: PKDescriptor(std::unique_ptr prov) : DescriptorImpl(Vector(std::move(prov)), {}, "pk") {} + bool IsSingleType() const final { return true; } }; /** A parsed pkh(P) descriptor. */ @@ -805,6 +808,7 @@ Optional GetOutputType() const override { return OutputType::LEGACY; } + bool IsSingleType() const final { return true; } }; /** A parsed combo(P) descriptor. */ @@ -826,6 +830,7 @@ public: ComboDescriptor(std::unique_ptr prov) : DescriptorImpl(Vector(std::move(prov)), {}, "combo") {} + bool IsSingleType() const final { return false; } }; /** A parsed multi(...) descriptor. */ @@ -855,6 +860,7 @@ : DescriptorImpl(std::move(providers), {}, sorted ? "sortedmulti" : "multi"), m_threshold(threshold), m_sorted(sorted) {} + bool IsSingleType() const final { return true; } }; /** A parsed sh(...) descriptor. */ @@ -872,6 +878,7 @@ Optional GetOutputType() const override { return OutputType::LEGACY; } + bool IsSingleType() const final { return true; } }; ////////////////////////////////////////////////////////////////////////////