diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-07-20 00:04:02 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-08-13 08:46:23 -0700 |
commit | 81e1dd5ce1a32114a38691ec6b55e72ab04dbbb1 (patch) | |
tree | 5342792dd281e8628ebc214feca9e74d80770e79 | |
parent | 84f1f1bfdf900cd28099e428441aa42f9d11a0ed (diff) | |
download | bitcoin-81e1dd5ce1a32114a38691ec6b55e72ab04dbbb1.tar.xz |
Generalize PublicOnlySigningProvider into HidingSigningProvider
-rw-r--r-- | src/script/sign.cpp | 13 | ||||
-rw-r--r-- | src/script/sign.h | 13 | ||||
-rw-r--r-- | src/wallet/rpcwallet.cpp | 6 |
3 files changed, 19 insertions, 13 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 diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fd3b82d9ab..a719e883c7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4520,11 +4520,7 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C } SignatureData sigdata; - if (sign) { - complete &= SignPSBTInput(*pwallet, *psbtx.tx, input, sigdata, i, sighash_type); - } else { - complete &= SignPSBTInput(PublicOnlySigningProvider(pwallet), *psbtx.tx, input, sigdata, i, sighash_type); - } + complete &= SignPSBTInput(HidingSigningProvider(pwallet, !sign, false), *psbtx.tx, input, sigdata, i, sighash_type); if (it != pwallet->mapWallet.end()) { // Drop the unnecessary UTXO if we added both from the wallet. |