Skip to content

Commit

Permalink
Remove support for subdescriptors expanding to multiple scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa authored and pull[bot] committed Feb 15, 2022
1 parent ab282a8 commit 811fe69
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/script/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ class DescriptorImpl : public Descriptor
//! The sub-descriptor argument (nullptr for everything but SH and WSH).
//! In doc/descriptors.m this is referred to as SCRIPT expressions sh(SCRIPT)
//! and wsh(SCRIPT), and distinct from KEY expressions and ADDR expressions.
//! Subdescriptors can only ever generate a single script.
const std::unique_ptr<DescriptorImpl> m_subdescriptor_arg;

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

/** A helper function to construct the scripts for this descriptor.
*
* This function is invoked once for every CScript produced by evaluating
* m_subdescriptor_arg, or just once in case m_subdescriptor_arg is nullptr.
* This function is invoked once by ExpandHelper.
* @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).
Expand Down Expand Up @@ -586,6 +586,7 @@ class DescriptorImpl : public Descriptor
if (m_subdescriptor_arg) {
FlatSigningProvider subprovider;
if (!m_subdescriptor_arg->ExpandHelper(pos, arg, read_cache, subscripts, subprovider, write_cache)) return false;
assert(subscripts.size() == 1);
out = Merge(out, subprovider);
}

Expand All @@ -596,13 +597,8 @@ class DescriptorImpl : public Descriptor
out.origins.emplace(entry.first.GetID(), std::make_pair<CPubKey, KeyOriginInfo>(CPubKey(entry.first), std::move(entry.second)));
}
if (m_subdescriptor_arg) {
for (const auto& subscript : subscripts) {
out.scripts.emplace(CScriptID(subscript), subscript);
std::vector<CScript> addscripts = MakeScripts(pubkeys, &subscript, out);
for (auto& addscript : addscripts) {
output_scripts.push_back(std::move(addscript));
}
}
out.scripts.emplace(CScriptID(subscripts[0]), subscripts[0]);
output_scripts = MakeScripts(pubkeys, &subscripts[0], out);
} else {
output_scripts = MakeScripts(pubkeys, nullptr, out);
}
Expand Down

0 comments on commit 811fe69

Please sign in to comment.