2014-03-15 17:58:28 -07:00
|
|
|
/*
|
2014-04-08 11:23:48 -07:00
|
|
|
This script should be hooked to the coin daemon as follow:
|
2014-04-15 15:38:51 -07:00
|
|
|
litecoind -blocknotify="node /path/to/this/script/blockNotify.js 127.0.0.1:8117 password litecoin %s"
|
2014-04-08 11:23:48 -07:00
|
|
|
The above will send tell litecoin to launch this script with those parameters every time a block is found.
|
|
|
|
This script will then send the blockhash along with other information to a listening tcp socket
|
|
|
|
*/
|
2014-02-28 19:12:59 -08:00
|
|
|
|
2014-04-08 11:23:48 -07:00
|
|
|
var net = require('net');
|
|
|
|
var config = process.argv[2];
|
|
|
|
var parts = config.split(':');
|
|
|
|
var host = parts[0];
|
|
|
|
var port = parts[1];
|
|
|
|
var password = process.argv[3];
|
|
|
|
var coin = process.argv[4];
|
2014-03-25 11:52:11 -07:00
|
|
|
var blockHash = process.argv[5];
|
2014-02-28 19:12:59 -08:00
|
|
|
|
2014-04-08 11:23:48 -07:00
|
|
|
var client = net.connect(port, host, function () {
|
2014-02-28 19:12:59 -08:00
|
|
|
console.log('client connected');
|
|
|
|
client.write(JSON.stringify({
|
|
|
|
password: password,
|
|
|
|
coin: coin,
|
2014-03-04 12:24:02 -08:00
|
|
|
hash: blockHash
|
2014-02-28 19:12:59 -08:00
|
|
|
}) + '\n');
|
|
|
|
});
|
|
|
|
|
2014-04-08 11:23:48 -07:00
|
|
|
client.on('data', function (data) {
|
2014-02-28 19:12:59 -08:00
|
|
|
console.log(data.toString());
|
|
|
|
//client.end();
|
|
|
|
});
|
|
|
|
|
2014-04-08 11:23:48 -07:00
|
|
|
client.on('end', function () {
|
2014-02-28 19:12:59 -08:00
|
|
|
console.log('client disconnected');
|
|
|
|
//process.exit();
|
|
|
|
});
|