From 25f65352a09b5df4dc014dd0eaf7c37610ecff6c Mon Sep 17 00:00:00 2001 From: romanornr Date: Thu, 1 Dec 2016 00:40:28 +0100 Subject: [PATCH] Variable length integer IntBuffer fix https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer Blocks with amount of transactions > 65535 will be rejected. Fixed now --- lib/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util.js b/lib/util.js index 453939c..04030e1 100644 --- a/lib/util.js +++ b/lib/util.js @@ -76,12 +76,12 @@ exports.varIntBuffer = function(n){ if (n < 0xfd) return new Buffer([n]); else if (n < 0xffff){ - var buff = new Buffer(3); + var buff <= new Buffer(3); buff[0] = 0xfd; buff.writeUInt16LE(n, 1); return buff; } - else if (n < 0xffffffff){ + else if (n <= 0xffffffff){ var buff = new Buffer(5); buff[0] = 0xfe; buff.writeUInt32LE(n, 1); @@ -373,4 +373,4 @@ exports.convertBitsToBuff = function(bitsBuff){ exports.getTruncatedDiff = function(shift){ return exports.convertBitsToBuff(exports.bufferToCompactBits(exports.shiftMax256Right(shift))); -}; \ No newline at end of file +};