Skip to content

Why fields are capitalized or lowercase in rippled requests and responses

Elliot Lee edited this page Apr 6, 2020 · 1 revision
  1. Why is this called delivered_amount and not DeliveredAmount?
  • Fields that are in uppercase are set by the server. They’re part of the official metadata. These fields are usually UpperCamelCase (Pascal case).
  • Fields in lowercase are synthetic fields. These fields are usually snake_case.
  • You can have both DeliveredAmount and delivered_amount set.
  • I don’t recall the rationale for us not setting DeliveredAmount in every payment.
  1. Similarly, some fields are capitalized (like Account etc. in tx_json) but some are not (like account in an account_info request).
  • Although it is querying official ledger data, the fields in the request are user-supplied data, not ledger data.
  • In other words, most request parameters are lowercase because they're user-supplied data, not ledger data.
  • We should tinker with errors, where necessary, to ensure they make sense in the context where the user sees them.
  • In this case, we should actually catch that error before we do a request, because Account is a required field on every transaction.
  • Before auto-filling, you must know the transaction type and the account. Everything else can be auto-filled or omitted.
  1. In some circumstances we set delivered_amount to "unavailable" (see https://github.com/ripple/rippled/blob/develop/src/ripple/rpc/impl/RPCHelpers.cpp#L473). This isn't a valid amount encoding (for the binary format). If we were to write code to support the binary case, we would probably need to encode this as an amount, not a string.
  • We don’t need the delivered_amount field in the binary encoding. We assume that anyone competent enough to parse the binary encoding is competent enough to understand that the absence of the field means the full amount was delivered. For the human-readable output (i.e. JSON) we can’t make that same assumption.
  • As a result, JSON responses will have the field, but binary won't, for the same request. But binary is a pain anyway.