diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index baabd4d5b5cc8..597b1a1544bcc 100644 --- a/src/script/signingprovider.cpp +++ b/src/script/signingprovider.cpp @@ -62,6 +62,11 @@ bool FlatSigningProvider::GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) if (ret) info = std::move(out.second); return ret; } +bool FlatSigningProvider::HaveKey(const CKeyID &keyid) const +{ + CKey key; + return LookupHelper(keys, keyid, key); +} bool FlatSigningProvider::GetKey(const CKeyID& keyid, CKey& key) const { return LookupHelper(keys, keyid, key); } bool FlatSigningProvider::GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const { diff --git a/src/script/signingprovider.h b/src/script/signingprovider.h index efdfd9ee566b0..f0fb21c8b18ff 100644 --- a/src/script/signingprovider.h +++ b/src/script/signingprovider.h @@ -215,6 +215,7 @@ struct FlatSigningProvider final : public SigningProvider bool GetCScript(const CScriptID& scriptid, CScript& script) const override; bool GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const override; bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override; + bool HaveKey(const CKeyID &keyid) const override; bool GetKey(const CKeyID& keyid, CKey& key) const override; bool GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override; bool GetTaprootBuilder(const XOnlyPubKey& output_key, TaprootBuilder& builder) const override; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 62384056dc6e4..7787e2ff6bfb0 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2456,7 +2456,11 @@ std::unique_ptr DescriptorScriptPubKeyMan::GetSigningProvid int32_t index = it->second; // Always try to get the signing provider with private keys. This function should only be called during signing anyways - return GetSigningProvider(index, true); + std::unique_ptr out = GetSigningProvider(index, true); + if (!out->HaveKey(pubkey.GetID())) { + return nullptr; + } + return out; } std::unique_ptr DescriptorScriptPubKeyMan::GetSigningProvider(int32_t index, bool include_private) const