diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index e9f4dd05..6db4b0c5 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -444,7 +444,7 @@ TXPool.prototype.getReceived = function getReceived(address) { return this._addresses[address].received.clone(); return new bn(0); } - return this._sent.clone(); + return this._received.clone(); }; TXPool.prototype.getBalance = function getBalance(address) { diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index c16ee965..8bc82c7c 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -411,6 +411,11 @@ TX.prototype.verify = function verify(index, force, flags) { if (this.isCoinbase()) return true; + if (this.getOutputValue().cmp(this.getInputValue()) > 0) { + utils.debug('TX is spending funds it does not have.'); + return false; + } + return this.inputs.every(function(input, i) { if (index != null && i !== index) return true;