add lockedbalance and lockcount to account_lines rpc

This commit is contained in:
Richard Holland
2022-08-30 11:11:31 +00:00
parent ce09f9a4c6
commit 73bf8f3fff
4 changed files with 31 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -152,6 +152,18 @@ public:
return mBalance;
}
std::optional<STAmount> const&
getLockedBalance() const
{
return mLockedBalance;
}
std::optional<uint32_t> const&
getLockCount() const
{
return mLockCount;
}
STAmount const&
getLimit() const
{
@@ -174,6 +186,8 @@ protected:
STAmount const mHighLimit;
STAmount mBalance;
std::optional<STAmount> mLockedBalance;
std::optional<uint32_t> mLockCount; // RH NOTE: this is from sfLockCount has nothing to do with a mutex.
std::uint32_t mFlags;

View File

@@ -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

View File

@@ -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<STAmount> const& saLockedBalance(line.getLockedBalance());
std::optional<uint32_t> 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();