createwallet RPC method: Various features unusable with positional params and bitcoin-cli #22425

issue luke-jr opened this issue on July 10, 2021
  1. luke-jr commented at 10:49 PM on July 10, 2021: member

    bitcoin-cli has no way to omit positional params, but when creating a watch-only wallet, createwallet will error if passphrase is provided. This effectively prevents such commands from using the later parameters (avoid_reuse, descriptors, load_on_startup, and external_signer).

    (n.b. all of those inaccessible params should really be an options Object when using positional parameters anyway; why does the interface suck? :/ )

  2. luke-jr added the label Bug on Jul 10, 2021
  3. luke-jr commented at 10:51 PM on July 10, 2021: member

    Actually, it looks like we accept the null string here. User reporting it has something else going on.

  4. luke-jr closed this on Jul 10, 2021

  5. PsySc0rpi0n commented at 10:59 PM on July 10, 2021: none

    It's the error message we get. I'm not even sure the wallet is created.

    $ bitcoin-cli createwallet MyWatchWallet true true null false true true
    error code: -4
    error message:
    Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled
    
  6. achow101 commented at 11:28 PM on July 10, 2021: member

    Named parameters can be used.

    bitcoin-cli -named createwallet wallet_name=MyWatchWallet disable_private_keys=true blank=true descriptors=true load_on_startup=true
    

    I agree this should be changed to an object, but it needs to be done in a way that doesn't break the API for existing users.

  7. ryanofsky commented at 6:45 PM on July 11, 2021: member

    (n.b. all of those inaccessible params should really be an options Object when using positional parameters anyway; why does the interface suck? :/ )

    I think the reason the interface is awkward is that #19762 hasn't been merged, so there is no way to combine positional arguments with named arguments. #19762 is a basic building block that could be extended more, but this approach should be more command line friendly than using an options object, because you can pass the options as name=value literals, and not have to manually construct json object literals using braces and quotes and double-escaped strings. It is also more python-friendly because python naturally supports combining named arguments with positional arguments, so it removes an artificial error preventing this when calling RPC functions from python.

  8. luke-jr commented at 11:58 PM on July 11, 2021: member

    They shouldn't have positions in the first place. #19762 is fine, but it needs a non-standard JSON-RPC client.

    The positional arguments should simply take an options Object at the end of the logically-positional params, like other existing RPC methods do.

    #17356 would have been a good step toward making this simpler, but alas never got enough eyes.

  9. DrahtBot locked this on Aug 18, 2022

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: 2026-04-14 15:14 UTC

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