Skip to content

Commit

Permalink
Removed featureCredential check for MPT
Browse files Browse the repository at this point in the history
review fixes
renamed malformedAuthorizedCredentials
  • Loading branch information
oleks-rip committed Nov 6, 2024
1 parent 0e2683d commit 777b00a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,8 +1432,8 @@ class MPToken_test : public beast::unit_test::suite
env(fset(bob, asfDepositAuth));
env.close();

// alice try to send 100 MPT to bob, authorization is not checked
mptAlice.pay(alice, bob, 100);
// alice try to send 100 MPT to bob, not authorized
mptAlice.pay(alice, bob, 100, tecNO_PERMISSION);
env.close();

// alice try to send 100 MPT to bob with credentials, amendment
Expand All @@ -1445,7 +1445,7 @@ class MPToken_test : public beast::unit_test::suite
env(deposit::auth(bob, alice));
env.close();

// alice sends 100 MPT to bob, authorization is not checked
// alice sends 100 MPT to bob
mptAlice.pay(alice, bob, 100);
env.close();

Expand All @@ -1457,8 +1457,8 @@ class MPToken_test : public beast::unit_test::suite
env(deposit::unauth(bob, alice));
env.close();

// alice try to send 100 MPT to bob, authorization is not checked
mptAlice.pay(alice, bob, 100);
// alice try to send 100 MPT to bob
mptAlice.pay(alice, bob, 100, tecNO_PERMISSION);
env.close();

// alice sends 100 MPT to bob with credentials, amendment disabled
Expand Down
14 changes: 7 additions & 7 deletions src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand All @@ -1148,7 +1148,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand All @@ -1170,7 +1170,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand Down Expand Up @@ -1218,7 +1218,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand Down Expand Up @@ -1260,7 +1260,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand All @@ -1282,7 +1282,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand All @@ -1304,7 +1304,7 @@ class LedgerRPC_test : public beast::unit_test::suite
auto const jrr =
env.rpc("json", "ledger_entry", to_string(jvParams));
checkErrorValue(
jrr[jss::result], "malformedAuthorizeCredentials", "");
jrr[jss::result], "malformedAuthorizedCredentials", "");
}

{
Expand Down
3 changes: 2 additions & 1 deletion src/xrpld/app/misc/CredentialHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ verifyDepositPreauth(
// If depositPreauth is enabled, then an account that requires
// authorization has at least two ways to get a payment in:
// 1. If src == dst, or
// 2. If src is deposit preauthorized by dst.
// 2. If src is deposit preauthorized by dst (either by account or by
// credentials).

bool const credentialsPresent = ctx.tx.isFieldPresent(sfCredentialIDs);

Expand Down
10 changes: 4 additions & 6 deletions src/xrpld/app/tx/detail/DepositPreauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ DepositPreauth::preflight(PreflightContext const& ctx)
return ret;

auto& tx = ctx.tx;
auto& j = ctx.j;

if (tx.getFlags() & tfUniversalMask)
{
JLOG(j.trace()) << "Malformed transaction: Invalid flags set.";
JLOG(ctx.j.trace()) << "Malformed transaction: Invalid flags set.";
return temINVALID_FLAG;
}

Expand All @@ -66,17 +65,16 @@ DepositPreauth::preflight(PreflightContext const& ctx)

if (authPresent + authCredPresent != 1)
{
// Either both fields are present or neither field is present. In
// either case the transaction is malformed.
JLOG(j.trace())
// There can only be 1 field out of 4 or the transaction is malformed.
JLOG(ctx.j.trace())
<< "Malformed transaction: "
"Invalid Authorize and Unauthorize field combination.";
return temMALFORMED;
}

// Make sure that the passed account is valid.
if (authPresent)
{
// Make sure that the passed account is valid.
AccountID const& target(optAuth ? *optAuth : *optUnauth);
if (!target)
{
Expand Down
11 changes: 4 additions & 7 deletions src/xrpld/app/tx/detail/Payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,10 @@ Payment::doApply()
ter != tesSUCCESS)
return ter;

if (view().rules().enabled(featureCredentials))
{
if (auto err =
verifyDepositPreauth(ctx_, account_, dstAccountID, sleDst);
!isTesSuccess(err))
return err;
}
if (auto err =
verifyDepositPreauth(ctx_, account_, dstAccountID, sleDst);
!isTesSuccess(err))
return err;

auto const& issuer = mptIssue.getIssuer();

Expand Down
4 changes: 2 additions & 2 deletions src/xrpld/rpc/handlers/LedgerEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ doLedgerEntry(RPC::JsonContext& context)
STArray const arr = parseAuthorizeCredentials(ac);

if (arr.empty() || (arr.size() > maxCredentialsArraySize))
jvResult[jss::error] = "malformedAuthorizeCredentials";
jvResult[jss::error] = "malformedAuthorizedCredentials";
else
{
auto sorted = credentials::makeSorted(arr);
if (sorted.empty())
jvResult[jss::error] =
"malformedAuthorizeCredentials";
"malformedAuthorizedCredentials";
else
uNodeIndex =
keylet::depositPreauth(*owner, sorted).key;
Expand Down

0 comments on commit 777b00a

Please sign in to comment.