Merge bitcoin/bitcoin#31244: descriptors: MuSig2

5fe7915c86 doc: Add musig() example (Ava Chow)
d576079ab4 tests: Test musig() parsing (Ava Chow)
a53924bee3 descriptor: Parse musig() key expressions (Ava Chow)
9473e9606c descriptors: Move DeriveType parsing into its own function (Ava Chow)
4af0dca096 descriptor: Add MuSigPubkeyProvider (Ava Chow)
d00d95437d Add MuSig2 Keyagg Cache helper functions (Ava Chow)
8ecea91bf2 sign: Add GetMuSig2ParticipantPubkeys to SigningProvider (Ava Chow)
fac0ee0bfc build: Enable secp256k1 musig module (Ava Chow)
1894f97503 descriptors: Add PubkeyProvider::IsBIP32() (Ava Chow)
12bc1d0b1e util/string: Allow Split to include the separator (Ava Chow)
8811312571 script/parsing: Allow Const to not skip the found constant (Ava Chow)
5fe4c66462 XOnlyPubKey: Add GetCPubKeys (Ava Chow)

Pull request description:

  Implements parsing of BIP 390 `musig()` descriptors.

  Split from #29675

ACKs for top commit:
  w0xlt:
    reACK 5fe7915c86
  rkrux:
    ACK 5fe7915c86
  theStack:
    re-ACK 5fe7915c86 🎹
  Sjors:
    ACK 5fe7915c86

Tree-SHA512: a5be6288e277187fb9a1e2adf4e9822b46b1b8380d732b2fabd53f317c839aecb1971b04410486cbd65047fbc20956675d4d676f56caa37a44ff0e4d12b9b081
This commit is contained in:
merge-script
2025-07-31 16:51:39 -04:00
14 changed files with 752 additions and 51 deletions

View File

@@ -100,18 +100,30 @@ void ReplaceAll(std::string& in_out, const std::string& search, const std::strin
*
* If sep does not occur in sp, a singleton with the entirety of sp is returned.
*
* @param[in] include_sep Whether to include the separator at the end of the left side of the splits.
*
* Note that this function does not care about braces, so splitting
* "foo(bar(1),2),3) on ',' will return {"foo(bar(1)", "2)", "3)"}.
*
* If include_sep == true, splitting "foo(bar(1),2),3) on ','
* will return:
* - foo(bar(1),
* - 2),
* - 3)
*/
template <typename T = std::span<const char>>
std::vector<T> Split(const std::span<const char>& sp, std::string_view separators)
std::vector<T> Split(const std::span<const char>& sp, std::string_view separators, bool include_sep = false)
{
std::vector<T> ret;
auto it = sp.begin();
auto start = it;
while (it != sp.end()) {
if (separators.find(*it) != std::string::npos) {
ret.emplace_back(start, it);
if (include_sep) {
ret.emplace_back(start, it + 1);
} else {
ret.emplace_back(start, it);
}
start = it + 1;
}
++it;
@@ -128,9 +140,9 @@ std::vector<T> Split(const std::span<const char>& sp, std::string_view separator
* "foo(bar(1),2),3) on ',' will return {"foo(bar(1)", "2)", "3)"}.
*/
template <typename T = std::span<const char>>
std::vector<T> Split(const std::span<const char>& sp, char sep)
std::vector<T> Split(const std::span<const char>& sp, char sep, bool include_sep = false)
{
return Split<T>(sp, std::string_view{&sep, 1});
return Split<T>(sp, std::string_view{&sep, 1}, include_sep);
}
[[nodiscard]] inline std::vector<std::string> SplitString(std::string_view str, char sep)