Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: drcyw on January 26, 2014, 03:44:03 PM



Title: node-bitcoin express
Post by: drcyw on January 26, 2014, 03:44:03 PM
Hello -

I can't get the node-bitcoin rpc module running correctly in my express app... Either I get a connection refused error or I get a invalid params -32602

Here's a little code snipped from my app.js file.  Can somebody help me out on what I'm doing wrong here.  FYI, I do have port 8332 and 8333 open on nginx

/******* THIS GIVES ME INVALID PARAMS from -32602 ******/
var net = require('net');
var server = net.createServer(function(c) { //'connection' listener
console.log('server connected');
});
server.listen(8332, function() { //'listening' listener
console.log('server bound');
});

var bitcoinClient = new bitcoin.Client({
host: 'localhost',
port: 8332,
user: 'username',
pass: 'password'
});

bitcoinClient.getInfo(function(e, info){
if(e){ return console.log(e);}
});
/****************************************************************/

/******* THIS GIVES ME CONNECTION REFUSED ******/

var bitcoinClient = new bitcoin.Client({
host: 'localhost',
port: 8332,
user: 'username',
pass: 'password'
});

bitcoinClient.getInfo(function(e, info){
if(e){ return console.log(e);}
});
/****


Title: Re: node-bitcoin express
Post by: Nova! on January 28, 2014, 07:33:59 PM
You running node and the bitcoin wallet on the same computer?  If so that's stupid (you're begging to be compromised).  If not then change everything that says "localhost" to something that matches your actual topology.