edilmedeiros / rust-bcli

Bitcoin CLI in Rust
GNU General Public License v3.0
6 stars 2 forks source link

Define a minimal set of options for the MVP #7

Open edilmedeiros opened 6 months ago

edilmedeiros commented 6 months ago

bitcoind --help lists all the options that can be used by the cli tool. @itornaza provided a dump in #2.

We want to eventually support everything and add more (like --json for backward-compatible inputs). But it's better to begin with less options and build upon later. So, Let's use this issue to agree with what it would look like.

edilmedeiros commented 6 months ago

I propose the following to begin:

  -?
       Print this help message and exit

  -conf=<file>
       Specify configuration file. Relative paths will be prefixed by datadir
       location. (default: bitcoin.conf)

  -datadir=<dir>
       Specify data directory

  -rpcconnect=<ip>
       Send commands to node running on <ip> (default: 127.0.0.1)

  -rpccookiefile=<loc>
       Location of the auth cookie. Relative paths will be prefixed by a
       net-specific datadir location. (default: data dir)

  -rpcpassword=<pw>
       Password for JSON-RPC connections

  -rpcport=<port>
       Connect to JSON-RPC on <port> (default: 8332, testnet: 18332, signet:
       38332, regtest: 18443)

  -rpcuser=<user>
       Username for JSON-RPC connections

  -stdin
       Read extra arguments from standard input, one per line until EOF/Ctrl-D
       (recommended for sensitive information such as passphrases). When
       combined with -stdinrpcpass, the first line from standard input
       is used for the RPC password.

  -version
       Print version and exit

Rationale:

  1. Just enough to connect and authenticate to the RPC server.
edilmedeiros commented 6 months ago

Notice we will need to redesign the options names and choose short versions for those that make sense to have a short version.

We are aiming for:

  1. double dashes for long names: --conf=<file>
  2. accept argument values both with and without =: --conf=<file> and --conf <file>

Also, I'm unsure what the semantics of --stdin should be since we aim for named inputs.

itornaza commented 6 months ago

I think that --stdin is normally used when we want to override the configuration file, and lets say provide a password directly from the command line. Nonetheless, I agree on your proposed minimal implementation concept!

edilmedeiros commented 6 months ago

I think that --stdin is normally used when we want to override the configuration file, and lets say provide a password directly from the command line. Nonetheless, I agree on your proposed minimal implementation concept!

It can be used to pass arguments to methods, line by line.

For instance:

$ echo "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6\n2" | bitcoin-cli -stdin getblock

(note the \n in the string).