NOLINTNEXTLINE(misc-no-recursion)
| 993 | |
| 994 | // NOLINTNEXTLINE(misc-no-recursion) |
| 995 | bool ExpandHelper(int pos, const SigningProvider& arg, const DescriptorCache* read_cache, std::vector<CScript>& output_scripts, FlatSigningProvider& out, DescriptorCache* write_cache) const |
| 996 | { |
| 997 | FlatSigningProvider subprovider; |
| 998 | std::vector<CPubKey> pubkeys; |
| 999 | pubkeys.reserve(m_pubkey_args.size()); |
| 1000 | |
| 1001 | // Construct temporary data in `pubkeys`, `subscripts`, and `subprovider` to avoid producing output in case of failure. |
| 1002 | for (const auto& p : m_pubkey_args) { |
| 1003 | std::optional<CPubKey> pubkey = p->GetPubKey(pos, arg, subprovider, read_cache, write_cache); |
| 1004 | if (!pubkey) return false; |
| 1005 | pubkeys.push_back(pubkey.value()); |
| 1006 | } |
| 1007 | std::vector<CScript> subscripts; |
| 1008 | for (const auto& subarg : m_subdescriptor_args) { |
| 1009 | std::vector<CScript> outscripts; |
| 1010 | if (!subarg->ExpandHelper(pos, arg, read_cache, outscripts, subprovider, write_cache)) return false; |
| 1011 | assert(outscripts.size() == 1); |
| 1012 | subscripts.emplace_back(std::move(outscripts[0])); |
| 1013 | } |
| 1014 | out.Merge(std::move(subprovider)); |
| 1015 | |
| 1016 | output_scripts = MakeScripts(pubkeys, std::span{subscripts}, out); |
| 1017 | return true; |
| 1018 | } |
| 1019 | |
| 1020 | bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out, DescriptorCache* write_cache = nullptr) const final |
| 1021 | { |