From 777b00a5efb293bbffbf333398568f5d421293f8 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:53:07 -0500 Subject: [PATCH] Removed featureCredential check for MPT review fixes renamed malformedAuthorizedCredentials --- src/test/app/MPToken_test.cpp | 10 +++++----- src/test/rpc/LedgerRPC_test.cpp | 14 +++++++------- src/xrpld/app/misc/CredentialHelpers.cpp | 3 ++- src/xrpld/app/tx/detail/DepositPreauth.cpp | 10 ++++------ src/xrpld/app/tx/detail/Payment.cpp | 11 ++++------- src/xrpld/rpc/handlers/LedgerEntry.cpp | 4 ++-- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 6bc6a3f51c6..536818caa07 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -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 @@ -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(); @@ -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 diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index e4ad33b98b2..c5e10198c49 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -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", ""); } { @@ -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", ""); } { @@ -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", ""); } { @@ -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", ""); } { @@ -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", ""); } { @@ -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", ""); } { @@ -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", ""); } { diff --git a/src/xrpld/app/misc/CredentialHelpers.cpp b/src/xrpld/app/misc/CredentialHelpers.cpp index 58fdeb78195..08b5d804d4b 100644 --- a/src/xrpld/app/misc/CredentialHelpers.cpp +++ b/src/xrpld/app/misc/CredentialHelpers.cpp @@ -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); diff --git a/src/xrpld/app/tx/detail/DepositPreauth.cpp b/src/xrpld/app/tx/detail/DepositPreauth.cpp index 6208db1ad1d..73cd19e4120 100644 --- a/src/xrpld/app/tx/detail/DepositPreauth.cpp +++ b/src/xrpld/app/tx/detail/DepositPreauth.cpp @@ -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; } @@ -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) { diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index e8de8ac4352..b58dce685f0 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -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(); diff --git a/src/xrpld/rpc/handlers/LedgerEntry.cpp b/src/xrpld/rpc/handlers/LedgerEntry.cpp index 2eda79e64cc..6a3b7a48686 100644 --- a/src/xrpld/rpc/handlers/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/LedgerEntry.cpp @@ -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;