coinview: remove view.spend.
This commit is contained in:
parent
5a116923c5
commit
f8deb0cdfd
@ -173,7 +173,20 @@ CoinView.prototype.addOutput = function addOutput(prevout, output) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CoinView.prototype.spendOutput = function spendOutput(prevout) {
|
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);
|
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.
|
* Get a single entry by input.
|
||||||
* @param {Input} input
|
* @param {Input} input
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user