diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 0987db194c..46f3e9677f 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -219,6 +219,9 @@ public: virtual std::optional GetRootPubKey() const = 0; /** Return the extended public key for this PubkeyProvider, if it has one. */ virtual std::optional GetRootExtPubKey() const = 0; + + /** Make a deep copy of this PubkeyProvider */ + virtual std::unique_ptr Clone() const = 0; }; class OriginPubkeyProvider final : public PubkeyProvider @@ -280,6 +283,10 @@ public: { return m_provider->GetRootExtPubKey(); } + std::unique_ptr Clone() const override + { + return std::make_unique(m_expr_index, m_origin, m_provider->Clone(), m_apostrophe); + } }; /** An object representing a parsed constant public key in a descriptor. */ @@ -333,6 +340,10 @@ public: { return std::nullopt; } + std::unique_ptr Clone() const override + { + return std::make_unique(m_expr_index, m_pubkey, m_xonly); + } }; enum class DeriveType { @@ -556,6 +567,10 @@ public: { return m_root_extkey; } + std::unique_ptr Clone() const override + { + return std::make_unique(m_expr_index, m_root_extkey, m_path, m_derive, m_apostrophe); + } }; /** Base class for all Descriptor implementations. */