Bitcoin-Node-Api
Bitcoin-Node-Api copied to clipboard
How to run bitcoin-node-api example ?
When I am trying to run below example as
var bitcoinapi = require('bitcoin-node-api');
var express = require('express');
var app = express();
var wallet = {
host: 'localhost',
port: 8332,
user: 'username',
pass: 'password'
};
bitcoinapi.setWalletDetails(wallet);
app.use('/bitcoin/api', bitcoinapi.app); //Bind the middleware to any chosen url
app.get('/getApi' , (req,res) => {
var url = 'http://localhost:3000/bitcoin/api/getinfo';
console.log('Url is :->',url);
var request = require('request');
request(url, function (error, response, body) {
console.log('response-->',response);
console.log('Error-->',error);
if (!error && response.statusCode == 200) {
//var response = JSON.parse(body);
res.send(response);
}
else {
console.log("Error "+error);
}
});
})
app.listen(3000,(port)=>{
console.log('Port at 3000');
});
and trying to run : node app.js it giving me an error as,
{ Error: connect ECONNREFUSED 127.0.0.1:8332
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8332 }
can you please tell me how to run bitcoin-node-api ??
Do you have a running blockchain on the server/machine you're running this file?
@Manbearpixel I am having the same problem and I do have blockchain running on the machine