diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 023a1121..24c18ec2 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -35,17 +35,6 @@ Bitcoin.prototype.start = function(callback) { var errorCaught = none; this.log_pipe = bitcoindjs.start(function(err, status) { - if (callback) { - callback(err); - callback = null; - } - - if (err) { - self.emit('error', err); - } else { - self.emit('open', status); - } - process.on('SIGINT', self.stop.bind(self)); process.on('SIGHUP', self.stop.bind(self)); @@ -69,6 +58,17 @@ Bitcoin.prototype.start = function(callback) { } self.stop(); }); + + if (callback) { + callback(err); + callback = null; + } + + if (err) { + self.emit('error', err); + } else { + self.emit('open', status); + } }); // bitcoind's boost threads aren't in the thread pool