From d4f11676c708ccd4c8e6a7cedf5f8e499357d483 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 9 May 2014 15:00:50 +0400 Subject: [PATCH] tx: encode as hex --- lib/bcoin/tx-pool.js | 2 ++ lib/bcoin/tx.js | 4 ++-- lib/bcoin/wallet.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index 1bcd76da..493ee3b8 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -126,6 +126,8 @@ TXPool.prototype._storeTX = function _storeTX(hash, tx) { TXPool.prototype.unspent = function unspent() { return Object.keys(this._unspent).map(function(key) { return this._unspent[key]; + }, this).filter(function(item) { + return this._wallet.own(item.tx, item.index); }, this); }; diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 2e1808ae..a28faa68 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -184,12 +184,12 @@ TX.prototype.toJSON = function toJSON() { // Compact representation var ts = new Array(4); bcoin.utils.writeU32(ts, this.ts, 0); - return utils.toBase58(this.render().concat(ts)); + return utils.toHex(this.render().concat(ts)); }; TX.fromJSON = function fromJSON(json) { // Compact representation - var data = utils.fromBase58(json); + var data = utils.toArray(json, 'hex'); var tx = data.slice(0, -4); var ts = bcoin.utils.readU32(data, data.length - 4); diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 5c1d389d..acb6c078 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -142,7 +142,7 @@ Wallet.prototype.own = function own(tx, index) { var hash = this.getHash(); var key = this.getPublicKey(); var outputs = tx.outputs.filter(function(output, i) { - if (index && index !== i) + if (index !== undefined && index !== i) return false; var s = output.script;