diff options
author | coderrr <coderrr.contact@gmail.com> | 2012-08-01 12:48:42 -0400 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2012-08-23 15:55:42 -0400 |
commit | 22dfd7359863217eb8caef75084cfa8fa8e1d8fb (patch) | |
tree | 5ed884dcea256b01a5d9bd140ddac3377f6d31ed /src/rpcwallet.cpp | |
parent | 47753fa369f15274718779ffea1e2f151aa8307d (diff) |
Add address groupings RPC from the coincontrol patches.
Signed-off-by: Gregory Maxwell <greg@xiph.org>
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r-- | src/rpcwallet.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index eacb5b3b1a..519e353138 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -274,6 +274,33 @@ Value sendtoaddress(const Array& params, bool fHelp) return wtx.GetHash().GetHex(); } +Value listaddressgroupings(const Array& params, bool fHelp) +{ + if (fHelp) + throw runtime_error("listaddressgroupings"); + + Array jsonGroupings; + map<string, int64> balances = pwalletMain->GetAddressBalances(); + BOOST_FOREACH(set<string> grouping, pwalletMain->GetAddressGroupings()) + { + Array jsonGrouping; + BOOST_FOREACH(string address, grouping) + { + Array addressInfo; + addressInfo.push_back(address); + addressInfo.push_back(ValueFromAmount(balances[address])); + { + LOCK(pwalletMain->cs_wallet); + if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end()) + addressInfo.push_back(pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second); + } + jsonGrouping.push_back(addressInfo); + } + jsonGroupings.push_back(jsonGrouping); + } + return jsonGroupings; +} + Value signmessage(const Array& params, bool fHelp) { if (fHelp || params.size() != 2) |