bitcoin-rpc-api
A modern full-featured Bitcoin Core REST and RPC Express middleware to execute administrative tasks, multiwallet operations and queries about network and the blockchain using URL structure exposed for easy interfacing with a bitcoind Bitcoin wallet..
Status
Installation
Install the package via npm
:
npm install bitcoin-rpc-api --save
Usage
Examples
Using Node.js
Example of a setup
var bitcoin = ;var express = ;var app = ; //Username and password relate to those set in the bitcoin.conf file var node = protocol: 'http' host: 'localhost' port: 8332 user: 'username' pass: 'password'; bitcoin;app; //Bind the middleware to any chosen url app;
Client/Browser
Just add the method name after the binded url.
For example:
This will return data as expected from bitcoin-cli
"chain": "main" "blocks": 559438 "headers": 559438 "bestblockhash": "" "difficulty": 5883988430955408 "mediantime": 1548061269 "verificationprogress": 09999991510791459 "initialblockdownload": false "chainwork": "" "size_on_disk": 548902880 "pruned": true "prune_target_size": 576716800 "softforks": ... "bip9_softforks": "csv": ... "segwit": ... "warnings": ""
Parameters should be sent via a query string:
Client(...args)
Params
The command sh bitcoin-cli validateaddress "1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc"
can be converted as
This will return in similar faishon.
"result": "isvalid": true "address": "1N2xxpqDDPb1wm" "scriptPubKey": "76a914e6b9c5ba5d75088ac" "ismine": false "iswatchonly": false "isscript": false "iswitness": false "error": null "id": null
Consult the API list for parameter information.
More APIs with complex params coming soon...
.walletPass(passphrase);
If your wallet is encrypted set that before using middleware. Ex:
bitcoin;bitcoin;app;
Projects
Bitcoin-RPC-Api is used in the following projects:
If you use Bitcoin-RPC-Api in your projects submit a pull request to the readme with a link or send me an email: dibyanshu.sunny@gmail.com
Licence
Code released under the MIT license.
Copyright (C) 2019 Dibyanshu