wallet: allow label for non-ranged external descriptor (if internal=false) & disallow label for ranged descriptors #31514

pull scgbckbone wants to merge 1 commits into bitcoin:master from scgbckbone:ProcessDescriptorImport_fixes changing 3 files +20 −4
  1. scgbckbone commented at 10:35 am on December 17, 2024: none

    Motivation:

    • ranged descriptors MUST not be able to have label (current impl allows it)
    • external non-ranged descriptor MUST be able to have label (current impl disallows it, if internal=false is provided via importdescriptor user data)

    Repro steps:

    • create blank wallet and import descriptors
    • external has label=test (not internal)
     0    conn = bitcoind.create_wallet(wallet_name=w_name, disable_private_keys=True, blank=True,
     1                                  passphrase=None, avoid_reuse=False, descriptors=True)
     2    descriptors = [
     3        {
     4            "timestamp": "now",
     5            "label": "test",
     6            "active": True,
     7            "desc": "wpkh([0f056943/84h/1h/0h]tpubDC7jGaaSE66Pn4dgtbAAstde4bCyhSUs4r3P8WhMVvPByvcRrzrwqSvpF9Ghx83Z1LfVugGRrSBko5UEKELCz9HoMv5qKmGq3fqnnbS5E9r/0/*)#erexmnep",
     8            "internal": False
     9        },
    10        {
    11            "desc": "wpkh([0f056943/84h/1h/0h]tpubDC7jGaaSE66Pn4dgtbAAstde4bCyhSUs4r3P8WhMVvPByvcRrzrwqSvpF9Ghx83Z1LfVugGRrSBko5UEKELCz9HoMv5qKmGq3fqnnbS5E9r/1/*)#ghu8xxfe",
    12            "active": True,
    13            "internal": True,
    14            "timestamp": "now"
    15        },
    16    ]
    17    r = conn.importdescriptors(descriptors)
    18    print(r)
    

    response:

    0[{'error': {'code': -8,
    1            'message': 'Internal addresses should not have a label'},
    2  'success': False,
    3  'warnings': ['Range not given, using default keypool range']},
    4 {'success': True,
    5  'warnings': ['Range not given, using default keypool range']}]
    

    But in above, ONLY external has a label.

    If you remove label from external descriptor import object - it will import no problem:

    0[{'success': True,
    1  'warnings': ['Range not given, using default keypool range']},
    2 {'success': True,
    3  'warnings': ['Range not given, using default keypool range']}]
    

    Even tho it should NOT, as the descriptor is ranged. Current implementation relies on checking user provided data to decide whether desc is ranged.

  2. DrahtBot commented at 10:35 am on December 17, 2024: 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/31514.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101

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

  3. DrahtBot renamed this:
    allow lable for external descriptor & disallow label for ranged descriptors
    allow lable for external descriptor & disallow label for ranged descriptors
    on Dec 17, 2024
  4. scgbckbone commented at 10:41 am on December 17, 2024: none

    after fix if you have label and ranged descriptor (even without providing range via api):

    0[{'error': {'code': -8,
    1            'message': 'Ranged descriptors should not have a label'},
    2  'success': False,
    3  'warnings': ['Range not given, using default keypool range']},
    4 {'success': True,
    5  'warnings': ['Range not given, using default keypool range']}]
    
  5. DrahtBot added the label CI failed on Dec 17, 2024
  6. scgbckbone force-pushed on Dec 17, 2024
  7. furszy commented at 3:12 pm on December 17, 2024: member
    Could you please add the motivation for the behavior change at the beginning of the PR description? For example, could describe how the process currently behaves, why you think that it is not adequate and what your change proposal does to improve the functionality.
  8. scgbckbone commented at 3:31 pm on December 17, 2024: none

    Could you please add the motivation for the behavior change at the beginning of the PR description? For example, could describe how the process currently behaves, why you think that it is not adequate and what your change proposal does to improve the functionality.

    I thought it’s clear - but added

  9. scgbckbone force-pushed on Dec 18, 2024
  10. maflcko removed the label CI failed on Dec 19, 2024
  11. scgbckbone renamed this:
    allow lable for external descriptor & disallow label for ranged descriptors
    wallet: allow lable for external descriptor & disallow label for ranged descriptors
    on Dec 23, 2024
  12. DrahtBot added the label Wallet on Dec 23, 2024
  13. scgbckbone commented at 3:29 pm on December 23, 2024: none
    @achow101 - looks like logic bugs to me
  14. luke-jr commented at 4:12 am on January 14, 2025: member
    It would be nice to have a test that checks all 4 success/failure cases.
  15. fanquake requested review from achow101 on Feb 21, 2025
  16. scgbckbone force-pushed on Mar 26, 2025
  17. scgbckbone renamed this:
    wallet: allow lable for external descriptor & disallow label for ranged descriptors
    wallet: allow label for non-ranged external descriptor & disallow label for ranged descriptors
    on Mar 26, 2025
  18. scgbckbone commented at 3:01 pm on March 26, 2025: none
    added tests & rebased on master
  19. achow101 commented at 10:49 pm on April 16, 2025: member

    ACK dda90a96bd01e34f4a564fbd15f1948f1c22ff58

    Nice find!

    external non-ranged descriptor MUST be able to have label (current impl disallows it)

    Since we already have a test for this and this PR doesn’t change it, could you clarify what you mean?

  20. bugfix: disallow label for ranged descriptors & allow external non-ranged descriptors to have label
    * do not only check user provided range data to decide whether descriptor is ranged
    * properly handle std::optional<bool> when checking if descriptor is internal
    664657ed13
  21. scgbckbone force-pushed on Apr 22, 2025
  22. scgbckbone commented at 7:02 pm on April 22, 2025: none

    ACK dda90a9

    Nice find!

    external non-ranged descriptor MUST be able to have label (current impl disallows it)

    Since we already have a test for this and this PR doesn’t change it, could you clarify what you mean?

    the test in question:

    0        self.log.info("Should import a p2pkh descriptor")
    1        import_request = {"desc": descsum_create("pkh(" + key.pubkey + ")"),
    2                 "timestamp": "now",
    3                 "label": "Descriptor import test"}
    4        self.test_importdesc(import_request, success=True)
    

    passes as the bug does not manifest if “internal” is not provided by user

  23. scgbckbone commented at 7:03 pm on April 22, 2025: none
    re-based on current master
  24. achow101 commented at 0:29 am on April 23, 2025: member

    ACK 664657ed134365588914c2cf6a3975ce368a4f49

    passes as the bug does not manifest if “internal” is not provided by user

    I see. Can you mention that in the PR description?

    re-based on current master

    There’s no need to rebase if there are no conflicts.

  25. scgbckbone renamed this:
    wallet: allow label for non-ranged external descriptor & disallow label for ranged descriptors
    wallet: allow label for non-ranged external descriptor (if `internal=false`) & disallow label for ranged descriptors
    on Apr 23, 2025
  26. scgbckbone commented at 8:19 am on April 23, 2025: none
    PR description (and title) updated

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-05-05 18:13 UTC

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