From 19348b09f25a0d5f1399a1a8e285be160d33b213 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 19 Mar 2015 11:40:30 -0300 Subject: [PATCH] move reporters file --- index.js | 31 +------------------------------ lib/reporters.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 lib/reporters.js diff --git a/index.js b/index.js index 98ceb56b..aae7b25e 100644 --- a/index.js +++ b/index.js @@ -1,38 +1,9 @@ 'use strict'; var BitcoreNode = require('./lib/node'); -var bitcore = require('bitcore'); -var Unit = bitcore.Unit; +var reporters = require('./lib/reporters'); if (require.main === module) { - var reporters = {}; - reporters.none = function() { - // do nothing - }; - reporters.matrix = function(tx) { - var s = tx.toString(); - for (var i = 0; i < s.length; i++) { - var slice = s.slice(4 * i, 4 * (i + 1)); - if (slice.length < 4) { - continue; - } - var c = JSON.parse('"\\u' + slice + '"'); - process.stdout.write(c); - } - }; - reporters.simple = function(tx) { - var tout = Unit.fromSatoshis(tx.outputAmount).toBTC(); - console.log('Transaction:', tx.id); - console.log('\ttotal_out:', tout, 'BTC'); - console.log('\tinput addresses:'); - tx.inputs.forEach(function(inp) { - console.log('\t\t' + inp.script.toAddress()); - }); - console.log('\toutput addresses:'); - tx.outputs.forEach(function(out) { - console.log('\t\t' + out.script.toAddress()); - }); - }; var config = require('config'); var node = BitcoreNode.create(config.get('BitcoreNode')); node.start(); diff --git a/lib/reporters.js b/lib/reporters.js new file mode 100644 index 00000000..1e46849b --- /dev/null +++ b/lib/reporters.js @@ -0,0 +1,35 @@ +'use strict'; + +var bitcore = require('bitcore'); +var Unit = bitcore.Unit; + +var reporters = {}; +reporters.none = function() { + // do nothing +}; +reporters.matrix = function(tx) { + var s = tx.toString(); + for (var i = 0; i < s.length; i++) { + var slice = s.slice(4 * i, 4 * (i + 1)); + if (slice.length < 4) { + continue; + } + var c = JSON.parse('"\\u' + slice + '"'); + process.stdout.write(c); + } +}; +reporters.simple = function(tx) { + var tout = Unit.fromSatoshis(tx.outputAmount).toBTC(); + console.log('Transaction:', tx.id); + console.log('\ttotal_out:', tout, 'BTC'); + console.log('\tinput addresses:'); + tx.inputs.forEach(function(inp) { + console.log('\t\t' + inp.script.toAddress()); + }); + console.log('\toutput addresses:'); + tx.outputs.forEach(function(out) { + console.log('\t\t' + out.script.toAddress()); + }); +}; + +module.exports = reporters;