rpc: getreceivedbyaccount.
This commit is contained in:
parent
780601b3b7
commit
e872f5985c
@ -2814,6 +2814,7 @@ RPC.prototype.getreceivedbyaccount = function getreceivedbyaccount(args, callbac
|
||||
var self = this;
|
||||
var minconf = 0;
|
||||
var total = 0;
|
||||
var filter = {};
|
||||
var i, j, account, tx, output;
|
||||
|
||||
if (args.help || args.length < 1 || args.length > 2)
|
||||
@ -2827,25 +2828,34 @@ RPC.prototype.getreceivedbyaccount = function getreceivedbyaccount(args, callbac
|
||||
if (args.length === 2)
|
||||
minconf = Number(args[1]);
|
||||
|
||||
this.wallet.getHistory(account, function(err, txs) {
|
||||
this.wallet.getAddresses(function(err, hashes) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
for (i = 0; i < txs.length; i++) {
|
||||
tx = txs[i];
|
||||
if (minconf) {
|
||||
if (tx.height === -1)
|
||||
continue;
|
||||
if (!(self.chain.height - tx.height + 1 >= minconf))
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < tx.outputs.length; j++) {
|
||||
output = tx.outputs[j];
|
||||
total += output.value;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < hashes.length; i++)
|
||||
filter[hashes[i]] = true;
|
||||
|
||||
callback(null, +utils.btc(total));
|
||||
self.wallet.getHistory(account, function(err, txs) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
for (i = 0; i < txs.length; i++) {
|
||||
tx = txs[i];
|
||||
if (minconf) {
|
||||
if (tx.height === -1)
|
||||
continue;
|
||||
if (!(self.chain.height - tx.height + 1 >= minconf))
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < tx.outputs.length; j++) {
|
||||
output = tx.outputs[j];
|
||||
if (filter[output.getHash('hex')])
|
||||
total += output.value;
|
||||
}
|
||||
}
|
||||
|
||||
callback(null, +utils.btc(total));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -3105,6 +3115,10 @@ RPC.prototype.listreceivedbyaccount = function listreceivedbyaccount(args, callb
|
||||
};
|
||||
|
||||
RPC.prototype.listreceivedbyaddress = function listreceivedbyaddress(args, callback) {
|
||||
if (args.help || args.length > 3) {
|
||||
return callback(new RPCError('listreceivedbyaddress'
|
||||
+ ' ( minconf includeempty includeWatchonly)'));
|
||||
}
|
||||
callback(new Error('Not implemented.'));
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user