Skip to content

Inconsistent hardened derivation marker in listdescriptors output #31694

@jp1ac4

Description

@jp1ac4

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

If I use importdescriptors to import a descriptor that uses only ' as the hardened derivation marker, the corresponding output of listdescriptors sometimes uses a mix of ' and h.

Expected behaviour

I would expect the output for a given imported descriptor to either match my input or otherwise use only one of ' and h.

I would also expect the behaviour to be consistent across different descriptors.

Steps to reproduce

  1. Create wallet:
$ bitcoin-cli -regtest createwallet test_h_vs_apostrophe true
{
  "name": "test_h_vs_apostrophe"
}
  1. Import tr descriptor:
$ bitcoin-cli -regtest -rpcwallet=test_h_vs_apostrophe importdescriptors "[{\"desc\": \"tr([1dce71b2/48'/1'/0'/2']tpubDEeP3GefjqbaDTTaVAF5JkXWhoFxFDXQ9KuhVrMBViFXXNR2B3Lvme2d2AoyiKfzRFZChq2AGMNbU1qTbkBMfNv7WGVXLt2pnYXY87gXqcs/0/*,and_v(v:pk([1dce71b2/48'/1'/0'/2']tpubDEeP3GefjqbaDTTaVAF5JkXWhoFxFDXQ9KuhVrMBViFXXNR2B3Lvme2d2AoyiKfzRFZChq2AGMNbU1qTbkBMfNv7WGVXLt2pnYXY87gXqcs/2/*),older(65535)))#xhrh0cvn\", \"timestamp\": \"now\"}]"
[
  {
    "success": true,
    "warnings": [
      "Range not given, using default keypool range"
    ]
  }
]
  1. Import wsh descriptor:
$ bitcoin-cli -regtest -rpcwallet=test_h_vs_apostrophe importdescriptors "[{\"desc\": \"wsh(or_d(pk([a233d117/48'/1'/0'/2']tpubDF8d1Q2U8WWfxUHMiqqrYiavBReX2r7hwD7oQsEuq1AiXj5nJcLBkoh1uTLZVx66VrbRfeHyg5bSFvRKzesa1yzYuXDvawZeRi9m97a2Qzd/0/*),and_v(v:pkh([a233d117/48'/1'/0'/2']tpubDF8d1Q2U8WWfxUHMiqqrYiavBReX2r7hwD7oQsEuq1AiXj5nJcLBkoh1uTLZVx66VrbRfeHyg5bSFvRKzesa1yzYuXDvawZeRi9m97a2Qzd/2/*),older(65535))))#segwrd5h\", \"timestamp\": \"now\"}]"
[
  {
    "success": true,
    "warnings": [
      "Range not given, using default keypool range"
    ]
  }
]

When calling listdescriptors, the tr descriptor uses a mix of h and ' (and checksum has changed), while wsh uses only ' (and has same checksum):

$ bitcoin-cli -regtest -rpcwallet=test_h_vs_apostrophe listdescriptors
{
  "wallet_name": "test_h_vs_apostrophe",
  "descriptors": [
    {
      "desc": "tr([1dce71b2/48h/1h/0h/2h]tpubDEeP3GefjqbaDTTaVAF5JkXWhoFxFDXQ9KuhVrMBViFXXNR2B3Lvme2d2AoyiKfzRFZChq2AGMNbU1qTbkBMfNv7WGVXLt2pnYXY87gXqcs/0/*,and_v(v:pk([1dce71b2/48'/1'/0'/2']tpubDEeP3GefjqbaDTTaVAF5JkXWhoFxFDXQ9KuhVrMBViFXXNR2B3Lvme2d2AoyiKfzRFZChq2AGMNbU1qTbkBMfNv7WGVXLt2pnYXY87gXqcs/2/*),older(65535)))#2h7g2wme",
      "timestamp": 1296688602,
      "active": false,
      "range": [
        0,
        999
      ],
      "next": 0,
      "next_index": 0
    },
    {
      "desc": "wsh(or_d(pk([a233d117/48'/1'/0'/2']tpubDF8d1Q2U8WWfxUHMiqqrYiavBReX2r7hwD7oQsEuq1AiXj5nJcLBkoh1uTLZVx66VrbRfeHyg5bSFvRKzesa1yzYuXDvawZeRi9m97a2Qzd/0/*),and_v(v:pkh([a233d117/48'/1'/0'/2']tpubDF8d1Q2U8WWfxUHMiqqrYiavBReX2r7hwD7oQsEuq1AiXj5nJcLBkoh1uTLZVx66VrbRfeHyg5bSFvRKzesa1yzYuXDvawZeRi9m97a2Qzd/2/*),older(65535))))#segwrd5h",
      "timestamp": 1296688602,
      "active": false,
      "range": [
        0,
        999
      ],
      "next": 0,
      "next_index": 0
    }
  ]
}

Relevant log output

No response

How did you obtain Bitcoin Core

Pre-built binaries

What version of Bitcoin Core are you using?

v28.0.0

Operating system and version

Ubuntu 24.04

Machine specifications

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions