|
|
@ -120,8 +120,13 @@ Transaction.fromBuffer = function (buffer, __noStrict) { |
|
|
|
} |
|
|
|
|
|
|
|
if (hasWitnesses) { |
|
|
|
var isNull = true |
|
|
|
for (i = 0; i < vinLen; ++i) { |
|
|
|
tx.ins[i].witness = readVector() |
|
|
|
isNull = isNull && tx.ins[i].witness.length === 0 |
|
|
|
} |
|
|
|
if (isNull) { |
|
|
|
throw new Error('Transaction has superfluous witness data') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -409,6 +414,7 @@ Transaction.prototype.toBuffer = function (buffer, initialOffset) { |
|
|
|
writeInt32(this.version) |
|
|
|
|
|
|
|
var hasWitnesses = this._hasWitnesses() |
|
|
|
var serializeWitnesses = hasWitnesses // TODO: remove this, temporary
|
|
|
|
|
|
|
|
if (hasWitnesses) { |
|
|
|
writeUInt8(Transaction.ADVANCED_TRANSACTION_MARKER) |
|
|
@ -435,10 +441,15 @@ Transaction.prototype.toBuffer = function (buffer, initialOffset) { |
|
|
|
writeVarSlice(txOut.script) |
|
|
|
}) |
|
|
|
|
|
|
|
if (hasWitnesses) { |
|
|
|
if (serializeWitnesses) { |
|
|
|
var isNull = true |
|
|
|
this.ins.forEach(function (input) { |
|
|
|
writeVector(input.witness) |
|
|
|
isNull = isNull && input.witness.length === 0 |
|
|
|
}) |
|
|
|
if (isNull) { |
|
|
|
throw new Error('Transaction has superfluous witness data') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
writeUInt32(this.locktime) |
|
|
|