Use correct varint value (#54)

Explanation of this code provided by blondefrogs:

The transactions in a block are places in a vector. To serialize a vector, we need to be able to read its contents, so it serializes the size of the vector first but we don't know the size, so it uses a variable called a varint. A varint is trying to serialize the size in as little bits as possible. If the size is below 0xfc, it will just serialize the size Otherwise, if the size is above 0xfc, it will serialize a 0xfd first, then the size.

Basically, before this fix, the stratum would submit an invalidly coded block to the node if there were between 127 - 253 transactions in the block.
This commit is contained in:
Jeremy Anderson 2020-04-16 00:05:15 -06:00 committed by GitHub
parent b12e0b7c79
commit b36b7792ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -189,7 +189,7 @@ var BlockTemplate = module.exports = function BlockTemplate(
txCount = "0" + txCount;
}
if (this.txCount <= 0x7f){
if (this.txCount <= 0xfc){
var varInt = new Buffer(txCount, 'hex');
} else if (this.txCount <= 0x7fff) {
if (txCount.length == 2) {