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