diff --git a/lib/coins/coinview.js b/lib/coins/coinview.js index e8dec2d4..ae6a428b 100644 --- a/lib/coins/coinview.js +++ b/lib/coins/coinview.js @@ -173,7 +173,20 @@ CoinView.prototype.addOutput = function addOutput(prevout, output) { */ CoinView.prototype.spendOutput = function spendOutput(prevout) { - return this.spend(prevout.hash, prevout.index); + let coins = this.get(prevout.hash); + let coin; + + if (!coins) + return false; + + coin = coins.spend(prevout.index); + + if (!coin) + return false; + + this.undo.push(coin); + + return true; }; /** @@ -191,29 +204,6 @@ CoinView.prototype.removeOutput = function removeOutput(prevout) { return coins.remove(prevout.index); }; -/** - * Spend a coin from coins object. - * @param {Hash} hash - * @param {Number} index - * @returns {Boolean} - */ - -CoinView.prototype.spend = function spend(hash, index) { - let coins = this.get(hash); - - if (!coins) - return false; - - let coin = coins.spend(index); - - if (!coin) - return false; - - this.undo.push(coin); - - return true; -}; - /** * Get a single entry by input. * @param {Input} input