diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -102,10 +102,6 @@ virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key) = 0; - //! Get private key. - virtual bool getPrivKey(const CScript &script, const CKeyID &address, - CKey &key) = 0; - //! Sign message virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -129,21 +129,12 @@ bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key) override { std::unique_ptr provider = - m_wallet->GetSigningProvider(script); + m_wallet->GetSolvingProvider(script); if (provider) { return provider->GetPubKey(address, pub_key); } return false; } - bool getPrivKey(const CScript &script, const CKeyID &address, - CKey &key) override { - std::unique_ptr provider = - m_wallet->GetSigningProvider(script); - if (provider) { - return provider->GetKey(address, key); - } - return false; - } SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) override { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3495,7 +3495,7 @@ } std::unique_ptr provider = - pwallet->GetSigningProvider(scriptPubKey); + pwallet->GetSolvingProvider(scriptPubKey); if (provider) { if (scriptPubKey.IsPayToScriptHash()) { const CScriptID &hash = @@ -3518,7 +3518,7 @@ entry.pushKV("solvable", out.fSolvable); if (out.fSolvable) { std::unique_ptr provider = - pwallet->GetSigningProvider(scriptPubKey); + pwallet->GetSolvingProvider(scriptPubKey); if (provider) { auto descriptor = InferDescriptor(scriptPubKey, *provider); entry.pushKV("desc", descriptor->ToString()); @@ -4071,7 +4071,7 @@ CScript script = GetScriptForDestination(dest); std::unique_ptr provider = nullptr; if (pwallet) { - provider = pwallet->GetSigningProvider(script); + provider = pwallet->GetSolvingProvider(script); } ret.pushKVs(detail); ret.pushKVs(boost::apply_visitor( @@ -4212,7 +4212,7 @@ HexStr(scriptPubKey.begin(), scriptPubKey.end())); std::unique_ptr provider = - pwallet->GetSigningProvider(scriptPubKey); + pwallet->GetSolvingProvider(scriptPubKey); isminetype mine = pwallet->IsMine(dest); ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -243,14 +243,14 @@ } virtual std::unique_ptr - GetSigningProvider(const CScript &script) const { + GetSolvingProvider(const CScript &script) const { return nullptr; } /** * Whether this ScriptPubKeyMan can provide a SigningProvider (via - * GetSigningProvider) that, combined with sigdata, can produce a valid - * signature. + * GetSolvingProvider) that, combined with sigdata, can produce solving + * data. */ virtual bool CanProvide(const CScript &script, SignatureData &sigdata) { return false; @@ -446,7 +446,7 @@ bool CanGetAddresses(bool internal = false) override; std::unique_ptr - GetSigningProvider(const CScript &script) const override; + GetSolvingProvider(const CScript &script) const override; bool CanProvide(const CScript &script, SignatureData &sigdata) override; @@ -581,7 +581,8 @@ }; /** - * Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr + * Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr. + * Does not provide privkeys. */ class LegacySigningProvider : public SigningProvider { private: @@ -601,11 +602,9 @@ return m_spk_man.GetPubKey(address, pubkey); } bool GetKey(const CKeyID &address, CKey &key) const override { - return m_spk_man.GetKey(address, key); - } - bool HaveKey(const CKeyID &address) const override { - return m_spk_man.HaveKey(address); + return false; } + bool HaveKey(const CKeyID &address) const override { return false; } bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override { return m_spk_man.GetKeyOrigin(keyid, info); } diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -429,7 +429,7 @@ } std::unique_ptr -LegacyScriptPubKeyMan::GetSigningProvider(const CScript &script) const { +LegacyScriptPubKeyMan::GetSolvingProvider(const CScript &script) const { return std::make_unique(*this); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1464,9 +1464,9 @@ //! Get the SigningProvider for a script std::unique_ptr - GetSigningProvider(const CScript &script) const; + GetSolvingProvider(const CScript &script) const; std::unique_ptr - GetSigningProvider(const CScript &script, SignatureData &sigdata) const; + GetSolvingProvider(const CScript &script, SignatureData &sigdata) const; //! Get the LegacyScriptPubKeyMan which is used for all types, internal, and //! external. diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1496,7 +1496,7 @@ SignatureData sigdata; std::unique_ptr provider = - GetSigningProvider(scriptPubKey); + GetSolvingProvider(scriptPubKey); if (!provider) { // We don't know about this scriptpbuKey; return false; @@ -2381,7 +2381,7 @@ } std::unique_ptr provider = - GetSigningProvider(wtx.tx->vout[i].scriptPubKey); + GetSolvingProvider(wtx.tx->vout[i].scriptPubKey); bool solvable = provider ? IsSolvable(*provider, wtx.tx->vout[i].scriptPubKey) @@ -4836,17 +4836,17 @@ } std::unique_ptr -CWallet::GetSigningProvider(const CScript &script) const { +CWallet::GetSolvingProvider(const CScript &script) const { SignatureData sigdata; - return GetSigningProvider(script, sigdata); + return GetSolvingProvider(script, sigdata); } std::unique_ptr -CWallet::GetSigningProvider(const CScript &script, +CWallet::GetSolvingProvider(const CScript &script, SignatureData &sigdata) const { for (const auto &spk_man_pair : m_spk_managers) { if (spk_man_pair.second->CanProvide(script, sigdata)) { - return spk_man_pair.second->GetSigningProvider(script); + return spk_man_pair.second->GetSolvingProvider(script); } } return nullptr;