-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify JSON serialization format of transactions #722
Comments
I am very supportive of this. |
This would break backwards compatibility. Perhaps we should put the (More specifically, we should start allowing users to request a specific API version so we can add such breaking changes in a non-disruptive way.) |
To be crystal clear: the proposed format I am suggesting for all transactions is as follows:
(Edit 2023-10-17: I now recommend putting the transaction instructions in |
Consider this for API v2 |
Use XLS-22d (basically, just use the |
This is a low-priority task for Clio |
This design is really good. Having just dove into thr typescript definitions for xrpl.js I was very confused. |
Go for it, there will not be better time to improve consistency than major version bump. |
Some updates since this is being worked on in XRPLF/rippled#4727 :
|
There are many API methods that can return transactions. Currently, the return formats are inconsistent. The following table shows where fields are located as of rippled v1.12.0 (unchanged since v1.0.1).
Note: In the following table, the "top" level is with respect to the individual object representing the transaction; for methods that return arrays of transactions, the "top" level is per element of the array. "Transaction Instructions" refer to the canonical fields of the transaction as defined in the transaction format, such as the
Account
andFlags
fields.hash
ledger_index
inLedger
validated
ledger_hash
date
ledger
(with transactions expanded)metaData
field (JSON)or in
meta
field¹ (binary)tx_blob
field¹tx
meta
fieldtx
field¹tx_history
(deprecated)account_tx
tx
fieldmeta
fieldtx
fieldtx
fieldtx
fieldtx_blob
field¹transaction_entry
(would like to deprecate)tx_json
fieldmetadata
fieldtx_json
fieldsign
,sign_for
,submit
, andsubmit_multisigned
tx_json
fieldtx_json
fieldtx_blob
fieldsubscribe
transaction
fieldmeta
field²transaction
fieldtx
fieldmeta
fieldtx
¹¹ Only if the request asked for binary data
² The
transactions_proposed
stream omits these fields because the transactions' outcomes are not yet final.Recommendation
Change all of
rippled
's methods to serialize transactions to JSON in a single consistent format. The format I suggest is essentially the same format the Data API uses, with modifications to accommodate for some formats only therippled
APIs handle. Specifically:tx_blob
for binary format. Always usetx_json
for JSON format transaction instructions.tx_json
field with transaction instructions. Move all "lowercase" fields likehash
andledger_index
out to the top level of the transaction. (Note: theissuer
/currency
/value
sub-fields of amounts are canonical fields even though they are lowercase.)meta
for JSON metadata. Usemeta_blob
for binary metadata.inLedger
field entirely. (It was a deprecated alias forledger_index
, which is the ledger index of the ledger that includes this transaction.)date
field to all transactions that are from a closed ledger. Most of the time this would be the close time of the parent ledger. Make this a UTC ISO8601 timestamp with whole-seconds resolution, for example2018-07-22T16:37:55Z
. Omit this field from transactions that are not in closed ledgers.ledger_hash
field to any transactions when pulling them from a closed ledger. Omit this field from transactions that are not in closed ledgers.validated
boolean field to all transactions, even when this information is redundant because of context (for example, listing transactions in a validated ledger).The text was updated successfully, but these errors were encountered: