From 16005103e038c315d0877f7c7ef34d1753ecaaa4 Mon Sep 17 00:00:00 2001 From: Sky Young Date: Sat, 20 Oct 2018 13:25:54 -0600 Subject: [PATCH] Get witness data as well for Coinbase Transaction. --- lib/mining/template.js | 12 +++++++++++- package.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/mining/template.js b/lib/mining/template.js index 02d1b78e..c96d7492 100644 --- a/lib/mining/template.js +++ b/lib/mining/template.js @@ -328,7 +328,7 @@ BlockTemplate.prototype.createCoinbase = function createCoinbase(hash) { BlockTemplate.prototype.refresh = function refresh() { const hash = this.getWitnessHash(); const cb = this.createCoinbase(hash); - const raw = cb.toNormal(); + const raw = cb.toRaw(); let size = 0; size += 4; // version @@ -336,6 +336,16 @@ BlockTemplate.prototype.refresh = function refresh() { size += cb.inputs[0].getSize(); // input size size -= 4 + 4 + 4; // -(nonce1 + nonce2 + sequence) + // Add to the size for floData :) + let bufferLength = Buffer.from(this.strFloData).length; + + if (this.strFloData.length > 0){ + size += encoding.sizeVarint(bufferLength); + size += bufferLength + } else { + size += encoding.sizeVarint(0); + } + // Cut off right after the nonce // push and before the sequence. const left = raw.slice(0, size); diff --git a/package.json b/package.json index 4bfd9989..49c26e3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fcoin", - "version": "1.0.0-beta.30", + "version": "1.0.0-beta.31", "description": "Flo bike-shed", "license": "MIT", "repository": "git://github.com/oipwg/fcoin.git",