From 8d0f432c7af28cfd9a8ab69e66680a5c5f7990a8 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 28 Feb 2016 21:56:13 -0800 Subject: [PATCH] received and tx.verify. --- lib/bcoin/tx-pool.js | 2 +- lib/bcoin/tx.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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;