|
|
@ -135,7 +135,7 @@ Transaction.prototype.uncheckedSerialize = Transaction.prototype.toString = func |
|
|
|
* Retrieve a hexa string that can be used with bitcoind's CLI interface |
|
|
|
* (decoderawtransaction, sendrawtransaction) |
|
|
|
* |
|
|
|
* @param {Object} skipOptions allows to skip certain tests: |
|
|
|
* @param {Object} opts allows to skip certain tests: |
|
|
|
* <ul> |
|
|
|
* <li><tt>disableSmallFees</tt>: disable checking for fees that are too small</li> |
|
|
|
* <li><tt>disableLargeFees</tt>: disable checking for fees that are too large</li> |
|
|
@ -144,27 +144,27 @@ Transaction.prototype.uncheckedSerialize = Transaction.prototype.toString = func |
|
|
|
* </ul> |
|
|
|
* @return {string} |
|
|
|
*/ |
|
|
|
Transaction.prototype.checkedSerialize = function(skipOptions) { |
|
|
|
skipOptions = skipOptions || {}; |
|
|
|
Transaction.prototype.checkedSerialize = function(opts) { |
|
|
|
opts = opts || {}; |
|
|
|
var missingChange = this._missingChange(); |
|
|
|
var feeIsTooLarge = this._isFeeTooLarge(); |
|
|
|
var feeIsTooSmall = this._isFeeTooSmall(); |
|
|
|
var isFullySigned = this.isFullySigned(); |
|
|
|
var hasDustOutputs = this._hasDustOutputs(); |
|
|
|
|
|
|
|
if (!skipOptions.disableLargeFees && feeIsTooLarge) { |
|
|
|
if (!opts.disableLargeFees && feeIsTooLarge) { |
|
|
|
if (missingChange) { |
|
|
|
throw new errors.Transaction.ChangeAddressMissing('Fee is too large and no change address was provided'); |
|
|
|
} |
|
|
|
throw new errors.Transaction.FeeError(feeIsTooLarge); |
|
|
|
} |
|
|
|
if (!skipOptions.disableSmallFees && feeIsTooSmall) { |
|
|
|
if (!opts.disableSmallFees && feeIsTooSmall) { |
|
|
|
throw new errors.Transaction.FeeError(feeIsTooSmall); |
|
|
|
} |
|
|
|
if (!skipOptions.disableDustOutputs && this._hasDustOutputs()) { |
|
|
|
if (!opts.disableDustOutputs && this._hasDustOutputs()) { |
|
|
|
throw new errors.Transaction.DustOutputs(); |
|
|
|
} |
|
|
|
if (!skipOptions.disableIsFullySigned && !isFullySigned) { |
|
|
|
if (!opts.disableIsFullySigned && !isFullySigned) { |
|
|
|
throw new errors.Transaction.MissingSignatures(); |
|
|
|
} |
|
|
|
return this.uncheckedSerialize(); |
|
|
|