Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/xrpl/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ enum TECcodes : TERUnderlyingType {
tecLIMIT_EXCEEDED = 195,
tecPSEUDO_ACCOUNT = 196,
tecPRECISION_LOSS = 197,
// DEPRECATED: This error code tecNO_DELEGATE_PERMISSION is reserved for
// backward compatibility with historical data on non-prod networks, can be
// reclaimed after those networks reset.
// DEPRECATED: tecNO_DELEGATE_PERMISSION is reserved for backward
// compatibility with historical data on non-prod networks only.
// TODO(deprecation): Remove this entry and reclaim value 198 once all
// non-prod networks that recorded this code have been reset.
tecNO_DELEGATE_PERMISSION = 198,
};

Expand Down
5 changes: 5 additions & 0 deletions src/libxrpl/protocol/Permissions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ Permission::Permission()
#pragma pop_macro("PERMISSION")
};

XRPL_ASSERT(
txFeatureMap_.size() == delegableTx_.size(),
"xrpl::Permission : txFeatureMap_ and delegableTx_ must have same "
"size");

for ([[maybe_unused]] auto const& permission : granularPermissionMap_)
{
XRPL_ASSERT(
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/tx/transactors/delegate/DelegateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NotTEC
checkTxPermission(std::shared_ptr<SLE const> const& delegate, STTx const& tx)
{
if (!delegate)
return terNO_DELEGATE_PERMISSION; // LCOV_EXCL_LINE
return terNO_DELEGATE_PERMISSION;

auto const permissionArray = delegate->getFieldArray(sfPermissions);
auto const txPermission = tx.getTxnType() + 1;
Expand All @@ -28,7 +28,7 @@ loadGranularPermission(
std::unordered_set<GranularPermissionType>& granularPermissions)
{
if (!delegate)
return; // LCOV_EXCL_LINE
return;

auto const permissionArray = delegate->getFieldArray(sfPermissions);
for (auto const& permission : permissionArray)
Expand Down
1 change: 1 addition & 0 deletions src/libxrpl/tx/transactors/payment/Payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Payment::checkPermission(ReadView const& view, STTx const& tx)
tx.isFieldPresent(sfPaths))
return terNO_DELEGATE_PERMISSION;

// PaymentMint and PaymentBurn apply to both IOU and MPT direct payments.
if (granularPermissions.contains(PaymentMint) && !isXRP(amountAsset) &&
amountAsset.getIssuer() == tx[sfAccount])
return tesSUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions src/test/app/Batch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4154,8 +4154,12 @@ class Batch_test : public beast::unit_test::suite
std::vector<TestLedgerData> testCases = {
{0, "Batch", "tesSUCCESS", batchID, std::nullopt},
{1, "TrustSet", "tesSUCCESS", txIDs[0], batchID},
// jv2 fails with terNO_DELEGATE_PERMISSION.
};
validateClosedLedger(env, testCases);

// verify jv2 is not present in the closed ledger.
BEAST_EXPECT(env.rpc("tx", txIDs[1])[jss::result][jss::error] == "txnNotFound");
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/test/app/Delegate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Permissions.h>
#include <xrpl/tx/transactors/delegate/DelegateUtils.h>

namespace xrpl {
namespace test {
Expand Down Expand Up @@ -1721,6 +1722,21 @@ class Delegate_test : public beast::unit_test::suite
"\n Action: Verify security requirements to interact with Delegation feature");
}

void
testDelegateUtilsNullptrCheck()
{
testcase("DelegateUtils nullptr check");

// checkTxPermission nullptr check
STTx const tx{ttPAYMENT, [](STObject&) {}};
BEAST_EXPECT(checkTxPermission(nullptr, tx) == terNO_DELEGATE_PERMISSION);

// loadGranularPermission nullptr check
std::unordered_set<GranularPermissionType> granularPermissions;
loadGranularPermission(nullptr, ttPAYMENT, granularPermissions);
BEAST_EXPECT(granularPermissions.empty());
}

void
run() override
{
Expand All @@ -1746,6 +1762,7 @@ class Delegate_test : public beast::unit_test::suite
testPermissionValue(all);
testTxRequireFeatures(all);
testTxDelegableCount();
testDelegateUtilsNullptrCheck();
}
};
BEAST_DEFINE_TESTSUITE(Delegate, app, xrpl);
Expand Down
Loading