|
|
@ -3,6 +3,7 @@ |
|
|
|
var _ = require('lodash'); |
|
|
|
var $ = require('../util/preconditions'); |
|
|
|
var buffer = require('buffer'); |
|
|
|
var compare = Buffer.compare || require('buffer-compare'); |
|
|
|
|
|
|
|
var errors = require('../errors'); |
|
|
|
var BufferUtil = require('../util/buffer'); |
|
|
@ -914,17 +915,17 @@ Transaction.prototype.removeOutput = function(index) { |
|
|
|
Transaction.prototype.sort = function() { |
|
|
|
this.sortInputs(function(inputs) { |
|
|
|
var copy = Array.prototype.concat.apply([], inputs); |
|
|
|
copy.sort(function compare(first, second) { |
|
|
|
return BufferUtil.compare(first.prevTxId, second.prevTxId) |
|
|
|
copy.sort(function(first, second) { |
|
|
|
return compare(first.prevTxId, second.prevTxId) |
|
|
|
|| first.outputIndex - second.outputIndex; |
|
|
|
}); |
|
|
|
return copy; |
|
|
|
}); |
|
|
|
this.sortOutputs(function(outputs) { |
|
|
|
var copy = Array.prototype.concat.apply([], outputs); |
|
|
|
copy.sort(function compare(first, second) { |
|
|
|
copy.sort(function(first, second) { |
|
|
|
return first.satoshis - second.satoshis |
|
|
|
|| BufferUtil.compare(first.script.toBuffer(), second.script.toBuffer()); |
|
|
|
|| compare(first.script.toBuffer(), second.script.toBuffer()); |
|
|
|
}); |
|
|
|
return copy; |
|
|
|
}); |
|
|
|