diff --git a/lib/bcoin/coin.js b/lib/bcoin/coin.js index 063586ec..420a4c59 100644 --- a/lib/bcoin/coin.js +++ b/lib/bcoin/coin.js @@ -83,8 +83,10 @@ utils.inherits(Coin, bcoin.output); */ Coin.prototype.getConfirmations = function getConfirmations(height) { - if (height == null) - height = network.height; + assert(typeof height === 'number'); + + if (height === -1) + return 0; if (this.height === -1) return 0; @@ -131,7 +133,7 @@ Coin.prototype.inspect = function inspect() { coinbase: this.coinbase, hash: this.hash ? utils.revHex(this.hash) : null, index: this.index, - age: this.getAge(), + age: this.getAge(network.height), address: this.getAddress() }; }; diff --git a/lib/bcoin/mtx.js b/lib/bcoin/mtx.js index 0d1d4d65..a61f113e 100644 --- a/lib/bcoin/mtx.js +++ b/lib/bcoin/mtx.js @@ -1297,8 +1297,7 @@ MTX.prototype.sortMembers = function sortMembers() { */ MTX.prototype.avoidFeeSniping = function avoidFeeSniping(height) { - if (height == null) - height = network.height; + assert(typeof height === 'number'); if (height === -1) height = 0; diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index c8ae440d..fe25f84f 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -1362,11 +1362,10 @@ TX.prototype.getPriority = function getPriority(height, size) { if (this.isCoinbase()) return new bn(0); - if (height == null) { - height = this.height; - if (height === -1) - height = network.height + 1; - } + assert(typeof height === 'number'); + + if (height === -1) + height = 0; if (size == null) size = this.maxSize(); @@ -1411,11 +1410,7 @@ TX.prototype.getPriority = function getPriority(height, size) { TX.prototype.isFree = function isFree(height, size) { var priority; - if (height == null) { - height = this.height; - if (height === -1) - height = network.height + 1; - } + assert(typeof height === 'number'); priority = this.getPriority(height, size).priority; @@ -1483,8 +1478,10 @@ TX.prototype.getMaxFee = function getMaxFee(size, rate) { */ TX.prototype.getConfirmations = function getConfirmations(height) { - if (height == null) - height = network.height; + assert(typeof height === 'number'); + + if (height === -1) + return 0; if (this.height === -1) return 0; @@ -1635,8 +1632,8 @@ TX.prototype.inspect = function inspect() { value: utils.btc(this.getOutputValue()), fee: utils.btc(this.getFee()), minFee: utils.btc(this.getMinFee()), - confirmations: this.getConfirmations(), - priority: this.getPriority().priority.toString(10), + confirmations: this.getConfirmations(network.height), + priority: this.getPriority(network.height).priority.toString(10), date: utils.date(this.ts || this.ps), block: this.block ? utils.revHex(this.block) : null, ts: this.ts, diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 2b0d2cdf..4f10df3c 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -815,7 +815,7 @@ Wallet.prototype.createTX = function createTX(options, outputs, callback) { // if (options.locktime != null) // tx.setLocktime(options.locktime); // else - // tx.avoidFeeSniping(); + // tx.avoidFeeSniping(network.height); // Sign the transaction if (!self.sign(tx))