From 73bf8f3fff44be97013670200a2d89e0f2a5760a Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Tue, 30 Aug 2022 11:11:31 +0000 Subject: [PATCH] add lockedbalance and lockcount to account_lines rpc --- src/ripple/app/paths/TrustLine.cpp | 2 ++ src/ripple/app/paths/TrustLine.h | 14 ++++++++++++++ src/ripple/protocol/jss.h | 2 ++ src/ripple/rpc/handlers/AccountLines.cpp | 13 +++++++++++++ 4 files changed, 31 insertions(+) diff --git a/src/ripple/app/paths/TrustLine.cpp b/src/ripple/app/paths/TrustLine.cpp index 14a5d6f88..2d7e5b241 100644 --- a/src/ripple/app/paths/TrustLine.cpp +++ b/src/ripple/app/paths/TrustLine.cpp @@ -32,6 +32,8 @@ TrustLineBase::TrustLineBase( , mLowLimit(sle->getFieldAmount(sfLowLimit)) , mHighLimit(sle->getFieldAmount(sfHighLimit)) , mBalance(sle->getFieldAmount(sfBalance)) + , mLockedBalance((*sle)[~sfLockedBalance]) + , mLockCount((*sle)[~sfLockCount]) , mFlags(sle->getFieldU32(sfFlags)) , mViewLowest(mLowLimit.getIssuer() == viewAccount) { diff --git a/src/ripple/app/paths/TrustLine.h b/src/ripple/app/paths/TrustLine.h index 6b27dca36..29430c0d3 100644 --- a/src/ripple/app/paths/TrustLine.h +++ b/src/ripple/app/paths/TrustLine.h @@ -152,6 +152,18 @@ public: return mBalance; } + std::optional const& + getLockedBalance() const + { + return mLockedBalance; + } + + std::optional const& + getLockCount() const + { + return mLockCount; + } + STAmount const& getLimit() const { @@ -174,6 +186,8 @@ protected: STAmount const mHighLimit; STAmount mBalance; + std::optional mLockedBalance; + std::optional mLockCount; // RH NOTE: this is from sfLockCount has nothing to do with a mutex. std::uint32_t mFlags; diff --git a/src/ripple/protocol/jss.h b/src/ripple/protocol/jss.h index 28959e98f..30c3da60d 100644 --- a/src/ripple/protocol/jss.h +++ b/src/ripple/protocol/jss.h @@ -381,6 +381,8 @@ JSS(load_fee); // out: LoadFeeTrackImp, NetworkOPs JSS(local); // out: resource/Logic.h JSS(local_txs); // out: GetCounts JSS(local_static_keys); // out: ValidatorList +JSS(locked_balance); // out: AccountLines +JSS(lock_count); // out: AccountLines JSS(low); // out: BookChanges JSS(lowest_sequence); // out: AccountInfo JSS(lowest_ticket); // out: AccountInfo diff --git a/src/ripple/rpc/handlers/AccountLines.cpp b/src/ripple/rpc/handlers/AccountLines.cpp index 364d40673..a1c958f71 100644 --- a/src/ripple/rpc/handlers/AccountLines.cpp +++ b/src/ripple/rpc/handlers/AccountLines.cpp @@ -47,6 +47,9 @@ addLine(Json::Value& jsonLines, RPCTrustLine const& line) STAmount const& saBalance(line.getBalance()); STAmount const& saLimit(line.getLimit()); STAmount const& saLimitPeer(line.getLimitPeer()); + std::optional const& saLockedBalance(line.getLockedBalance()); + std::optional const& saLockCount(line.getLockCount()); + Json::Value& jPeer(jsonLines.append(Json::objectValue)); jPeer[jss::account] = to_string(line.getAccountIDPeer()); @@ -56,6 +59,16 @@ addLine(Json::Value& jsonLines, RPCTrustLine const& line) // Amount reported is negative if other account holds current // account's IOUs. jPeer[jss::balance] = saBalance.getText(); + + if (saLockedBalance) + jPeer[jss::locked_balance] = + saLockedBalance->negative() + ? (-(*saLockedBalance)).getText() + : saLockedBalance->getText(); + + if (saLockCount) + jPeer[jss::lock_count] = *saLockCount; + jPeer[jss::currency] = to_string(saBalance.issue().currency); jPeer[jss::limit] = saLimit.getText(); jPeer[jss::limit_peer] = saLimitPeer.getText();