rpc: improve getrawtransaction.
This commit is contained in:
parent
9f09de4867
commit
c365ecb3ea
@ -2187,7 +2187,7 @@ RPC.prototype.decodescript = co(function* decodescript(args, help) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
RPC.prototype.getrawtransaction = co(function* getrawtransaction(args, help) {
|
RPC.prototype.getrawtransaction = co(function* getrawtransaction(args, help) {
|
||||||
var hash, verbose, json, tx;
|
var hash, verbose, json, meta, tx, entry;
|
||||||
|
|
||||||
if (help || args.length < 1 || args.length > 2)
|
if (help || args.length < 1 || args.length > 2)
|
||||||
throw new RPCError('getrawtransaction "txid" ( verbose )');
|
throw new RPCError('getrawtransaction "txid" ( verbose )');
|
||||||
@ -2202,15 +2202,21 @@ RPC.prototype.getrawtransaction = co(function* getrawtransaction(args, help) {
|
|||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
verbose = toBool(args[1]);
|
verbose = toBool(args[1]);
|
||||||
|
|
||||||
tx = yield this.node.getTX(hash);
|
meta = yield this.node.getMeta(hash);
|
||||||
|
|
||||||
if (!tx)
|
if (!meta)
|
||||||
throw new RPCError('Transaction not found.');
|
throw new RPCError('Transaction not found.');
|
||||||
|
|
||||||
|
tx = meta.tx;
|
||||||
|
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
return tx.toRaw().toString('hex');
|
return tx.toRaw().toString('hex');
|
||||||
|
|
||||||
json = this._txToJSON(tx);
|
if (meta.block)
|
||||||
|
entry = yield this.chain.db.getEntry(meta.block);
|
||||||
|
|
||||||
|
json = this._txToJSON(tx, entry);
|
||||||
|
json.time = meta.ps;
|
||||||
json.hex = tx.toRaw().toString('hex');
|
json.hex = tx.toRaw().toString('hex');
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user