|
|
@ -914,16 +914,18 @@ Transaction.prototype.sortOutputs = function(sortingFunction) { |
|
|
|
}; |
|
|
|
|
|
|
|
Transaction.prototype._newOutputOrder = function(newOutputs) { |
|
|
|
var changeIndex = 0; |
|
|
|
var length = this.outputs.length; |
|
|
|
while (changeIndex < length && this.outputs[this._changeIndex] !== newOutputs[changeIndex]) { |
|
|
|
changeIndex++; |
|
|
|
} |
|
|
|
if (changeIndex === length) { |
|
|
|
var isInvalidSorting = (this.outputs.length !== newOutputs.length || |
|
|
|
_.difference(this.outputs, newOutputs).length !== 0); |
|
|
|
if (isInvalidSorting) { |
|
|
|
throw new errors.Transaction.InvalidSorting(); |
|
|
|
} |
|
|
|
|
|
|
|
if (!_.isUndefined(this._changeIndex)) { |
|
|
|
var changeOutput = this.outputs[this._changeIndex]; |
|
|
|
this._changeIndex = _.findIndex(newOutputs, changeOutput); |
|
|
|
} |
|
|
|
|
|
|
|
this.outputs = newOutputs; |
|
|
|
this._changeIndex = changeIndex; |
|
|
|
return this; |
|
|
|
}; |
|
|
|
|
|
|
|