Skip to content

Commit 5ea026b

Browse files
committed
getaddressbalance alos retunrs individual balances; version made 2.2.1
1 parent 660e4ea commit 5ea026b

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
22
AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
4-
define(_CLIENT_VERSION_MINOR, 3)
4+
define(_CLIENT_VERSION_MINOR, 2)
55
define(_CLIENT_VERSION_REVISION, 1)
6-
define(_CLIENT_VERSION_BUILD, 0)
6+
define(_CLIENT_VERSION_BUILD, 50)
77
define(_ZC_BUILD_VAL,
88
m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD),
99
m4_eval(_CLIENT_VERSION_BUILD < 50), 1,

src/rpc/misc.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,15 @@ Returns the balance for addresses.
810810
811811
Result:
812812
{
813-
"balance" (string) The current balance in )" + MINOR_CURRENCY_UNIT + R"(
814-
"received" (string) The total number of )" + MINOR_CURRENCY_UNIT + R"( received (including change)
813+
"addressess":
814+
[
815+
{
816+
"address" (string) The base58check encoded address
817+
"balance" (string) (string) The current balance of the address in )" + MINOR_CURRENCY_UNIT + R"(
818+
}, ...
819+
],
820+
"balance" (string) The total current balance in )" + MINOR_CURRENCY_UNIT + R"(on all addresses in the request
821+
"received" (string) The total number of )" + MINOR_CURRENCY_UNIT + R"( received (including change) by all addresses in the request
815822
}
816823
817824
Examples:
@@ -827,6 +834,8 @@ Returns the balance for addresses.
827834
// to zero (full range, entire blockchain)
828835
getAddressesInHeightRange(params, make_tuple(0, 0), vAddresses, vAddressIndex);
829836

837+
UniValue addresses(UniValue::VARR);
838+
addresses.reserve(vAddressIndex.size());
830839
CAmount balance = 0;
831840
CAmount received = 0;
832841
for (const auto& it : vAddressIndex)
@@ -835,8 +844,21 @@ Returns the balance for addresses.
835844
received += it.second;
836845

837846
balance += it.second;
847+
848+
string address;
849+
auto scriptTypeOpt = toScriptType(it.first.type);
850+
if (!scriptTypeOpt)
851+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown script type");
852+
if (!getAddressFromIndex(scriptTypeOpt.value(), it.first.hashBytes, address))
853+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
854+
855+
UniValue addr_obj(UniValue::VOBJ);
856+
addr_obj.pushKV("address", address);
857+
addr_obj.pushKV("balance", it.first.index);
858+
addresses.push_back(addr_obj);
838859
}
839860
UniValue result(UniValue::VOBJ);
861+
result.pushKV("deltas", addresses);
840862
result.pushKV("balance", balance);
841863
result.pushKV("received", received);
842864
return result;

0 commit comments

Comments
 (0)