|
@ -529,7 +529,7 @@ Transaction.prototype._updateChangeOutput = function() { |
|
|
} |
|
|
} |
|
|
this._clearSignatures(); |
|
|
this._clearSignatures(); |
|
|
if (!_.isUndefined(this._changeOutput)) { |
|
|
if (!_.isUndefined(this._changeOutput)) { |
|
|
this.removeOutput(this._changeOutput); |
|
|
this._removeOutput(this._changeOutput); |
|
|
} |
|
|
} |
|
|
var available = this._getUnspentValue(); |
|
|
var available = this._getUnspentValue(); |
|
|
var fee = this.getFee(); |
|
|
var fee = this.getFee(); |
|
@ -589,10 +589,33 @@ Transaction.prototype._estimateSize = function() { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Transaction.prototype.removeOutput = function(index) { |
|
|
Transaction.prototype._removeOutput = function(index) { |
|
|
var output = this.outputs[index]; |
|
|
var output = this.outputs[index]; |
|
|
this._outputAmount -= output.satoshis; |
|
|
this._outputAmount -= output.satoshis; |
|
|
this.outputs = _.without(this.outputs, this.outputs[this._changeOutput]); |
|
|
this.outputs = _.without(this.outputs, output); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Transaction.prototype.removeOutput = function(index) { |
|
|
|
|
|
this._removeOutput(index); |
|
|
|
|
|
this._updateChangeOutput(); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Transaction.prototype.removeInput = function(txId, outputIndex) { |
|
|
|
|
|
var index; |
|
|
|
|
|
if (!outputIndex && _.isNumber(txId)) { |
|
|
|
|
|
index = txId; |
|
|
|
|
|
} else { |
|
|
|
|
|
index = _.findIndex(this.inputs, function(input) { |
|
|
|
|
|
return input.prevTxId.toString('hex') === txId && input.outputIndex === outputIndex; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (index < 0 || index >= this.inputs.length) { |
|
|
|
|
|
throw new errors.Transaction.InvalidIndex(index, this.inputs.length); |
|
|
|
|
|
} |
|
|
|
|
|
var input = this.inputs[index]; |
|
|
|
|
|
this._inputAmount -= input.output.satoshis; |
|
|
|
|
|
this.inputs = _.without(this.inputs, input); |
|
|
|
|
|
this._updateChangeOutput(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/* Signature handling */ |
|
|
/* Signature handling */ |
|
|