Add support for XLS-85 Token Escrow (#5185)

- Specification: https://github.com/XRPLF/XRPL-Standards/pull/272
- Amendment: `TokenEscrow`
- Enables escrowing of IOU and MPT tokens in addition to native XRP.
- Allows accounts to lock issued tokens (IOU/MPT) in escrow objects, with support for freeze, authorization, and transfer rates.
- Adds new ledger fields (`sfLockedAmount`, `sfIssuerNode`, etc.) to track locked balances for IOU and MPT escrows.
- Updates EscrowCreate, EscrowFinish, and EscrowCancel transaction logic to support IOU and MPT assets, including proper handling of trustlines and MPT authorization, transfer rates, and locked balances.
- Enforces invariant checks for escrowed IOU/MPT amounts.
- Extends GatewayBalances RPC to report locked (escrowed) balances.
This commit is contained in:
Denis Angell
2025-06-03 18:51:55 +02:00
committed by GitHub
parent 7e24adbdd0
commit 053e1af7ff
39 changed files with 6420 additions and 766 deletions

View File

@@ -199,6 +199,48 @@ Env::balance(Account const& account, Issue const& issue) const
return {amount, lookup(issue.account).name()};
}
PrettyAmount
Env::balance(Account const& account, MPTIssue const& mptIssue) const
{
MPTID const id = mptIssue.getMptID();
if (!id)
return {STAmount(mptIssue, 0), account.name()};
AccountID const issuer = mptIssue.getIssuer();
if (account.id() == issuer)
{
// Issuer balance
auto const sle = le(keylet::mptIssuance(id));
if (!sle)
return {STAmount(mptIssue, 0), account.name()};
STAmount const amount{mptIssue, sle->getFieldU64(sfOutstandingAmount)};
return {amount, lookup(issuer).name()};
}
else
{
// Holder balance
auto const sle = le(keylet::mptoken(id, account));
if (!sle)
return {STAmount(mptIssue, 0), account.name()};
STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
return {amount, lookup(issuer).name()};
}
}
PrettyAmount
Env::limit(Account const& account, Issue const& issue) const
{
auto const sle = le(keylet::line(account.id(), issue));
if (!sle)
return {STAmount(issue, 0), account.name()};
auto const aHigh = account.id() > issue.account;
if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit))
return {(*sle)[aHigh ? sfLowLimit : sfHighLimit], account.name()};
return {STAmount(issue, 0), account.name()};
}
std::uint32_t
Env::ownerCount(Account const& account) const
{