From f6a6d912059c66792f48689632d2a7f14f8bdad9 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 14 Nov 2024 14:45:02 +0100 Subject: [PATCH] test: add check for getting SigningProvider for a CPubKey Verify that the DescriptorSPKM method `GetSigningProvider` should only return a signing provider for the passed public key if its corresponding private key of the passed public key is available. --- src/wallet/scriptpubkeyman.h | 5 +++-- src/wallet/test/scriptpubkeyman_tests.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index d8b6c90178a..4ff35a478ca 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -611,8 +611,6 @@ private: mutable std::map m_map_signing_providers; // Fetch the SigningProvider for the given script and optionally include private keys std::unique_ptr GetSigningProvider(const CScript& script, bool include_private = false) const; - // Fetch the SigningProvider for the given pubkey and always include private keys. This should only be called by signing code. - std::unique_ptr GetSigningProvider(const CPubKey& pubkey) const; // Fetch the SigningProvider for a given index and optionally include private keys. Called by the above functions. std::unique_ptr GetSigningProvider(int32_t index, bool include_private = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); @@ -675,6 +673,9 @@ public: bool CanProvide(const CScript& script, SignatureData& sigdata) override; + // Fetch the SigningProvider for the given pubkey and always include private keys. This should only be called by signing code. + std::unique_ptr GetSigningProvider(const CPubKey& pubkey) const; + bool SignTransaction(CMutableTransaction& tx, const std::map& coins, int sighash, std::map& input_errors) const override; SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override; std::optional FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override; diff --git a/src/wallet/test/scriptpubkeyman_tests.cpp b/src/wallet/test/scriptpubkeyman_tests.cpp index 15bff04221d..f27865865db 100644 --- a/src/wallet/test/scriptpubkeyman_tests.cpp +++ b/src/wallet/test/scriptpubkeyman_tests.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include