descriptor: handle listdescriptors(private=true) for descriptors having partial keys #32186

pull rkrux wants to merge 2 commits into bitcoin:master from rkrux:taproot-list-desc changing 2 files +75 −7
  1. rkrux commented at 2:28 pm on April 1, 2025: contributor

    When parsing descriptors with multiple keys (tr, wsh, sh, miniscript), we might not have all the private keys but only few of them (rest being public keys).

    listdescriptors(private=true) RPC should not fail in such scenario and instead return those partial private keys, using public keys for the rest.

    Fixes #32078

  2. DrahtBot commented at 2:28 pm on April 1, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32186.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK w0xlt, brunoerg
    Approach NACK sipa
    Stale ACK Randy808

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31734 (miniscript: account for all StringType variants in Miniscriptdescriptor::ToString() by pythcoiner)
    • #30243 (descriptors: taproot partial descriptors by Eunovo)

    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.

  3. rkrux commented at 2:30 pm on April 1, 2025: contributor
    cc: @furszy
  4. DrahtBot commented at 4:46 pm on April 1, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/39778817034

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  5. DrahtBot added the label CI failed on Apr 1, 2025
  6. furszy commented at 7:27 pm on April 1, 2025: member
    I haven’t checked the approach, but based on the title, I assume it is linked to #32078.
  7. rkrux force-pushed on Apr 3, 2025
  8. rkrux renamed this:
    descriptor: handle listdescriptors(private=true) in case of taproot descriptors having partial keys
    descriptor: handle listdescriptors(private=true) for taproot descriptors having partial keys
    on Apr 3, 2025
  9. rkrux force-pushed on Apr 3, 2025
  10. rkrux force-pushed on Apr 3, 2025
  11. DrahtBot removed the label CI failed on Apr 3, 2025
  12. rkrux marked this as ready for review on Apr 3, 2025
  13. w0xlt commented at 1:47 am on April 4, 2025: contributor
    Concept ACK. It addresses the issue mentioned in the PR description. It may be better if the test validates the returned message.
  14. in src/script/descriptor.cpp:690 in 92d9340871 outdated
    686+        if (is_taproot && type == StringType::PRIVATE) {
    687+            if (!has_internal_key) {
    688+                if (subscript.empty()) {
    689+                    return false;
    690+                }
    691+                // Atleast one key should be present in any of the Taproot spending paths
    


    Randy808 commented at 6:41 pm on April 5, 2025:
    nit: ‘Atleast’ should be ‘At least’
  15. Randy808 commented at 8:01 pm on April 5, 2025: contributor
    Code Review ACK 3d3d8491948c2825c43db7fae69c32aae343742f
  16. brunoerg commented at 2:51 pm on April 7, 2025: contributor
    Concept ACK
  17. sipa commented at 3:48 pm on April 7, 2025: member

    Approach NACK. There is no reason why this needs to be special cased for taproot.

    listdescriptors true should always return all private keys that are present in the wallet, even if not all private keys are present. That can happen in taproot branches, but it also could happen for a simple multisig.

    #24361 would have fixed this. Feel free to pick it up.

  18. rkrux commented at 5:03 pm on April 7, 2025: contributor
    I see, it makes sense to solve it for all the cases; I’ll rework this PR.
  19. rkrux marked this as a draft on Apr 7, 2025
  20. laanwj added the label Wallet on Apr 9, 2025
  21. descriptor: list private descriptors if not all keys present
    When parsing descriptors with multiple keys (tr, wsh, sh, miniscript),
    we might not have all the private keys but only few of them
    (rest being public keys).
    
    `listdescriptors(private=true)` RPC should not
    fail in such scenario and instead return those partial private keys,
    using public keys for the rest.
    62c261c6f7
  22. rkrux force-pushed on Apr 10, 2025
  23. rkrux renamed this:
    descriptor: handle listdescriptors(private=true) for taproot descriptors having partial keys
    descriptor: handle listdescriptors(private=true) for descriptors having partial keys
    on Apr 10, 2025
  24. test: listdescriptors(private=true) if not all private keys present a0c73846aa
  25. rkrux force-pushed on Apr 10, 2025
  26. DrahtBot added the label CI failed on Apr 10, 2025
  27. DrahtBot commented at 3:47 pm on April 10, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/40327848658

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  28. rkrux commented at 2:06 pm on April 11, 2025: contributor

    I don’t like the way this diff has turned out, seems repetitive. I will take inspiration from #24361 and spend some time figuring out how to make it work for Miniscript expressions as well. The branch name is outdated too now.

    Most likely will close this and open a new PR.


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: 2025-04-16 15:12 UTC

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