Skip to content
Draft
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
37 changes: 24 additions & 13 deletions include/xrpl/ledger/helpers/EscrowHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,32 @@ escrowUnlockApplyHelper<Issue>(

if (!ctx.view.exists(trustLineKey) && createAsset)
{
// Can the account cover the trust line's reserve?
auto const sponsorSle = getTxReserveSponsor(ctx);
if (!sponsorSle)
return sponsorSle.error(); // LCOV_EXCL_LINE

if (auto const ret = checkReserve(
ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
!isTesSuccess(ret))
if (!ctx.view.rules().enabled(featureSponsor))
{
JLOG(journal.trace()) << "Trust line does not exist. "
"Insufficient reserve to create line.";
// checkReserve can return tecINSUFFICIENT_RESERVE or tecINTERNAL
if (ret == tecINSUFFICIENT_RESERVE)
// Can the account cover the trust line's reserve?
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
xrpBalance < ctx.view.fees().accountReserve(ownerCount + 1))
{
JLOG(journal.trace()) << "Trust line does not exist. "
"Insufficient reserve to create line.";
return tecNO_LINE_INSUF_RESERVE;
return ret;
}
}
else
{
auto const sponsorSle = getTxReserveSponsor(ctx);
if (!sponsorSle)
return sponsorSle.error(); // LCOV_EXCL_LINE

if (auto const ret = checkReserve(
ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
!isTesSuccess(ret))
{
JLOG(journal.trace()) << "Trust line does not exist. "
"Insufficient reserve to create line.";
// checkReserve can return tecINSUFFICIENT_RESERVE or tecINTERNAL
return ret;
}
}

Currency const currency = issue.currency;
Expand Down