diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index 392260c9..4031d043 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -230,6 +230,12 @@ HTTPServer.prototype._init = function _init() { assert(utils.isUInt32(options.age), 'Age must be a number.'); } + if (params.fee) + options.fee = utils.satoshi(params.fee); + + if (params.maxFee) + options.maxFee = utils.satoshi(params.maxFee); + if (params.rate) options.rate = utils.satoshi(params.rate); diff --git a/lib/bcoin/mtx.js b/lib/bcoin/mtx.js index 73113b2e..434cbec6 100644 --- a/lib/bcoin/mtx.js +++ b/lib/bcoin/mtx.js @@ -1250,7 +1250,7 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) { // bytes (10000 satoshi for every 1024 bytes). do { // Calculate max possible size after signing. - size = tx.maxSize(options.key, options.script); + size = tx.maxSize(options); if (tryFree && options.height >= 0) { // Note that this will only work @@ -1272,6 +1272,13 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) { if (fee > constants.tx.MAX_FEE) fee = constants.tx.MAX_FEE; + if (options.maxFee && fee > options.maxFee) { + throw new FundingError( + 'Fee is too high.', + tx.getInputValue(), + total()); + } + // Failed to get enough funds, add more coins. if (!isFull()) addCoins();