rpc: mempool ancestors and descendants.
This commit is contained in:
parent
9fbd2710ab
commit
c2bcd8fd74
@ -1069,7 +1069,7 @@ RPC.prototype.getmempoolinfo = function getmempoolinfo(args, callback) {
|
||||
};
|
||||
|
||||
RPC.prototype.getmempoolancestors = function getmempoolancestors(args, callback) {
|
||||
var hash, entry;
|
||||
var i, hash, verbose, entry, entries;
|
||||
|
||||
if (args.help || args.length < 1 || args.length > 2)
|
||||
return callback(new RPCError('getmempoolancestors txid (verbose)'));
|
||||
@ -1079,16 +1079,29 @@ RPC.prototype.getmempoolancestors = function getmempoolancestors(args, callback)
|
||||
if (!hash)
|
||||
return callback(new RPCError('Invalid parameter.'));
|
||||
|
||||
if (args.length > 1)
|
||||
verbose = toBool(args[1], false);
|
||||
|
||||
entry = this.mempool.getEntry(hash);
|
||||
|
||||
if (!entry)
|
||||
return callback(new RPCError('Transaction not in mempool.'));
|
||||
|
||||
callback(new Error('Not implemented.'));
|
||||
entries = this.mempool.getAncestors(entry.tx);
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < entries.length; i++)
|
||||
entries[i] = this._entryToJSON(entries[i]);
|
||||
} else {
|
||||
for (i = 0; i < entries.length; i++)
|
||||
entries[i] = entries[i].tx.rhash;
|
||||
}
|
||||
|
||||
callback(null, entries);
|
||||
};
|
||||
|
||||
RPC.prototype.getmempooldescendants = function getmempooldescendants(args, callback) {
|
||||
var hash, entry;
|
||||
var i, hash, verbose, entry, entries;
|
||||
|
||||
if (args.help || args.length < 1 || args.length > 2)
|
||||
return callback(new RPCError('getmempooldescendants txid (verbose)'));
|
||||
@ -1098,12 +1111,25 @@ RPC.prototype.getmempooldescendants = function getmempooldescendants(args, callb
|
||||
if (!hash)
|
||||
return callback(new RPCError('Invalid parameter.'));
|
||||
|
||||
if (args.length > 1)
|
||||
verbose = toBool(args[1], false);
|
||||
|
||||
entry = this.mempool.getEntry(hash);
|
||||
|
||||
if (!entry)
|
||||
return callback(new RPCError('Transaction not in mempool.'));
|
||||
|
||||
callback(new Error('Not implemented.'));
|
||||
entries = this.mempool.getDescendants(entry.tx);
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < entries.length; i++)
|
||||
entries[i] = this._entryToJSON(entries[i]);
|
||||
} else {
|
||||
for (i = 0; i < entries.length; i++)
|
||||
entries[i] = entries[i].tx.rhash;
|
||||
}
|
||||
|
||||
callback(null, entries);
|
||||
};
|
||||
|
||||
RPC.prototype.getmempoolentry = function getmempoolentry(args, callback) {
|
||||
@ -2608,13 +2634,13 @@ RPC.prototype.dumpwallet = function dumpwallet(args, callback) {
|
||||
utils.forEachSerial(hashes, function(hash, next) {
|
||||
self.wallet.getKeyRing(hash, function(err, ring) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
return next(err);
|
||||
|
||||
if (!ring)
|
||||
return next();
|
||||
|
||||
if (!self.wallet.master.key)
|
||||
return callback(new RPCError('Wallet is locked.'));
|
||||
return next(new RPCError('Wallet is locked.'));
|
||||
|
||||
address = ring.getAddress('base58');
|
||||
fmt = '%s %s label= addr=%s';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user