Skip to content

Commit

Permalink
Check for reserve only when creating a new object.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled authored and oleks-rip committed Nov 7, 2024
1 parent 91befed commit 7a083ec
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/xrpld/app/tx/detail/PermissionedDomainSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ PermissionedDomainSet::doApply()
{
auto const ownerSle = view().peek(keylet::account(account_));

// Check reserve availability for new object creation
{
auto const balance = STAmount((*ownerSle)[sfBalance]).xrp();
auto const reserve =
ctx_.view().fees().accountReserve((*ownerSle)[sfOwnerCount] + 1);

if (balance < reserve)
return tecINSUFFICIENT_RESERVE;
}

// The purpose of this lambda is to modify the SLE for either creating a
// new or updating an existing object, to reduce code repetition.
// All checks have already been done. Just update credentials. Same logic
Expand Down Expand Up @@ -145,6 +135,13 @@ PermissionedDomainSet::doApply()
else
{
// Create new permissioned domain.
// Check reserve availability for new object creation
auto const balance = STAmount((*ownerSle)[sfBalance]).xrp();
auto const reserve =
ctx_.view().fees().accountReserve((*ownerSle)[sfOwnerCount] + 1);
if (balance < reserve)
return tecINSUFFICIENT_RESERVE;

Keylet const pdKeylet = keylet::permissionedDomain(
account_, ctx_.tx.getFieldU32(sfSequence));
auto slePd = std::make_shared<SLE>(pdKeylet);
Expand Down

0 comments on commit 7a083ec

Please sign in to comment.