Skip to content

wallet: allow lable for external descriptor & disallow label for ranged descriptors

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)

Repro steps:

  • create blank wallet and import descriptors
  • external has label=test (not internal)
    conn = bitcoind.create_wallet(wallet_name=w_name, disable_private_keys=True, blank=True,
                                  passphrase=None, avoid_reuse=False, descriptors=True)
    descriptors = [
        {
            "timestamp": "now",
            "label": "test",
            "active": True,
            "desc": "wpkh([0f056943/84h/1h/0h]tpubDC7jGaaSE66Pn4dgtbAAstde4bCyhSUs4r3P8WhMVvPByvcRrzrwqSvpF9Ghx83Z1LfVugGRrSBko5UEKELCz9HoMv5qKmGq3fqnnbS5E9r/0/*)#erexmnep",
            "internal": False
        },
        {
            "desc": "wpkh([0f056943/84h/1h/0h]tpubDC7jGaaSE66Pn4dgtbAAstde4bCyhSUs4r3P8WhMVvPByvcRrzrwqSvpF9Ghx83Z1LfVugGRrSBko5UEKELCz9HoMv5qKmGq3fqnnbS5E9r/1/*)#ghu8xxfe",
            "active": True,
            "internal": True,
            "timestamp": "now"
        },
    ]
    r = conn.importdescriptors(descriptors)
    print(r)

response:

[{'error': {'code': -8,
            'message': 'Internal addresses should not have a label'},
  'success': False,
  'warnings': ['Range not given, using default keypool range']},
 {'success': True,
  '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:

[{'success': True,
  'warnings': ['Range not given, using default keypool range']},
 {'success': True,
  '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.

Merge request reports

Loading