fix: add allowClawback flag for account_info (#4590)

* Update the `account_info` API so that the `allowClawback` flag is
  included in the response.
  * The proposed `Clawback` amendement added an `allowClawback` flag in
    the `AccountRoot` object.
  * In the API response, under `account_flags`, there is now an
    `allowClawback` field with a boolean (`true` or `false`) value.
  * For reference, the XLS-39 Clawback implementation can be found in
    #4553

Fix #4588
This commit is contained in:
Shawn Xie
2023-07-05 11:46:23 -04:00
committed by GitHub
parent 66bfe909e6
commit 77dc63b549
2 changed files with 43 additions and 8 deletions

View File

@@ -96,6 +96,9 @@ doAccountInfo(RPC::JsonContext& context)
{"disallowIncomingPayChan", lsfDisallowIncomingPayChan},
{"disallowIncomingTrustline", lsfDisallowIncomingTrustline}}};
static constexpr std::pair<std::string_view, LedgerSpecificFlags>
allowClawbackFlag{"allowClawback", lsfAllowClawback};
auto const sleAccepted = ledger->read(keylet::account(accountID));
if (sleAccepted)
{
@@ -123,6 +126,11 @@ doAccountInfo(RPC::JsonContext& context)
for (auto const& lsf : disallowIncomingFlags)
acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
}
if (ledger->rules().enabled(featureClawback))
acctFlags[allowClawbackFlag.first.data()] =
sleAccepted->isFlag(allowClawbackFlag.second);
result[jss::account_flags] = std::move(acctFlags);
// The document states that signer_lists is a bool, however