From b0d0c2bb354b43966728d045d314c74161411402 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 21 Jul 2014 11:52:13 -0300 Subject: [PATCH] add example --- examples/NetworkMonitor.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/NetworkMonitor.js diff --git a/examples/NetworkMonitor.js b/examples/NetworkMonitor.js new file mode 100644 index 0000000..d61aecb --- /dev/null +++ b/examples/NetworkMonitor.js @@ -0,0 +1,29 @@ +'use strict'; + +var run = function() { + // Replace '../bitcore' with 'bitcore' if you use this code elsewhere. + var bitcore = require('../bitcore'); + var NetworkMonitor = bitcore.NetworkMonitor; + + var config = { + networkName: 'testnet', + host: 'localhost', + port: 18333 + }; + + + var nm = new NetworkMonitor.create(config); + // monitor incoming transactions to http://tpfaucet.appspot.com/ donation address + nm.incoming('msj42CCGruhRsFrGATiUuh25dtxYtnpbTx', function(tx) { + console.log('Donation to tpfaucet! '+JSON.stringify(tx.getStandardizedObject())); + }); + + // connect to bitcoin network and start listening + nm.start(); + +}; + +module.exports.run = run; +if (require.main === module) { + run(); +}