rpc, descriptor: warn when multipath expansion clones single-path key expressions #36005

pull pythcoiner wants to merge 4 commits into bitcoin:master from pythcoiner:multipath-clone-warning changing 8 files +148 −10
  1. pythcoiner commented at 4:19 AM on August 18, 2026: contributor

    This PR:

    • deduplicate warnings pushed with PushWarnings in RPC calls
    • warn when single-path key expressions or tr() subscripts are cloned into every multipath expansion; surfaced by importdescriptors and by a new warnings field on getdescriptorinfo (which also exposes the existing miniscript older() warnings)

    Cloning internal to musig() is not warned: both musig(A,B)/<0;1>/* and musig(A/<1;2>,B) derive a distinct aggregate key per branch, so nothing observable is reused.

    closes #35985

  2. DrahtBot commented at 4:20 AM on August 18, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK fametrano
    Stale ACK jeanpablojp

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36710 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36710.svg"></sub> (test: Replace hardcoded extended keys with ExtendedKey helpers by nebula-21)
    • #36444 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36444.svg"></sub> (wallet: Store information about created and imported multipath descriptors by achow101)
    • #36443 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36443.svg"></sub> (descriptor: Reconstruct a multipath descriptor from its expansion by achow101)
    • #36442 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36442.svg"></sub> (descriptor: Represent multipath descriptors in a single Descriptor object by achow101)
    • #36402 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36402.svg"></sub> (refactor: wallet_importdescriptors to separate run_test() contents into specific functions by nebula-21)
    • #36154 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36154.svg"></sub> (wallet: fill PSBT_GLOBAL_XPUB by jeanpablojp)
    • #31668 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31668.svg"></sub> (Added rescan option for import descriptors by saikiran57)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. pythcoiner force-pushed on Aug 18, 2026
  4. DrahtBot added the label CI failed on Aug 18, 2026
  5. pythcoiner marked this as ready for review on Aug 18, 2026
  6. pythcoiner referenced this in commit cf98aaa510 on Aug 18, 2026
  7. pythcoiner force-pushed on Aug 18, 2026
  8. pythcoiner referenced this in commit 13ef865f84 on Aug 18, 2026
  9. pythcoiner force-pushed on Aug 18, 2026
  10. DrahtBot removed the label CI failed on Aug 18, 2026
  11. DrahtBot added the label CI failed on Aug 18, 2026
  12. DrahtBot commented at 6:18 AM on August 18, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task previous releases: https://github.com/bitcoin/bitcoin/actions/runs/32101345101/job/95602400388</sub> <sub>LLM reason (✨ experimental): CI failed due to a GCC 12 internal compiler error (segmentation fault) while compiling src/rpc/blockchain.cpp.</sub>

    Edit: Looks like the ICE was due to a corrupt VM/hardware

  13. DrahtBot removed the label CI failed on Aug 18, 2026
  14. jeanpablojp commented at 3:14 PM on August 20, 2026: contributor

    tACK 13ef865f84fc5d0f7073e11a6b4167b2dcd45e92

    Built and ran the unit tests plus rpc_getdescriptorinfo.py and wallet_importdescriptors.py. I dropped each of the four multipath_cloned = true lines one at a time and each one fails on a different descriptor in the new unit test, and reverting only the PushWarnings dedup fails both functional tests.

  15. in src/test/descriptor_tests.cpp:1358 in 13ef865f84
    1353 | +    auto descs = Parse(desc, keys, error);
    1354 | +    BOOST_REQUIRE_MESSAGE(!descs.empty(), desc + ": " + error);
    1355 | +    for (const auto& d : descs) {
    1356 | +        const auto warnings = d->Warnings();
    1357 | +        if (expect_warning) {
    1358 | +            BOOST_REQUIRE_MESSAGE(warnings.size() == 1U, desc);
    


    jeanpablojp commented at 3:14 PM on August 20, 2026:

    nit: this only allows one warning. I hit both with wsh(and_v(v:pk(A/<0;1>/*),and_v(v:pk(B/0/*),older(65536)))), which nothing covers at the moment. Worth adding one?

  16. DrahtBot added the label Needs rebase on Sep 9, 2026
  17. sedited commented at 12:58 PM on October 2, 2026: contributor

    Ping @pythcoiner this has been in need of a rebase for a while. Are you still working on this change?

  18. pythcoiner commented at 9:22 AM on October 4, 2026: contributor

    @sedited, this is still on my todo-list (but not at the top atm tbh)

  19. rpc: deduplicate warnings in PushWarnings 1da004330a
  20. descriptor: warn when single-path key expressions are cloned into multipath branches 18ddb577ee
  21. rpc: return descriptor warnings from getdescriptorinfo 7c6a0154a1
  22. doc: add release notes for #36005 9367321544
  23. pythcoiner force-pushed on Nov 5, 2026
  24. pythcoiner commented at 5:56 AM on November 5, 2026: contributor

    rebased on master @jeanpablojp thanks for the review, added your descriptor to the test, and modified the check to count only expected warnings

  25. DrahtBot removed the label Needs rebase on Nov 5, 2026
  26. fametrano commented at 7:51 AM on November 8, 2026: contributor

    tACK 93673215444ab07b64c39213c5eceb3bb979652e

    I compared the new warning with key reuse computed outside Core. bip32-descriptors, a library I maintain, expanded 291 multipath descriptors. They cover multi, sortedmulti, multi_a, tr() trees, miniscript and musig(), with ranged, fixed and plain single-path keys. For each expansion it collected the keys in its scripts plus the taproot internal key, at indexes 0 to 2 where the descriptor is ranged. In 272 descriptors two expansions share a key. The warning fires on 270 of them and on none of the other 19. The two it misses clone no single-path key: each shared key comes from two multipath expressions on the same xpub. deriveaddresses matches the library's addresses on all 291. importdescriptors warns exactly where getdescriptorinfo does. With the tr() internal-key flag removed, 17 more descriptors disagree, so the comparison catches a missing flag.

    Gist: https://gist.github.com/fametrano/7ef458c65cf3d8c4bdab96688745b80d/1d0f3d2371525bda975201f8f987e7bdf54dcf21

  27. DrahtBot requested review from jeanpablojp on Nov 8, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-10 20:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me