-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Description
We have wrong varint encoding here https://github.com/z-classic/node-stratum-pool/blob/master/lib/blockTemplate.js#L91 for transaction count in block. Let's see results of default implementation:
1. this.txCount = 15, varInt = 0f
2. this.txCount = 127, varInt = 7f
3. this.txCount = 128, varInt = fd80
4. this.txCount = 256, varInt = fd0100
5. this.txCount = 777, varInt = fd0309
This is totally wrong for cases 3-5 and block with this encoding in Transaction Count field will be rejected with block decode failed error. Should be:
1. this.txCount = 15, varInt = 0f
2. this.txCount = 127, varInt = 7f
3. this.txCount = 128, varInt = fd8000
4. this.txCount = 256, varInt = fd0001
5. this.txCount = 777, varInt = fd0903
Here is a fix:
if (this.txCount <= 0x7f){
var varInt = new Buffer(txCount, 'hex');
}
else if (this.txCount <= 0x7fff){
if (txCount.length == 2) txCount = "00" + txCount;
var varInt = new Buffer.concat([Buffer('FD', 'hex'), util.reverseBuffer(new Buffer(txCount, 'hex'))]);
}
Alrighttt, himu007, miketout, BloodyNora and gcharang
Metadata
Metadata
Assignees
Labels
No labels