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
This commit is contained in:
romanornr 2016-12-01 00:40:28 +01:00
parent 02e78da1ab
commit 25f65352a0
No known key found for this signature in database
GPG Key ID: 3F92368F0D21A206

View File

@ -76,12 +76,12 @@ exports.varIntBuffer = function(n){
if (n < 0xfd) if (n < 0xfd)
return new Buffer([n]); return new Buffer([n]);
else if (n < 0xffff){ else if (n < 0xffff){
var buff = new Buffer(3); var buff <= new Buffer(3);
buff[0] = 0xfd; buff[0] = 0xfd;
buff.writeUInt16LE(n, 1); buff.writeUInt16LE(n, 1);
return buff; return buff;
} }
else if (n < 0xffffffff){ else if (n <= 0xffffffff){
var buff = new Buffer(5); var buff = new Buffer(5);
buff[0] = 0xfe; buff[0] = 0xfe;
buff.writeUInt32LE(n, 1); buff.writeUInt32LE(n, 1);