mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-18 21:35:13 +01:00
descriptors: Add PubkeyProvider::Clone
This commit is contained in:
parent
79b8472040
commit
7e86541f72
@ -219,6 +219,9 @@ public:
|
||||
virtual std::optional<CPubKey> GetRootPubKey() const = 0;
|
||||
/** Return the extended public key for this PubkeyProvider, if it has one. */
|
||||
virtual std::optional<CExtPubKey> GetRootExtPubKey() const = 0;
|
||||
|
||||
/** Make a deep copy of this PubkeyProvider */
|
||||
virtual std::unique_ptr<PubkeyProvider> Clone() const = 0;
|
||||
};
|
||||
|
||||
class OriginPubkeyProvider final : public PubkeyProvider
|
||||
@ -280,6 +283,10 @@ public:
|
||||
{
|
||||
return m_provider->GetRootExtPubKey();
|
||||
}
|
||||
std::unique_ptr<PubkeyProvider> Clone() const override
|
||||
{
|
||||
return std::make_unique<OriginPubkeyProvider>(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<PubkeyProvider> Clone() const override
|
||||
{
|
||||
return std::make_unique<ConstPubkeyProvider>(m_expr_index, m_pubkey, m_xonly);
|
||||
}
|
||||
};
|
||||
|
||||
enum class DeriveType {
|
||||
@ -556,6 +567,10 @@ public:
|
||||
{
|
||||
return m_root_extkey;
|
||||
}
|
||||
std::unique_ptr<PubkeyProvider> Clone() const override
|
||||
{
|
||||
return std::make_unique<BIP32PubkeyProvider>(m_expr_index, m_root_extkey, m_path, m_derive, m_apostrophe);
|
||||
}
|
||||
};
|
||||
|
||||
/** Base class for all Descriptor implementations. */
|
||||
|
Loading…
Reference in New Issue
Block a user