From 97f7b5d3e34d9392dd0bfbaaf98fd03ca8492cf7 Mon Sep 17 00:00:00 2001 From: Ian Munoz Date: Tue, 1 May 2018 08:34:37 -0600 Subject: [PATCH] added fOverwintered flag, nVersionGroupId and nExpiryHeight to transaction --- lib/transaction/transaction.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 6d22684..0c2d569 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -313,8 +313,19 @@ Transaction.prototype.fromBuffer = function(buffer) { Transaction.prototype.fromBufferReader = function(reader) { $.checkArgument(!reader.finished(), 'No transaction data received'); var i, sizeTxIns, sizeTxOuts, sizeJSDescs; + var header = reader.readUInt32LE(); + this.fOverwintered = header & 0x80000000; + + if ( this.fOverwintered == true ) { + this.version = header & 0x7fffffff; + } else { + this.version = header; + } + + if ( this.version >= 3 ){ + this.nVersionGroupId = reader.readUInt32LE(); + } - this.version = reader.readUInt32LE(); sizeTxIns = reader.readVarintNum(); for (i = 0; i < sizeTxIns; i++) { var input = Input.fromBufferReader(reader); @@ -325,6 +336,9 @@ Transaction.prototype.fromBufferReader = function(reader) { this.outputs.push(Output.fromBufferReader(reader)); } this.nLockTime = reader.readUInt32LE(); + if (this.version >= 3) { + this.nExpiryHeight = reader.readUInt32LE(); + } if (this.version >= 2) { sizeJSDescs = reader.readVarintNum(); for (i = 0; i < sizeJSDescs; i++) { @@ -354,7 +368,7 @@ Transaction.prototype.toObject = Transaction.prototype.toJSON = function toObjec outputs: outputs, nLockTime: this.nLockTime }; - if (this.version >= 2) { + if (this.version >= 3) { var joinSplits = []; this.joinSplits.forEach(function(joinSplit) { joinSplits.push(joinSplit.toObject());