Ledger owner fund (#753)

Fixes #754
This commit is contained in:
cyan317
2023-07-11 12:36:48 +01:00
committed by GitHub
parent 210d7fdbc8
commit 7710468f37
5 changed files with 562 additions and 17 deletions

View File

@@ -86,6 +86,32 @@ LedgerHandler::process(LedgerHandler::Input input, Context const& ctx) const
entry[JS(meta)] = ripple::strHex(obj.metadata);
}
if (input.ownerFunds)
{
// check the type of tx
auto const [tx, meta] = RPC::deserializeTxPlusMeta(obj);
if (tx and tx->isFieldPresent(ripple::sfTransactionType) and
tx->getTxnType() == ripple::ttOFFER_CREATE)
{
auto const account = tx->getAccountID(ripple::sfAccount);
auto const amount = tx->getFieldAmount(ripple::sfTakerGets);
// If the offer create is not self funded then add the
// owner balance
if (account != amount.getIssuer())
{
auto const ownerFunds = accountHolds(
*sharedPtrBackend_,
lgrInfo.seq,
account,
amount.getCurrency(),
amount.getIssuer(),
false, // fhIGNORE_FREEZE from rippled
ctx.yield);
entry[JS(owner_funds)] = ownerFunds.getText();
}
}
}
return entry;
});
}
@@ -173,6 +199,9 @@ tag_invoke(boost::json::value_to_tag<LedgerHandler::Input>, boost::json::value c
if (jsonObject.contains(JS(expand)))
input.expand = jv.at(JS(expand)).as_bool();
if (jsonObject.contains(JS(owner_funds)))
input.ownerFunds = jv.at(JS(owner_funds)).as_bool();
if (jsonObject.contains("diff"))
input.diff = jv.at("diff").as_bool();