diff --git a/lib/bcoin/mtx.js b/lib/bcoin/mtx.js index 2015be97..c7eef3e6 100644 --- a/lib/bcoin/mtx.js +++ b/lib/bcoin/mtx.js @@ -127,10 +127,12 @@ MTX.prototype.addInput = function addInput(options, index) { assert(this.ts === 0, 'Cannot modify a confirmed tx.'); - if (options instanceof MTX) + if (options instanceof bcoin.tx) options = bcoin.coin(options, index); if (options instanceof bcoin.coin) { + assert(typeof options.hash === 'string'); + assert(typeof options.index === 'number'); options = { prevout: { hash: options.hash, index: options.index }, coin: options @@ -901,7 +903,7 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) { var i, index; for (i = lastAdded; i < coins.length; i++) { - // Add new inputs until MTX will have enough + // Add new inputs until TX will have enough // funds to cover both minimum post cost // and fee. tx.addInput(coins[i]); @@ -929,7 +931,7 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) { addCoins(); // Add dummy output (for `change`) to - // calculate maximum MTX size. + // calculate maximum TX size. tx.addOutput({ address: options.changeAddress, value: new bn(0) diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 3e5bedb7..1b1ae060 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -601,9 +601,12 @@ TX.prototype.fillCoins = function fillCoins(coins) { coins = coins.reduce(function(out, coin) { if (coin instanceof TX) { out[coin.hash('hex')] = coin; - } else { + } else if (coin instanceof bcoin.coin) { assert(typeof coin.hash === 'string'); + assert(typeof coin.index === 'number'); out[coin.hash + '/' + coin.index] = coin; + } else { + assert(false, 'Non-coin object passed to fillCoins.'); } return out; }, {});