From e8cb71447c60878487604a90a19e34f56fddbbff Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 11 Aug 2016 01:42:13 -0700 Subject: [PATCH] txdb: fix rpc categorization. --- lib/bcoin/txdb.js | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index a0b199c3..93c04afb 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -2106,9 +2106,7 @@ Details.prototype.isReceive = function isReceive() { for (i = 0; i < this.inputs.length; i++) { input = this.inputs[i]; - if (!input.path) - continue; - if (input.path.id === this.id) + if (input.path) return false; } @@ -2117,19 +2115,18 @@ Details.prototype.isReceive = function isReceive() { Details.prototype.getValue = function getValue() { var value = 0; - var i, vector, member; - - if (this.isReceive()) - vector = this.outputs; - else - vector = this.inputs; + var receive = this.isReceive(); + var i, member; for (i = 0; i < this.outputs.length; i++) { member = this.outputs[i]; - if (!member.path) - continue; - if (member.path.id !== this.id) - continue; + if (receive) { + if (!member.path) + continue; + } else { + if (member.path) + continue; + } value += member.value; } @@ -2137,19 +2134,18 @@ Details.prototype.getValue = function getValue() { }; Details.prototype.getMember = function getMember() { - var i, vector, member; - - if (this.isReceive()) - vector = this.outputs; - else - vector = this.inputs; + var receive = this.isReceive(); + var i, member; for (i = 0; i < this.outputs.length; i++) { member = this.outputs[i]; - if (!member.path) - continue; - if (member.path.id !== this.id) - continue; + if (receive) { + if (!member.path) + continue; + } else { + if (member.path) + continue; + } return member; }