2

When I importdescriptors to another bitcoin core wallet using the descriptor shown in the bitcoin core, the descriptor with hardened character can not used directly.

example: importdescriptors '[{ "desc": "pkh(tpubD92TWW3UxPVt7kL1JwM6pQLqiYUotoKH5TfaKftUCtk7FkRr2iMyrKyqKr7ixPdisMZXdxQUBn2qU1X4fZyCDcYLfibLhxUjCPXiNHp6vb1/0')#vq6m7zrg", "timestamp":"now", "internal": true }]'

bitcoin core-QT console shows error: Error: Invalid command line

bitcoin-cli in command line shows this error: -bash: syntax error near unexpected token `)'

I have to convert ' to h and regenerate checksum by hand,to this:

pkh(tpubD92TWW3UxPVt7kL1JwM6pQLqiYUotoKH5TfaKftUCtk7FkRr2iMyrKyqKr7ixPdisMZXdxQUBn2qU1X4fZyCDcYLfibLhxUjCPXiNHp6vb1/0h)#r7w93wm7

The bitcoin core shows descriptors' hardened character all use ', and the descriptor often uses importdescriptors RPC, but it's very inconvenient to use in practice. Is it possible to make bitcoin core shows the descriptors' hardened character as h?

Murch
  • 71,155
  • 33
  • 180
  • 600
MonKong
  • 53
  • 3

1 Answers1

5

There is an open PR which changes the hardened character to h.

In some shells, you can also escape the ' with a backslash (i.e. \') and bash will no longer consider that single quote to be the end quote of the string.

In other shells, you have to use double quotes (") around the entire string, but then you have to escape each internal double quote with a backslash.

Andrew Chow
  • 67,209
  • 5
  • 76
  • 149
  • Thank you for the quick answer. I tried to add one or two backslash before `'` (i.e.`\'`,`\\'`), both in command line in mac and QT console, but it shows the same error. – MonKong Apr 18 '23 at 23:44
  • @MonKong Hmm, I guess bash handles that differently from the shell that I use. I've updated the answer with a different way but requires a lot more escaping. – Andrew Chow Apr 19 '23 at 15:46
  • Never mind, I'll wait for the bitcoin core update.@Andrew Chow – MonKong Apr 20 '23 at 00:31