gui icon indicating copy to clipboard operation
gui copied to clipboard

Unquoted descriptor arguments cause RPC console to improperly detect method name

Open achow101 opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behaviour

Using the RPC console with a command that has descriptor arguments results in a Method not found error.

Expected behaviour

The command should either accept the argument as is, or return an error about failing to parse the argument.

Steps to reproduce

> getdescriptorinfo wpkh(cNaQCDwmmh4dS9LzCgVtyy1e1xjCJ21GUDHe9K98nzb689JvinGV)
Method not found (code -32601)

Relevant log output

No response

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

v25.99.0-c92fd638860c

Operating system and version

Arch Linux

Machine specifications

No response

achow101 avatar Jun 12 '23 22:06 achow101

Ah, the issue is actually with the parentheses. The console thinks those are the beginning of a nested command or a more function-like syntax, introduced in https://github.com/bitcoin/bitcoin/pull/7783

achow101 avatar Jun 12 '23 23:06 achow101

Perhaps I 'm saying something obvious, but a good workaround migth be enclosing the descriptor with double quotes:

> getdescriptorinfo "wpkh(cNaQCDwmmh4dS9LzCgVtyy1e1xjCJ21GUDHe9K98nzb689JvinGV)"
{
  "descriptor": "wpkh(02fcba7ecf41bc7e1be4ee122d9d22e3333671eb0a3a87b5cdf099d59874e1940f)#442qn8e8",
  "checksum": "3qah2w9c",
  "isrange": false,
  "issolvable": true,
  "hasprivatekeys": true
}

Single quotes might work for some descriptors, but will probably fail with descriptors including hardened derivation paths.

hernanmarino avatar Jun 16 '23 17:06 hernanmarino

Perhaps I 'm saying something obvious, but a good workaround migth be enclosing the descriptor with double quotes:

Yes, that is the correct way to pass these strings. However method not found seems like the incorrect error to be giving when not using them.

Additionally, double quotes gets really confusing and insane when using RPCs that involve json like importdescriptors.

achow101 avatar Jun 16 '23 17:06 achow101