added fOverwintered flag, nVersionGroupId and nExpiryHeight to transaction

This commit is contained in:
Ian Munoz 2018-05-01 08:34:37 -06:00
parent 208069bee8
commit 97f7b5d3e3
1 changed files with 16 additions and 2 deletions

View File

@ -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());