Skip to content

Commit f5be950

Browse files
committed
Added omni_getwalletaddressbalances function
1 parent da27281 commit f5be950

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/bitcoinapi/bitcoinapi.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,39 @@ std::string BitcoinAPI::omni_funded_sendall(const std::string& fromaddress, cons
14441444
return result.asString();
14451445
}
14461446

1447+
std::vector<omni_address_balance_t> BitcoinAPI::omni_getwalletaddressbalances(bool includewatchonly)
1448+
{
1449+
string command = "omni_getwalletaddressbalances";
1450+
Value params, result;
1451+
vector<omni_address_balance_t> ret;
1452+
1453+
params.append(includewatchonly);
1454+
result = sendcommand(command, params);
1455+
1456+
for(ValueIterator it = result.begin(); it != result.end(); it++){
1457+
omni_address_balance_t tmp;
1458+
Value val = (*it);
1459+
tmp.address = val["address"].asString();
1460+
1461+
for(ValueIterator it2 = val["balances"].begin(); it2 != val["balances"].end(); it2++){
1462+
omni_detailed_balance_t tmp2;
1463+
Value val = (*it2);
1464+
1465+
tmp2.balance = stod(val["balance"].asString());
1466+
tmp2.reserved = stod(val["reserved"].asString());
1467+
tmp2.frozen = stod(val["frozen"].asString());
1468+
tmp2.name = val["name"].asString();
1469+
tmp2.propertyid = val["propertyid"].asInt();
1470+
1471+
tmp.balances.push_back(tmp2);
1472+
}
1473+
ret.push_back(tmp);
1474+
}
1475+
1476+
return ret;
1477+
}
1478+
1479+
14471480
std::vector<omni_detailed_balance_t> BitcoinAPI::omni_getwalletbalances(bool includewatchonly)
14481481
{
14491482
string command = "omni_getwalletbalances";

src/bitcoinapi/bitcoinapi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class BitcoinAPI
3636
std::string omni_funded_sendall(const std::string& fromaddress, const std::string& toaddress, int ecosystem, const std::string& feeaddress);
3737
std::string omni_funded_send(const std::string& fromaddress, const std::string& toaddress, int propertyid, double amount, const std::string& feeaddress);
3838
std::vector<omni_detailed_balance_t> omni_getwalletbalances(bool includewatchonly);
39+
std::vector<omni_address_balance_t> omni_getwalletaddressbalances(bool includewatchonly);
40+
3941
omni_balance_t omni_getbalance(const std::string& address, int propertyid);
4042
std::vector<omni_transaction_t> omni_listtransactions(const std::string& txid = "*", int count = 10, int skip = 0, int startblock = 0, int endblock = 999999999);
4143
std::vector<omni_transaction_t> omni_listpendingtransactions(const std::string& address = "");

src/bitcoinapi/types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@
275275
std::string name;
276276
};
277277

278+
struct omni_address_balance_t{
279+
std::string address;
280+
std::vector<omni_detailed_balance_t> balances;
281+
};
282+
278283
#endif
279284

280285

0 commit comments

Comments
 (0)