diff --git a/lib/services/dashd.js b/lib/services/dashd.js index 4c3f90270..9db927a92 100644 --- a/lib/services/dashd.js +++ b/lib/services/dashd.js @@ -2075,25 +2075,31 @@ Dash.prototype.estimateFee = function(blocks, callback) { * Will add a transaction to the mempool and relay to connected peers * @param {String|Transaction} transaction - The hex string of the transaction * @param {Object=} options - * @param {Boolean=} options.allowAbsurdFees - Enable large fees + * @param {Boolean=} options.maxFeeRate - Cap large fees (0 for unlimited) * @param {Function} callback */ Dash.prototype.sendTransaction = function(tx, options, callback) { var self = this; - var allowAbsurdFees = false; + var maxFeeRate = 0.00001000; // duff/kB (typically less than 1000) var isInstantSend = false; if (_.isFunction(options) && _.isUndefined(callback)) { callback = options; } else if (_.isObject(options)) { + if(options.hasOwnProperty('maxFeeRate')){ + maxFeeRate = options.maxFeeRate; + } if(options.hasOwnProperty('allowAbsurdFees')){ - allowAbsurdFees = options.allowAbsurdFees; + console.warn(`the boolean 'allowAbsurdFees' has been replaced by the int 'maxFeeRate'`); + if(false === options.allowAbsurdFees) { + maxFeeRate = 0; // unlimited + } } if(options.hasOwnProperty('isInstantSend')){ - isInstantSend = options.isInstantSend; + isInstantSend = options.isInstantSend; } } - this.client.sendRawTransaction(tx, allowAbsurdFees, isInstantSend, function(err, response) { + this.client.sendRawTransaction(tx, maxFeeRate, isInstantSend, function(err, response) { if (err) { return callback(self._wrapRPCError(err)); } diff --git a/test/services/dashd.unit.js b/test/services/dashd.unit.js index dc2d4225f..4bc07bf18 100644 --- a/test/services/dashd.unit.js +++ b/test/services/dashd.unit.js @@ -4580,7 +4580,7 @@ describe('Dash Service', function() { sendRawTransaction: sendRawTransaction } }); - dashd.sendTransaction(txhex, {allowAbsurdFees: true}, function(err, hash) { + dashd.sendTransaction(txhex, {maxFeeRate: 0}, function(err, hash) { if (err) { return done(err); }