Created
September 14, 2018 14:03
-
-
Save makevoid/40036988ef6d89ca5f86ae5e210a8b56 to your computer and use it in GitHub Desktop.
NodeJS "core-client" module for interacting with Bitcoin Core via RPC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CoreClient = require('bitcoin-core') // npm i --save bitcoinc-re | |
const host = '127.0.0.1' // ssh -L 8332:localhost:8332 root@YOUR_SERVER_IP -N # (ssh tunnel) | |
const core = new CoreClient({ // you have to | |
host: host, | |
username: 'bitcoin', | |
password: "PASSWORD", | |
}) | |
;(async () => { | |
const coreInfo = await core.getInfo() | |
console.log(coreInfo) | |
const balance = await core.getBalance() | |
console.log(balance) | |
// all the methods listed in bitcoin-cli / bitcoin RPC documentation | |
// ... await core.methodName(...) | |
})() | |
// $ cat ~/.bitcoin/bitcoin.conf | |
// | |
// txindex=1 | |
// rpcuser=bitcoin | |
// rpcpassword=PASSWORD | |
// dbcache=1500 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment