From 1894f975032013ef855c438654fbb745512e7982 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 15 Jan 2024 17:09:22 -0500 Subject: [PATCH] descriptors: Add PubkeyProvider::IsBIP32() --- src/script/descriptor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 71645c87462..d5e4bc2195f 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -221,6 +221,9 @@ public: /** Make a deep copy of this PubkeyProvider */ virtual std::unique_ptr Clone() const = 0; + + /** Whether this PubkeyProvider is a BIP 32 extended key that can be derived from */ + virtual bool IsBIP32() const = 0; }; class OriginPubkeyProvider final : public PubkeyProvider @@ -251,6 +254,7 @@ public: } bool IsRange() const override { return m_provider->IsRange(); } size_t GetSize() const override { return m_provider->GetSize(); } + bool IsBIP32() const override { return m_provider->IsBIP32(); } std::string ToString(StringType type) const override { return "[" + OriginString(type) + "]" + m_provider->ToString(type); } bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override { @@ -319,6 +323,7 @@ public: } bool IsRange() const override { return false; } size_t GetSize() const override { return m_pubkey.size(); } + bool IsBIP32() const override { return false; } std::string ToString(StringType type) const override { return m_xonly ? HexStr(m_pubkey).substr(2) : HexStr(m_pubkey); } bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override { @@ -406,6 +411,7 @@ public: BIP32PubkeyProvider(uint32_t exp_index, const CExtPubKey& extkey, KeyPath path, DeriveType derive, bool apostrophe) : PubkeyProvider(exp_index), m_root_extkey(extkey), m_path(std::move(path)), m_derive(derive), m_apostrophe(apostrophe) {} bool IsRange() const override { return m_derive != DeriveType::NO; } size_t GetSize() const override { return 33; } + bool IsBIP32() const override { return true; } std::optional GetPubKey(int pos, const SigningProvider& arg, FlatSigningProvider& out, const DescriptorCache* read_cache = nullptr, DescriptorCache* write_cache = nullptr) const override { KeyOriginInfo info;