Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/carnesen-archive/bitcoin-rpc-cli

A Node.js command-line interface (CLI) for bitcoin's remote procedure call (RPC) interface
https://github.com/carnesen-archive/bitcoin-rpc-cli

bitcoin bitcoin-rpc bitcoin-rpc-cli cli nodejs rpc typescript

Last synced: about 9 hours ago
JSON representation

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

Awesome Lists containing this project

README

        

# @carnesen/bitcoin-rpc-cli [![npm version](https://badge.fury.io/js/%40carnesen%2Fbitcoin-rpc-cli.svg)](https://badge.fury.io/js/%40carnesen%2Fbitcoin-rpc-cli) [![Build Status](https://travis-ci.com/carnesen/bitcoin-rpc-cli.svg?branch=master)](https://travis-ci.com/carnesen/bitcoin-rpc-cli)

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

Bitcoin remote procedure call (RPC)

Options:

--method : Method name
[--params ] : Named or positional params
[--configFilePath ] : Absolute path of a bitcoin configuration file
[--format ] : 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](src/__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
- [@carnesen/bitcoin-rpc](https://github.com/carnesen/bitcoin-rpc): A Node.js client library for bitcoin's remote procedure call (RPC) interface
- [@carnesen/bitcoin-rpc-href](https://github.com/carnesen/bitcoin-rpc-href): A Node.js library for reading bitcoin's remote procedure call (RPC) configuration
- [@carnesen/cli](https://github.com/carnesen/cli): A Node.js library for building command-line interfaces

## License

MIT © [Chris Arnesen](https://www.carnesen.com)