|
|
@ -693,8 +693,6 @@ WalletService.prototype.getBalance = function(opts, cb) { |
|
|
|
WalletService.prototype._selectTxInputs = function(txp, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
Bitcore.Transaction.FEE_SECURITY_MARGIN = 1; |
|
|
|
|
|
|
|
self._getUtxos(function(err, utxos) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
@ -730,6 +728,7 @@ WalletService.prototype._selectTxInputs = function(txp, cb) { |
|
|
|
if (!bitcoreError) { |
|
|
|
txp.inputPaths = _.pluck(txp.inputs, 'path'); |
|
|
|
txp.fee = bitcoreTx.getFee(); |
|
|
|
$.checkState(txp.fee < 1e8, 'Fees are too high!'); |
|
|
|
return cb(); |
|
|
|
} |
|
|
|
} catch (ex) { |
|
|
@ -787,7 +786,8 @@ WalletService.prototype._canCreateTx = function(copayerId, cb) { |
|
|
|
* @param {number} opts.amount - Amount to transfer in satoshi. |
|
|
|
* @param {string} opts.message - A message to attach to this transaction. |
|
|
|
* @param {string} opts.proposalSignature - S(toAddress|amount|message|payProUrl). Used by other copayers to verify the proposal. |
|
|
|
* @param {string} opts.payProUrl - Options: Paypro URL for peers to verify TX |
|
|
|
* @param {string} opts.feePerKb - Optional: Use an alternative fee per KB for this TX |
|
|
|
* @param {string} opts.payProUrl - Optional: Paypro URL for peers to verify TX |
|
|
|
* @returns {TxProposal} Transaction proposal. |
|
|
|
*/ |
|
|
|
WalletService.prototype.createTx = function(opts, cb) { |
|
|
@ -796,6 +796,10 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
if (!Utils.checkRequired(opts, ['toAddress', 'amount', 'proposalSignature'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
|
|
|
|
var feePerKb = opts.feePerKb || 10000; |
|
|
|
if (!_.contains([1000, 5000, 10000], feePerKb)) |
|
|
|
return cb(new ClientError('Invalid fee per KB value')); |
|
|
|
|
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
@ -827,7 +831,6 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
if (opts.amount < Bitcore.Transaction.DUST_AMOUNT) |
|
|
|
return cb(new ClientError('DUSTAMOUNT', 'Amount below dust threshold')); |
|
|
|
|
|
|
|
|
|
|
|
var changeAddress = wallet.createAddress(true); |
|
|
|
|
|
|
|
var txp = Model.TxProposal.create({ |
|
|
@ -837,6 +840,7 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
amount: opts.amount, |
|
|
|
message: opts.message, |
|
|
|
proposalSignature: opts.proposalSignature, |
|
|
|
feePerKb: feePerKb, |
|
|
|
payProUrl: opts.payProUrl, |
|
|
|
changeAddress: changeAddress, |
|
|
|
requiredSignatures: wallet.m, |
|
|
|