updated the code to 1-liner statements
using typeof instead of 2 if checks.
This commit is contained in:
parent
449e947966
commit
b4d607bfef
@ -109,10 +109,8 @@ function TransactionBuilder(opts) {
|
|||||||
this.lockTime = opts.lockTime || 0;
|
this.lockTime = opts.lockTime || 0;
|
||||||
this.spendUnconfirmed = opts.spendUnconfirmed || false;
|
this.spendUnconfirmed = opts.spendUnconfirmed || false;
|
||||||
|
|
||||||
if (opts.fee || opts.feeSat) {
|
this.givenFeeSat = typeof(opts.fee) !== 'undefined' ? opts.fee * util.COIN : opts.feeSat;
|
||||||
this.givenFeeSat = opts.fee ? opts.fee * util.COIN : opts.feeSat;
|
|
||||||
}
|
|
||||||
if (opts.fee == 0 || opts.feeSat == 0) this.givenFeeSat = 0;
|
|
||||||
this.remainderOut = opts.remainderOut;
|
this.remainderOut = opts.remainderOut;
|
||||||
this.signhash = opts.signhash || Transaction.SIGHASH_ALL;
|
this.signhash = opts.signhash || Transaction.SIGHASH_ALL;
|
||||||
|
|
||||||
@ -359,8 +357,7 @@ TransactionBuilder.prototype._setFeeAndRemainder = function(txobj) {
|
|||||||
/* based on https://en.bitcoin.it/wiki/Transaction_fees */
|
/* based on https://en.bitcoin.it/wiki/Transaction_fees */
|
||||||
maxSizeK = parseInt(size / 1000) + 1;
|
maxSizeK = parseInt(size / 1000) + 1;
|
||||||
|
|
||||||
var feeSat = this.givenFeeSat || this.givenFeeSat == 0 ?
|
var feeSat = typeof(this.givenFeeSat) !== 'undefined' ? this.givenFeeSat : maxSizeK * FEE_PER_1000B_SAT;
|
||||||
this.givenFeeSat : maxSizeK * FEE_PER_1000B_SAT;
|
|
||||||
|
|
||||||
var neededAmountSat = this.valueOutSat.add(feeSat);
|
var neededAmountSat = this.valueOutSat.add(feeSat);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user