Skip to content

Commit 84f3939

Browse files
committed
Remove support for subdescriptors expanding to multiple scripts
1 parent 1c7be9a commit 84f3939

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/script/descriptor.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ class DescriptorImpl : public Descriptor
484484
//! The sub-descriptor argument (nullptr for everything but SH and WSH).
485485
//! In doc/descriptors.m this is referred to as SCRIPT expressions sh(SCRIPT)
486486
//! and wsh(SCRIPT), and distinct from KEY expressions and ADDR expressions.
487+
//! Subdescriptors can only ever generate a single script.
487488
const std::unique_ptr<DescriptorImpl> m_subdescriptor_arg;
488489

489490
//! Return a serialization of anything except pubkey and script arguments, to be prepended to those.
490491
virtual std::string ToStringExtra() const { return ""; }
491492

492493
/** A helper function to construct the scripts for this descriptor.
493494
*
494-
* This function is invoked once for every CScript produced by evaluating
495-
* m_subdescriptor_arg, or just once in case m_subdescriptor_arg is nullptr.
495+
* This function is invoked once by ExpandHelper.
496496
497497
* @param pubkeys The evaluations of the m_pubkey_args field.
498498
* @param script The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr).
@@ -586,6 +586,7 @@ class DescriptorImpl : public Descriptor
586586
if (m_subdescriptor_arg) {
587587
FlatSigningProvider subprovider;
588588
if (!m_subdescriptor_arg->ExpandHelper(pos, arg, read_cache, subscripts, subprovider, write_cache)) return false;
589+
assert(subscripts.size() == 1);
589590
out = Merge(out, subprovider);
590591
}
591592

@@ -596,13 +597,8 @@ class DescriptorImpl : public Descriptor
596597
out.origins.emplace(entry.first.GetID(), std::make_pair<CPubKey, KeyOriginInfo>(CPubKey(entry.first), std::move(entry.second)));
597598
}
598599
if (m_subdescriptor_arg) {
599-
for (const auto& subscript : subscripts) {
600-
out.scripts.emplace(CScriptID(subscript), subscript);
601-
std::vector<CScript> addscripts = MakeScripts(pubkeys, &subscript, out);
602-
for (auto& addscript : addscripts) {
603-
output_scripts.push_back(std::move(addscript));
604-
}
605-
}
600+
out.scripts.emplace(CScriptID(subscripts[0]), subscripts[0]);
601+
output_scripts = MakeScripts(pubkeys, &subscripts[0], out);
606602
} else {
607603
output_scripts = MakeScripts(pubkeys, nullptr, out);
608604
}

0 commit comments

Comments
 (0)