aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2018-07-20 00:04:02 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2018-08-13 08:46:23 -0700
commit81e1dd5ce1a32114a38691ec6b55e72ab04dbbb1 (patch)
tree5342792dd281e8628ebc214feca9e74d80770e79 /src/script
parent84f1f1bfdf900cd28099e428441aa42f9d11a0ed (diff)
Generalize PublicOnlySigningProvider into HidingSigningProvider
Diffstat (limited to 'src/script')
-rw-r--r--src/script/sign.cpp13
-rw-r--r--src/script/sign.h13
2 files changed, 18 insertions, 8 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 47931e21d9..ae29f72b05 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -640,18 +640,25 @@ void PSBTOutput::Merge(const PSBTOutput& output)
if (witness_script.empty() && !output.witness_script.empty()) witness_script = output.witness_script;
}
-bool PublicOnlySigningProvider::GetCScript(const CScriptID &scriptid, CScript& script) const
+bool HidingSigningProvider::GetCScript(const CScriptID& scriptid, CScript& script) const
{
return m_provider->GetCScript(scriptid, script);
}
-bool PublicOnlySigningProvider::GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const
+bool HidingSigningProvider::GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const
{
return m_provider->GetPubKey(keyid, pubkey);
}
-bool PublicOnlySigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const
+bool HidingSigningProvider::GetKey(const CKeyID& keyid, CKey& key) const
{
+ if (m_hide_secret) return false;
+ return m_provider->GetKey(keyid, key);
+}
+
+bool HidingSigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const
+{
+ if (m_hide_origin) return false;
return m_provider->GetKeyOrigin(keyid, info);
}
diff --git a/src/script/sign.h b/src/script/sign.h
index 323fe70f34..d8334f2ea2 100644
--- a/src/script/sign.h
+++ b/src/script/sign.h
@@ -39,16 +39,19 @@ public:
extern const SigningProvider& DUMMY_SIGNING_PROVIDER;
-class PublicOnlySigningProvider : public SigningProvider
+class HidingSigningProvider : public SigningProvider
{
private:
+ const bool m_hide_secret;
+ const bool m_hide_origin;
const SigningProvider* m_provider;
public:
- PublicOnlySigningProvider(const SigningProvider* provider) : m_provider(provider) {}
- bool GetCScript(const CScriptID &scriptid, CScript& script) const;
- bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const;
- bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const;
+ HidingSigningProvider(const SigningProvider* provider, bool hide_secret, bool hide_origin) : m_hide_secret(hide_secret), m_hide_origin(hide_origin), m_provider(provider) {}
+ bool GetCScript(const CScriptID& scriptid, CScript& script) const override;
+ bool GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const override;
+ bool GetKey(const CKeyID& keyid, CKey& key) const override;
+ bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
};
struct FlatSigningProvider final : public SigningProvider