From 8024b466e9ea665dc3c338ae1f707b79c7db5576 Mon Sep 17 00:00:00 2001 From: Sky Young Date: Mon, 28 Oct 2019 13:01:59 -0600 Subject: [PATCH] Calculate the extra floData size to add to the Buffer when initializing --- lib/primitives/tx.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js index b6606736..6e0349e8 100644 --- a/lib/primitives/tx.js +++ b/lib/primitives/tx.js @@ -719,7 +719,16 @@ class TX { } } - const size = 156 + prev.getVarSize(); + // Calculate the extra floData size to add to the Buffer when initializing + let extraFloDataSize = 0 + if (this.version >= 2 && includeFloData){ + let bufferLength = this.floData.length; + + extraFloDataSize += encoding.sizeVarint(bufferLength); + extraFloDataSize += bufferLength + } + + const size = 156 + prev.getVarSize() + extraFloDataSize; const bw = bio.pool(size); bw.writeU32(this.version);