rippled
rippled copied to clipboard
The ledger command does not include "delivered_amount" field in transaction metadata
Issue Description
The ledger
RPC command has a different format for metadata than the tx
RPC command. In the ledger
command's response, metaData
(not meta
) is found. DeliveredAmount
(not delivered_amount
) is found. It is also missing validated
field. This should be fixed to match tx
command's response.
Steps to Reproduce
-
Go to https://xrpl.org/websocket-api-tool.html#ledger
-
Choose full history server and send the following request
{ "id": 1, "command": "ledger", "ledger_index": 36527098, "full": false, "expand": true, "transactions": true, "accounts": false }
-
Search the output for BFC631D4C12229F6F2BD14203349100356DFB72F4FD4067B9C7A4EFAB9850770. Note you'll find "metaData" (not "meta"), that contains "DeliveredAmount" (not "delivered_amount") and no "validated" field.
-
Go to https://xrpl.org/websocket-api-tool.html#tx
-
Post
{ "id": 1, "command": "tx", "transaction": "BFC631D4C12229F6F2BD14203349100356DFB72F4FD4067B9C7A4EFAB9850770" }
-
You'll find "meta", "delivered_amount" and "validated".
Expected Result
Actual Result
Environment
Supporting Files
sample outputs are included. ledger.txt tx.txt
Exported from RIPD-1599
This is related: https://github.com/ripple/rippled/issues/2599
[Sorry for closing -- accidental click.]
I looked into this. The "meta" vs "metaData" issue is because of here: https://github.com/ripple/rippled/blob/f43aeda49c5362dc83c66507cae2ec71cfa7bfdf/src/ripple/app/ledger/impl/LedgerToJson.cpp#L133 We even will use "meta" if you request binary data, but "metaData" otherwise. Definitely should fix that.
"validated" is not a field of each transaction, but applies to all of the returned data. Either all of the data is validated, or none is. If you scroll all the way to the bottom, you will find "validated" : true
. So, this output is as expected, and is not a bug.
I did not see "DeliveredAmount" in the output. I only saw "delivered_amount". I traced the code as well and could not find how "DeliveredAmount" could possibly end up in the output. This is the code that populates the delivered amount field: https://github.com/ripple/rippled/blob/f43aeda49c5362dc83c66507cae2ec71cfa7bfdf/src/ripple/rpc/impl/DeliveredAmount.cpp#L154
I reran this with the exact request that you specified and was able to see "DeliveredAmount". I saw a "DeliveredAmount" field as well as a "delivered_amount" field. Previously I had tried with a different ledger, and there was only "delivered_amount".
DeliveredAmount
is a raw data field that is included in the canonical metadata format (including in binary) and contributes to the hash of the ledger. We cannot remove or change it without an amendment.
delivered_amount
is a synthetic field that is added by the API. It covers some cases that DeliveredAmount
doesn't (e.g. cases with a fixed payment amount) so that you can always use delivered_amount
instead of sometimes using the Amount
from the payment. This is documented in the Transaction Metadata page.
Also, the meta
vs. metaData
thing is part of a much bigger problem thoroughly described in XRPLF/clio#722 as @intelliot mentioned above.
Hi I could try to fix it.
Is this being worked by someone? I can also pick it.
@giorgosHadji - I do not think anyone is working on this. You can pick it.