Skip to content

Commit

Permalink
add issuance check to start of func
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Sep 9, 2024
1 parent a28a767 commit f5ed98b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,23 @@ class MPToken_test : public beast::unit_test::suite
// fail.
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
}

// Issuer fails trying to send to some who doesn't own MPT for a
// issuance that was destroyed
{
Env env{*this, features};

MPTTester mptAlice(env, alice, {.holders = {&bob}});

mptAlice.create({.ownerCount = 1, .holderCount = 0});

// alice destroys issuance
mptAlice.destroy({.ownerCount = 0});

// alice tries to send bob who doesn't own the MPT after issuance is
// destroyed, it should fail
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
}
}

void
Expand Down
8 changes: 6 additions & 2 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,10 @@ rippleCredit(
{
auto const mptID = keylet::mptIssuance(saAmount.issue().getMptID());
auto const issuer = saAmount.getIssuer();

if (!view.peek(mptID))
return tecMPT_ISSUANCE_NOT_FOUND;

if (uSenderID == issuer)
{
if (auto sle = view.peek(mptID))
Expand All @@ -1875,7 +1879,7 @@ rippleCredit(
view.update(sle);
}
else
return tecMPT_ISSUANCE_NOT_FOUND;
return tecINTERNAL;
}
else
{
Expand Down Expand Up @@ -1914,7 +1918,7 @@ rippleCredit(
return tecINSUFFICIENT_FUNDS;
}
else
return tecMPT_ISSUANCE_NOT_FOUND;
return tecINTERNAL;
}
else
{
Expand Down

0 comments on commit f5ed98b

Please sign in to comment.