diff --git a/lib/bcoin/http/rpc.js b/lib/bcoin/http/rpc.js index a9c4e646..08d43c96 100644 --- a/lib/bcoin/http/rpc.js +++ b/lib/bcoin/http/rpc.js @@ -2606,7 +2606,7 @@ RPC.prototype.listreceivedbyaddress = function listreceivedbyaddress(args, callb RPC.prototype.listsinceblock = function listsinceblock(args, callback) { var self = this; - var block, conf, out; + var block, conf, out, highest; if (args.help) { return callback(new Error('listsinceblock' @@ -2620,6 +2620,8 @@ RPC.prototype.listsinceblock = function listsinceblock(args, callback) { block = utils.revHex(block); } + conf = 0; + if (args.length > 1) { conf = Number(args[1]); if (!utils.isNumber(conf) || conf < 0) @@ -2642,6 +2644,13 @@ RPC.prototype.listsinceblock = function listsinceblock(args, callback) { utils.forEachSerial(txs, function(tx, next, i) { if (tx.height < height) return next(); + + if (tx.getConfirmations() < conf) + return next(); + + if (!highest || tx.height > highest) + highest = tx; + self._toListTX(tx, function(err, json) { if (err) return next(err); @@ -2651,7 +2660,13 @@ RPC.prototype.listsinceblock = function listsinceblock(args, callback) { }, function(err) { if (err) return callback(err); - callback(null, out); + + callback(null, { + transactions: out, + lastblock: highest && highest.block + ? utils.revHex(highest.block) + : constants.NULL_HASH + }); }); }); });