mtx: maxFee option.

This commit is contained in:
Christopher Jeffrey 2016-08-21 12:17:24 -07:00
parent 8ed5016108
commit e5d23945b1
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 14 additions and 1 deletions

View File

@ -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);

View File

@ -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();