Skip to content

A Node.js command-line interface (CLI) for bitcoin's remote procedure call (RPC) interface

License

Notifications You must be signed in to change notification settings

carnesen-archive/bitcoin-rpc-cli

Repository files navigation

@carnesen/bitcoin-rpc-cli npm version Build Status

A Node.js command-line client for bitcoin's remote procedure call (RPC) interface

Install

npm install --global @carnesen/bitcoin-rpc-cli

Alternatively, if you don't want to install the package you can run it as a one-off command using npx:

$ npx @carnesen/bitcoin-rpc-cli

Usage

Use the --help flag to get command usage:

$ bitcoin-rpc --help
Usage: bitcoin-rpc <options>

   Bitcoin remote procedure call (RPC)

Options:

   --method <str> : Method name
   [--params <json>] : Named or positional params
   [--configFilePath <str>] : Absolute path of a bitcoin configuration file
   [--format <str>] : Format of the result
                      Allowed values {'pretty', 'json'}
                      (Default = 'pretty')

Here's an example of calling the getnetworkinfo method:

$ bitcoin-rpc --method getnetworkinfo
{ version: 170000,
  subversion: '/Satoshi:0.17.0/',
...

Parameters are passed as JSON string, either an array of positional params or an object of named params:

$ bitcoin-rpc --method getblockhash --params '[0]'
0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206

$ bitcoin-rpc --method getblockhash --params '{"height": 0}'
0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206

More information

Check out the unit tests to see more examples of how it works. If you encounter any bugs or have any questions or feature requests, please don't hesitate to file an issue or submit a pull request on this project's repository on GitHub.

Related

License

MIT © Chris Arnesen

About

A Node.js command-line interface (CLI) for bitcoin's remote procedure call (RPC) interface

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published