rpc: add listsinceblock.
This commit is contained in:
parent
42e03c227a
commit
d32df008df
@ -9,6 +9,7 @@
|
||||
var bcoin = require('../env');
|
||||
var utils = require('../utils');
|
||||
var IP = require('../ip');
|
||||
var assert = utils.assert;
|
||||
var constants = bcoin.protocol.constants;
|
||||
|
||||
function RPC(node) {
|
||||
@ -2407,7 +2408,6 @@ RPC.prototype.getreceivedbyaddress = function getreceivedbyaddress(args, callbac
|
||||
};
|
||||
|
||||
RPC.prototype._toWalletTX = function _toWalletTX(tx, callback) {
|
||||
var self = this;
|
||||
var receive, member, json;
|
||||
|
||||
this.walletdb.tx.getMap(tx, function(err, map) {
|
||||
@ -2448,6 +2448,7 @@ RPC.prototype._toWalletTX = function _toWalletTX(tx, callback) {
|
||||
};
|
||||
|
||||
RPC.prototype.gettransaction = function gettransaction(args, callback) {
|
||||
var self = this;
|
||||
var hash;
|
||||
|
||||
if (args.help || args.length < 1 || args.length > 2)
|
||||
@ -2604,11 +2605,59 @@ RPC.prototype.listreceivedbyaddress = function listreceivedbyaddress(args, callb
|
||||
};
|
||||
|
||||
RPC.prototype.listsinceblock = function listsinceblock(args, callback) {
|
||||
callback(new Error('Not implemented.'));
|
||||
var self = this;
|
||||
var block, conf, out;
|
||||
|
||||
if (args.help) {
|
||||
return callback(new Error('listsinceblock'
|
||||
+ ' ( "blockhash" target-confirmations includeWatchonly)'));
|
||||
}
|
||||
|
||||
if (args.length > 0) {
|
||||
block = String(args[0]);
|
||||
if (!utils.isHex(block) || block.length !== 64)
|
||||
return callback(new Error('Invalid parameter.'));
|
||||
block = utils.revHex(block);
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
conf = Number(args[1]);
|
||||
if (!utils.isNumber(conf) || conf < 0)
|
||||
return callback(new Error('Invalid parameter.'));
|
||||
}
|
||||
|
||||
out = [];
|
||||
|
||||
this.chain.db.getHeight(block, function(err, height) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (height === -1)
|
||||
height = self.chain.height;
|
||||
|
||||
self.wallet.getHistory(function(err, txs) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
utils.forEachSerial(txs, function(tx, next, i) {
|
||||
if (tx.height < height)
|
||||
return next();
|
||||
self._toListTX(tx, function(err, json) {
|
||||
if (err)
|
||||
return next(err);
|
||||
out.push(json);
|
||||
next();
|
||||
});
|
||||
}, function(err) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
callback(null, out);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
RPC.prototype._toListTX = function _toListTX(tx, callback) {
|
||||
var self = this;
|
||||
var receive, member, json;
|
||||
|
||||
this.walletdb.tx.getMap(tx, function(err, map) {
|
||||
@ -2645,6 +2694,7 @@ RPC.prototype._toListTX = function _toListTX(tx, callback) {
|
||||
};
|
||||
|
||||
RPC.prototype.listtransactions = function listtransactions(args, callback) {
|
||||
var self = this;
|
||||
var account, count;
|
||||
|
||||
if (args.help || args.length > 4) {
|
||||
@ -2700,8 +2750,6 @@ RPC.prototype.move = function move(args, callback) {
|
||||
};
|
||||
|
||||
RPC.prototype._send = function _send(account, address, amount, subtractFee, callback) {
|
||||
var self = this;
|
||||
|
||||
var options = {
|
||||
account: account,
|
||||
subtractFee: subtractFee,
|
||||
|
||||
@ -1037,7 +1037,6 @@ Wallet.prototype.getOutputPaths = function getOutputPaths(tx, callback) {
|
||||
|
||||
Wallet.prototype.syncOutputDepth = function syncOutputDepth(map, callback) {
|
||||
var self = this;
|
||||
var accounts = {};
|
||||
var change = [];
|
||||
var receive = [];
|
||||
var i, path, unlock;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user