diff --git a/lib/http/rpc.js b/lib/http/rpc.js index 86d74864..5f751ca9 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -1176,7 +1176,7 @@ RPC.prototype.gettxout = co(function* gettxout(args) { return null; return { - bestblock: utils.revHex(this.chain.tip.hash), + bestblock: this.chain.tip.rhash, confirmations: coin.getConfirmations(this.chain.height), value: +utils.btc(coin.value), scriptPubKey: this._scriptToJSON(coin.script, true), @@ -1187,7 +1187,7 @@ RPC.prototype.gettxout = co(function* gettxout(args) { RPC.prototype.gettxoutproof = co(function* gettxoutproof(args) { var uniq = {}; - var i, txids, block, hash, last, tx, coins; + var i, txids, block, hash, txid, tx, coins; if (args.help || (args.length !== 1 && args.length !== 2)) throw new RPCError('gettxoutproof ["txid",...] ( blockhash )'); @@ -1199,40 +1199,39 @@ RPC.prototype.gettxoutproof = co(function* gettxoutproof(args) { throw new RPCError('Cannot get coins when pruned.'); txids = toArray(args[0]); - block = args[1]; + hash = args[1]; if (!txids || txids.length === 0) throw new RPCError('Invalid parameter.'); - if (block) { - block = toHash(block); - if (!block) + if (hash) { + hash = toHash(hash); + if (!hash) throw new RPCError('Invalid parameter.'); } for (i = 0; i < txids.length; i++) { - hash = toHash(txids[i]); + txid = toHash(txids[i]); - if (!hash) + if (!txid) throw new RPCError('Invalid parameter.'); - if (uniq[hash]) + if (uniq[txid]) throw new RPCError('Duplicate txid.'); - uniq[hash] = true; - txids[i] = hash; - last = hash; + uniq[txid] = true; + txids[i] = txid; } if (hash) { block = yield this.chain.db.getBlock(hash); } else if (this.chain.options.indexTX) { - tx = yield this.chain.db.getTX(last); + tx = yield this.chain.db.getTX(txid); if (!tx) return; block = yield this.chain.db.getBlock(tx.block); } else { - coins = yield this.chain.db.getCoins(last); + coins = yield this.chain.db.getCoins(txid); if (!coins) return; block = yield this.chain.db.getBlock(coins.height);