@@ -810,8 +810,15 @@ Returns the balance for addresses.
810810
811811Result:
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
817824Examples:
@@ -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