MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckMultipath

Function CheckMultipath

src/test/descriptor_tests.cpp:510–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510void CheckMultipath(const std::string& prv,
511 const std::string& pub,
512 const std::vector<std::string>& expanded_prvs,
513 const std::vector<std::string>& expanded_pubs,
514 const std::vector<std::string>& expanded_norm_pubs,
515 const std::vector<int>& flags,
516 const std::vector<std::vector<std::vector<std::string>>>& scripts,
517 const std::optional<OutputType>& type,
518 const std::vector<std::set<std::vector<uint32_t>>>& paths)
519{
520 assert(expanded_prvs.size() == expanded_pubs.size());
521 assert(expanded_prvs.size() == expanded_norm_pubs.size());
522 assert(expanded_prvs.size() == scripts.size());
523 assert(expanded_prvs.size() == paths.size());
524 for (size_t i = 0; i < expanded_prvs.size(); ++i) {
525 int flag = flags.at(0);
526 if (flags.size() > 1) {
527 flag = flags.at(i);
528 }
529 Check(prv, pub, expanded_norm_pubs.at(i), flag, scripts.at(i), type, std::nullopt, paths.at(i),
530 /*spender_nlocktime=*/0, /*spender_nsequence=*/CTxIn::SEQUENCE_FINAL, /*preimages=*/{},
531 expanded_prvs.at(i), expanded_pubs.at(i), i);
532 }
533
534 // The descriptor for each path must be standalone. They should not share common references. Test this
535 // by parsing a multipath descriptor expression, deallocating all but one of the descriptors and making
536 // sure we can perform operations on it.
537 FlatSigningProvider prov, out;
538 std::string error;
539 const auto desc{[&](){
540 auto parsed{Parse(pub, prov, error)};
541 assert(parsed.size() > 1);
542 return std::move(parsed.at(0));
543 }()};
544 desc->ToString();
545 std::vector<CScript> out_scripts;
546 desc->Expand(0, prov, out_scripts, out);
547}
548
549void CheckInferDescriptor(const std::string& script_hex, const std::string& expected_desc, const std::vector<std::string>& hex_scripts, const std::vector<std::pair<std::string, std::string>>& origin_pubkeys)
550{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 6

CheckFunction · 0.85
ParseFunction · 0.50
sizeMethod · 0.45
atMethod · 0.45
ToStringMethod · 0.45
ExpandMethod · 0.45

Tested by

no test coverage detected