APIv2(DeliverMax): add alias for Amount in Payment transactions (#4733)

Using the "Amount" field in Payment transactions can cause incorrect
interpretation. There continue to be problems from the use of this
field. "Amount" is rarely the correct field to use; instead,
"delivered_amount" (or "DeliveredAmount") should be used.

Rename the "Amount" field to "DeliverMax", a less misleading name. With
api_version: 2, remove the "Amount" field from Payment transactions.

- Input: "DeliverMax" in `tx_json` is an alias for "Amount"
  - sign
  - submit (in sign-and-submit mode)
  - submit_multisigned
  - sign_for
- Output: Add "DeliverMax" where transactions are provided by the API
  - ledger
  - tx
  - tx_history
  - account_tx
  - transaction_entry
  - subscribe (transactions stream)
- Output: Remove "Amount" from API version 2

Fix #3484

Fix #3902
This commit is contained in:
Bronek Kozicki
2023-10-23 19:26:16 +01:00
committed by GitHub
parent 5026cbdaf3
commit 397268394b
28 changed files with 1014 additions and 83 deletions

View File

@@ -194,8 +194,16 @@ public:
// Check stream update for payment transaction
BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) {
return jv[jss::meta]["AffectedNodes"][1u]["CreatedNode"]
["NewFields"][jss::Account] ==
Account("alice").human();
["NewFields"][jss::Account] //
== Account("alice").human() &&
jv[jss::transaction][jss::TransactionType] //
== jss::Payment &&
jv[jss::transaction][jss::DeliverMax] //
== "10000000010" &&
jv[jss::transaction][jss::Fee] //
== "10" &&
jv[jss::transaction][jss::Sequence] //
== 1;
}));
// Check stream update for accountset transaction
@@ -211,7 +219,16 @@ public:
// Check stream update for payment transaction
BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) {
return jv[jss::meta]["AffectedNodes"][1u]["CreatedNode"]
["NewFields"][jss::Account] == Account("bob").human();
["NewFields"][jss::Account] //
== Account("bob").human() &&
jv[jss::transaction][jss::TransactionType] //
== jss::Payment &&
jv[jss::transaction][jss::DeliverMax] //
== "10000000010" &&
jv[jss::transaction][jss::Fee] //
== "10" &&
jv[jss::transaction][jss::Sequence] //
== 2;
}));
// Check stream update for accountset transaction