tx: encode as hex

This commit is contained in:
Fedor Indutny 2014-05-09 15:00:50 +04:00
parent 90ea2e24d1
commit d4f11676c7
3 changed files with 5 additions and 3 deletions

View File

@ -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);
};

View File

@ -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);

View File

@ -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;