Skip to content

Commit

Permalink
improve requireAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Oct 11, 2024
1 parent 9d51389 commit 09dc565
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,15 +1720,29 @@ requireAuth(
AccountID const& account)
{
auto const mptID = keylet::mptIssuance(mptIssue.getMptID());
if (auto const sle = view.read(mptID);
sle && sle->getFieldU32(sfFlags) & lsfMPTRequireAuth)
{
auto const mptokenID = keylet::mptoken(mptID.key, account);
if (auto const tokSle = view.read(mptokenID); tokSle &&
//(sle->getFlags() & lsfMPTRequireAuth) &&
!(tokSle->getFlags() & lsfMPTAuthorized))
return TER{tecNO_AUTH};
}
auto const sleIssuance = view.read(mptID);

if (!sleIssuance)
return tecOBJECT_NOT_FOUND;

auto const mptIssuer = sleIssuance->getAccountID(sfIssuer);

// issuer is always "authorized"
if (mptIssuer == account)
return tesSUCCESS;

auto const mptokenID = keylet::mptoken(mptID.key, account);
auto const tokSle = view.read(mptokenID);

// if account has no MPToken, fail
if (!tokSle)
return tecNO_AUTH;

// mptoken must be authorized if issuance enabled requireAuth
if (sleIssuance->getFieldU32(sfFlags) & lsfMPTRequireAuth &&
!(tokSle->getFlags() & lsfMPTAuthorized))
return tecNO_AUTH;

return tesSUCCESS;
}

Expand Down

0 comments on commit 09dc565

Please sign in to comment.