diff --git a/Block.js b/Block.js index 5cae78b..9efa15f 100644 --- a/Block.js +++ b/Block.js @@ -64,7 +64,7 @@ function spec(b) { var txCount = parser.varInt(); - for (i = 0; i < txCount; i++) { + for (var i = 0; i < txCount; i++) { var tx = new Transaction(); tx.parse(parser); this.txs.push(tx); diff --git a/Connection.js b/Connection.js index a50edb5..3558b15 100644 --- a/Connection.js +++ b/Connection.js @@ -476,7 +476,7 @@ function spec(b) { lock_time: tx.lock_time, ins: tx.ins, outs: tx.outs, - tx: tx, + tx: tx, }; case 'getblocks': diff --git a/Transaction.js b/Transaction.js index 205ffc5..0cc95bb 100644 --- a/Transaction.js +++ b/Transaction.js @@ -553,7 +553,7 @@ function spec(b) { var ins = this.ins.map(function (txin) { var txinObj = { prev_out: { - hash: new Buffer(txin.getOutpointHash()).reverse().toString(hex), + hash: new Buffer(txin.getOutpointHash()).reverse().toString('hex'), n: txin.getOutpointIndex() } }; diff --git a/const.js b/const.js index cd6a77e..9edf459 100644 --- a/const.js +++ b/const.js @@ -1,7 +1,18 @@ -exports.MSG = { +MSG = { TX: 1, BLOCK: 2, FILTERED_BLOCK: 3, }; +MSG.to_str = function(t) { + switch(t) { + case MSG.TX: return 'transaction'; + case MSG.BLOCK: return 'block'; + case MSG.FILTERED_BLOCK: return 'filtered block'; + default: return 'unknown'; + } +} + +exports.MSG = MSG; +