diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index ed382f2a54..d15cba1fa8 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -497,7 +497,7 @@ protected: * @param pubkeys The evaluations of the m_pubkey_args field. * @param script The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr). * @param out A FlatSigningProvider to put scripts or public keys in that are necessary to the solver. - * The script arguments to this function are automatically added, as is the origin info of the provided pubkeys. + * The origin info of the provided pubkeys is automatically added. * @return A vector with scriptPubKeys for this descriptor. */ virtual std::vector MakeScripts(const std::vector& pubkeys, const CScript* script, FlatSigningProvider& out) const = 0; @@ -597,7 +597,6 @@ public: out.origins.emplace(entry.first.GetID(), std::make_pair(CPubKey(entry.first), std::move(entry.second))); } if (m_subdescriptor_arg) { - out.scripts.emplace(CScriptID(subscripts[0]), subscripts[0]); output_scripts = MakeScripts(pubkeys, &subscripts[0], out); } else { output_scripts = MakeScripts(pubkeys, nullptr, out); @@ -776,7 +775,12 @@ public: class SHDescriptor final : public DescriptorImpl { protected: - std::vector MakeScripts(const std::vector&, const CScript* script, FlatSigningProvider&) const override { return Vector(GetScriptForDestination(ScriptHash(*script))); } + std::vector MakeScripts(const std::vector&, const CScript* script, FlatSigningProvider& out) const override + { + auto ret = Vector(GetScriptForDestination(ScriptHash(*script))); + if (ret.size()) out.scripts.emplace(CScriptID(*script), *script); + return ret; + } public: SHDescriptor(std::unique_ptr desc) : DescriptorImpl({}, std::move(desc), "sh") {} @@ -793,7 +797,12 @@ public: class WSHDescriptor final : public DescriptorImpl { protected: - std::vector MakeScripts(const std::vector&, const CScript* script, FlatSigningProvider&) const override { return Vector(GetScriptForDestination(WitnessV0ScriptHash(*script))); } + std::vector MakeScripts(const std::vector&, const CScript* script, FlatSigningProvider& out) const override + { + auto ret = Vector(GetScriptForDestination(WitnessV0ScriptHash(*script))); + if (ret.size()) out.scripts.emplace(CScriptID(*script), *script); + return ret; + } public: WSHDescriptor(std::unique_ptr desc) : DescriptorImpl({}, std::move(desc), "wsh") {} std::optional GetOutputType() const override { return OutputType::BECH32; }