coinview: remove view.spend.

This commit is contained in:
Christopher Jeffrey 2017-07-03 16:33:37 -07:00
parent 5a116923c5
commit f8deb0cdfd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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