|
|
@ -1270,9 +1270,10 @@ WalletService.prototype._checkTx = function(txp) { |
|
|
|
WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
//todo: check inputs are ours and has enough value
|
|
|
|
if (txp.inputs && txp.inputs.length > 0) { |
|
|
|
self._estimateFee(txp); |
|
|
|
//todo: check inputs are ours and have enough value
|
|
|
|
if (txp.inputs && !_.isEmpty(txp.inputs)) { |
|
|
|
if (!_.isNumber(txp.fee)) |
|
|
|
self._estimateFee(txp); |
|
|
|
return cb(self._checkTx(txp)); |
|
|
|
} |
|
|
|
|
|
|
@ -1725,21 +1726,28 @@ WalletService.prototype.createTxLegacy = function(opts, cb) { |
|
|
|
* @param {number} opts.outputs[].amount - Amount to transfer in satoshi. |
|
|
|
* @param {string} opts.outputs[].message - A message to attach to this output. |
|
|
|
* @param {string} opts.message - A message to attach to this transaction. |
|
|
|
* @param {Array} opts.inputs - Optional. Inputs for this TX |
|
|
|
* @param {string} opts.feePerKb - The fee per kB to use for this TX. |
|
|
|
* @param {number} opts.feePerKb - The fee per kB to use for this TX. |
|
|
|
* @param {string} opts.payProUrl - Optional. Paypro URL for peers to verify TX |
|
|
|
* @param {string} opts.excludeUnconfirmedUtxos[=false] - Optional. Do not use UTXOs of unconfirmed transactions as inputs |
|
|
|
* @param {string} opts.validateOutputs[=true] - Optional. Perform validation on outputs. |
|
|
|
* @param {Array} opts.inputs - Optional. Inputs for this TX |
|
|
|
* @param {number} opts.fee - Optional. The fee to use for this TX (used only when opts.inputs is specified). |
|
|
|
* @returns {TxProposal} Transaction proposal. |
|
|
|
*/ |
|
|
|
WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (!Utils.checkRequired(opts, ['outputs', 'feePerKb'])) |
|
|
|
if (!Utils.checkRequired(opts, ['outputs'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
|
|
|
|
if (opts.feePerKb < Defaults.MIN_FEE_PER_KB || opts.feePerKb > Defaults.MAX_FEE_PER_KB) |
|
|
|
return cb(new ClientError('Invalid fee per KB')); |
|
|
|
// feePerKb is required unless inputs & fee are specified
|
|
|
|
if (!_.isNumber(opts.feePerKb) && !(opts.inputs && _.isNumber(opts.fee))) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
|
|
|
|
if (_.isNumber(opts.feePerKb)) { |
|
|
|
if (opts.feePerKb < Defaults.MIN_FEE_PER_KB || opts.feePerKb > Defaults.MAX_FEE_PER_KB) |
|
|
|
return cb(new ClientError('Invalid fee per KB')); |
|
|
|
} |
|
|
|
|
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
@ -1760,7 +1768,6 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
var txOpts = { |
|
|
|
walletId: self.walletId, |
|
|
|
creatorId: self.copayerId, |
|
|
|
inputs: opts.inputs, |
|
|
|
outputs: opts.outputs, |
|
|
|
message: opts.message, |
|
|
|
changeAddress: wallet.createAddress(true), |
|
|
@ -1772,6 +1779,8 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
validateOutputs: !opts.validateOutputs, |
|
|
|
addressType: wallet.addressType, |
|
|
|
customData: opts.customData, |
|
|
|
inputs: opts.inputs, |
|
|
|
fee: opts.inputs && !_.isNumber(opts.feePerKb) ? opts.fee : null, |
|
|
|
}; |
|
|
|
|
|
|
|
var txp = Model.TxProposal.create(txOpts); |
|
|
|