Skip to content

Commit

Permalink
Rename allowClawback flag to allowTrustLineClawback (#4617)
Browse files Browse the repository at this point in the history
Reason for this change is here XRPLF/XRPL-Standards#119

We would want to be explicit that this flag is exclusively for trustline. For new token types(eg. CFT), they will not utilize this flag for clawback, instead, they will turn clawback on/off on the token-level, which is more versatile.
  • Loading branch information
shawnxie999 authored Jul 14, 2023
1 parent cb09e61 commit 5ba1f98
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 104 deletions.
6 changes: 4 additions & 2 deletions src/ripple/app/tx/impl/Clawback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ Clawback::preclaim(PreclaimContext const& ctx)

std::uint32_t const issuerFlagsIn = sleIssuer->getFieldU32(sfFlags);

// If AllowClawback is not set or NoFreeze is set, return no permission
if (!(issuerFlagsIn & lsfAllowClawback) || (issuerFlagsIn & lsfNoFreeze))
// If AllowTrustLineClawback is not set or NoFreeze is set, return no
// permission
if (!(issuerFlagsIn & lsfAllowTrustLineClawback) ||
(issuerFlagsIn & lsfNoFreeze))
return tecNO_PERMISSION;

auto const sleRippleState =
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/app/tx/impl/SetAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ SetAccount::preclaim(PreclaimContext const& ctx)
//
if (ctx.view.rules().enabled(featureClawback))
{
if (uSetFlag == asfAllowClawback)
if (uSetFlag == asfAllowTrustLineClawback)
{
if (uFlagsIn & lsfNoFreeze)
{
Expand All @@ -240,7 +240,7 @@ SetAccount::preclaim(PreclaimContext const& ctx)
else if (uSetFlag == asfNoFreeze)
{
// Cannot set NoFreeze if clawback is enabled
if (uFlagsIn & lsfAllowClawback)
if (uFlagsIn & lsfAllowTrustLineClawback)
{
JLOG(ctx.j.trace())
<< "Can't set NoFreeze if clawback is enabled";
Expand Down Expand Up @@ -595,10 +595,10 @@ SetAccount::doApply()

// Set flag for clawback
if (ctx_.view().rules().enabled(featureClawback) &&
uSetFlag == asfAllowClawback)
uSetFlag == asfAllowTrustLineClawback)
{
JLOG(j_.trace()) << "set allow clawback";
uFlagsOut |= lsfAllowClawback;
uFlagsOut |= lsfAllowTrustLineClawback;
}

if (uFlagsIn != uFlagsOut)
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ enum LedgerSpecificFlags {
lsfDisallowIncomingTrustline =
0x20000000, // True, reject new trustlines (only if no issued assets)
lsfAMM [[maybe_unused]] = 0x40000000, // True, AMM account
lsfAllowClawback =
lsfAllowTrustLineClawback =
0x80000000, // True, enable clawback

// ltOFFER
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/TxFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ constexpr std::uint32_t asfDisallowIncomingNFTokenOffer = 12;
constexpr std::uint32_t asfDisallowIncomingCheck = 13;
constexpr std::uint32_t asfDisallowIncomingPayChan = 14;
constexpr std::uint32_t asfDisallowIncomingTrustline = 15;
constexpr std::uint32_t asfAllowClawback = 16;
constexpr std::uint32_t asfAllowTrustLineClawback = 16;

// OfferCreate flags:
constexpr std::uint32_t tfPassive = 0x00010000;
Expand Down
7 changes: 4 additions & 3 deletions src/ripple/rpc/handlers/AccountInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ doAccountInfo(RPC::JsonContext& context)
{"disallowIncomingTrustline", lsfDisallowIncomingTrustline}}};

static constexpr std::pair<std::string_view, LedgerSpecificFlags>
allowClawbackFlag{"allowClawback", lsfAllowClawback};
allowTrustLineClawbackFlag{
"allowTrustLineClawback", lsfAllowTrustLineClawback};

auto const sleAccepted = ledger->read(keylet::account(accountID));
if (sleAccepted)
Expand Down Expand Up @@ -128,8 +129,8 @@ doAccountInfo(RPC::JsonContext& context)
}

if (ledger->rules().enabled(featureClawback))
acctFlags[allowClawbackFlag.first.data()] =
sleAccepted->isFlag(allowClawbackFlag.second);
acctFlags[allowTrustLineClawbackFlag.first.data()] =
sleAccepted->isFlag(allowTrustLineClawbackFlag.second);

result[jss::account_flags] = std::move(acctFlags);

Expand Down
Loading

0 comments on commit 5ba1f98

Please sign in to comment.