feat: Add optional expanded response format to account_currencies - #7829
Open
Platonenkov wants to merge 1 commit into
Open
feat: Add optional expanded response format to account_currencies#7829Platonenkov wants to merge 1 commit into
Platonenkov wants to merge 1 commit into
Conversation
|
If only the most recent commit is unsigned, you can run:
If multiple commits are unsigned, you can run:
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
Platonenkov
marked this pull request as draft
July 20, 2026 01:55
Platonenkov
marked this pull request as ready for review
July 20, 2026 01:55
Platonenkov
force-pushed
the
feature/account-currencies-expanded
branch
from
July 20, 2026 01:55
e6be48d to
d129bb7
Compare
Add an optional boolean 'expanded' request parameter to the account_currencies method. When expanded is true, send_currencies and receive_currencies contain objects keyed by asset instead of plain currency codes. Entries for tokens held (or receivable) from a counterparty carry currency, issuer (the counterparty) and value (the maximum amount that can be received or sent on that line). The account's own issuance is aggregated into a single entry per currency with issuer set to the requested account and no value, so that issuing accounts with many holders do not produce one entry per trust line (compare the obligations section of gateway_balances). Like the legacy format, membership and value are derived from trust line limits and balances alone and do not reflect freeze or authorization state; account_lines reports the full per-line state. Currency codes alone are ambiguous because an account may hold trust lines with the same currency code from different issuers, and the legacy response gives no way to tell which issuer-specific asset is usable. The default response format is unchanged for backward compatibility.
Platonenkov
marked this pull request as draft
July 20, 2026 11:49
Platonenkov
marked this pull request as ready for review
July 20, 2026 11:49
Platonenkov
force-pushed
the
feature/account-currencies-expanded
branch
from
July 20, 2026 11:49
d129bb7 to
cdace5c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High Level Overview of Change
Adds an optional boolean
expandedrequest parameter to theaccount_currenciesmethod.When
expanded: true,send_currenciesandreceive_currenciescontain objects keyed by asset instead of plain currency codes:currency,issuerandvalue(the remaining capacity of the trust line). The account's own issuance is aggregated into a single entry per currency, so issuing accounts with many holders do not produce one entry per trust line. The default response format is unchanged.Fixes #6629
Context of Change
Currency codes alone are ambiguous: an account may hold trust lines with the same currency code from different issuers, and one of them may be available for sending while another is only available for receiving. The legacy response (
"send_currencies": ["USD"]) gives no way to tell which issuer-specific asset is meant, so clients fall back toaccount_linesand reimplement the aggregation logic that already exists inside this handler.Design decisions:
issuer= counterparty andvalue= remaining capacity (limit - balancefor receive,balancefor send). Each entry has the shape of a standard currency amount object.issuer= the requested account and novalue, mirroring the aggregatedobligationssection ofgateway_balances. Without this, an issuer with thousands of holders would get one (misleading) entry per trust line.account_lines; evaluating effective transferability here would also require extra ledger reads (e.g.lsfRequireAuthlives on the issuer's AccountRoot).Alternatives considered are documented in the linked issue (including an earlier revision with per-line state flags, which was dropped to keep the method focused on "which assets and how much").
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)API-CHANGELOG.md is updated in this PR. The only
libxrplchange is one new constant injss.h(JSS(expanded)).The new parameter is opt-in and fully backward compatible: without
expanded(or withexpanded: false) the response is unchanged. A non-booleanexpandedreturnsinvalidParams, consistent with the parameter validation introduced in #6529.Before / After
Request:
{ "command": "account_currencies", "account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn", "ledger_index": "validated", "expanded": true }Before (and still the response when
expandedis omitted):{ "receive_currencies": ["EUR", "USD"], "send_currencies": ["USD"] }After, with
expanded: true(holder account; two USD issuers are now distinguishable and carry the remaining line capacity):{ "receive_currencies": [ { "currency": "EUR", "issuer": "rGateway...", "value": "100" }, { "currency": "USD", "issuer": "rIssuerA...", "value": "50" }, { "currency": "USD", "issuer": "rIssuerB...", "value": "100" } ], "send_currencies": [ { "currency": "USD", "issuer": "rIssuerA...", "value": "50" } ] }Issuing account (own issuance aggregated, holders not enumerated):
{ "receive_currencies": [ { "currency": "USD", "issuer": "rIssuingAccount..." } ], "send_currencies": [ { "currency": "USD", "issuer": "rIssuingAccount..." } ] }Performance: no impact on the default path (identical code path). The expanded path performs the same single pass over the same trust line vector, with one STAmount subtraction per entry; no additional ledger reads, locks or async processing.
Test Plan
Extended
AccountCurrencies_testwith:valuechecks for send/receive capacities;currency,issuer,value;value);expanded: falseproducing the legacy string-array format;invalidParamsfor non-booleanexpandedvalues.Full local runs on top of current
develop(gcc 15.2, Release, Linux):xrpld --unittest— 238 suites, 4513 cases, 0 failures;xrpl_tests— 708 tests passed.