37 auto& params = context.
params;
46 if (!(params.isMember(jss::account) || params.isMember(jss::ident)))
50 params.isMember(jss::account) ? params[jss::account].asString() : params[jss::ident].asString());
53 auto id = parseBase58<AccountID>(strIdent);
56 auto const accountID{std::move(
id.value())};
59 result[jss::account] =
toBase58(accountID);
70 if (params.isMember(jss::hotwallet))
72 auto addHotWallet = [&hotWallets](
Json::Value const& j) {
75 if (
auto id = parseBase58<AccountID>(j.asString()); id)
77 hotWallets.
insert(std::move(
id.value()));
91 for (
unsigned i = 0; i < hw.
size(); ++i)
92 valid &= addHotWallet(hw[i]);
96 valid &= addHotWallet(hw);
130 if (sle->getType() == ltESCROW)
132 auto const& escrow = sle->getFieldAmount(sfAmount);
133 auto& bal = locked[escrow.getCurrency()];
134 if (bal == beast::zero)
161 int balSign = rs->getBalance().signum();
165 auto const& peer = rs->getAccountIDPeer();
171 if (hotWallets.
count(peer) > 0)
174 hotBalances[peer].push_back(-rs->getBalance());
176 else if (balSign > 0)
179 assets[peer].push_back(rs->getBalance());
181 else if (rs->getFreeze())
184 frozenBalances[peer].push_back(-rs->getBalance());
189 auto& bal = sums[rs->getBalance().getCurrency()];
190 if (bal == beast::zero)
193 bal = -rs->getBalance();
199 bal -= rs->getBalance();
217 for (
auto const& [k, v] : sums)
221 result[jss::obligations] = std::move(j);
224 auto populateResult = [&result](
229 for (
auto const& [accId, accBalances] : array)
232 for (
auto const& balance : accBalances)
236 entry[jss::value] = balance.getText();
237 balanceArray.
append(std::move(entry));
239 j[
to_string(accId)] = std::move(balanceArray);
241 result[name] = std::move(j);
245 populateResult(hotBalances, jss::balances);
246 populateResult(frozenBalances, jss::frozen_balances);
247 populateResult(assets, jss::assets);
253 for (
auto const& [k, v] : locked)
257 result[jss::locked] = std::move(j);
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, Json::Value &result)
Looks up a ledger from a request and fills a Json::Value with ledger data.
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Resource::Charge & loadType