From cc781a21800a6ce13875feefd0cb14ab0a84524c Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 11 Jul 2023 11:26:22 -0300 Subject: descriptor: InferScript, do not return top-level only func as sub descriptor e.g. sh(addr(ADDR)) or sh(raw(HEX)) are invalid descriptors. Making sh and wsh top level functions to return addr/raw descriptors when the subscript inference fails. --- src/script/descriptor.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/script') diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index dff6429259..c13338c01a 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -1717,6 +1717,10 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo } } + // The following descriptors are all top-level only descriptors. + // So if we are not at the top level, return early. + if (ctx != ParseScriptContext::TOP) return nullptr; + CTxDestination dest; if (ExtractDestination(script, dest)) { if (GetScriptForDestination(dest) == script) { -- cgit v1.2.3