diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index bc4eb4d410b..b17dcf9c89b 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -453,8 +453,8 @@ Payment::doApply() ter != tesSUCCESS) return ter; - if (auto const ter = - canTransfer(view(), saDstAmount.mptIssue(), account_, uDstAccountID); + if (auto const ter = canTransfer( + view(), saDstAmount.mptIssue(), account_, uDstAccountID); ter != tesSUCCESS) return ter; diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index 9859639bd74..39fc1e90fba 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -1699,14 +1699,18 @@ requireAuth(ReadView const& view, MPTIssue const& mpt, AccountID const& account) } TER -canTransfer(ReadView const& view, MPTIssue const& mpt, AccountID const& from, AccountID const& to) +canTransfer( + ReadView const& view, + MPTIssue const& mpt, + AccountID const& from, + AccountID const& to) { auto const mptID = keylet::mptIssuance(mpt.mpt()); if (auto const sle = view.read(mptID); sle && !(sle->getFieldU32(sfFlags) & lsfMPTCanTransfer)) { - if(from != (*sle)[sfIssuer] && to != (*sle)[sfIssuer]) - return TER{tecNO_AUTH}; + if (from != (*sle)[sfIssuer] && to != (*sle)[sfIssuer]) + return TER{tecNO_AUTH}; } return tesSUCCESS; } diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 5760b4735bf..f47638ab083 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -619,7 +619,8 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob, &carol}}); - mptAlice.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); + mptAlice.create( + {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); // env(mpt::authorize(alice, id.key, std::nullopt)); // env.close(); @@ -646,7 +647,9 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob}}); mptAlice.create( - {.ownerCount = 1, .holderCount = 0, .flags = tfMPTRequireAuth | tfMPTCanTransfer}); + {.ownerCount = 1, + .holderCount = 0, + .flags = tfMPTRequireAuth | tfMPTCanTransfer}); mptAlice.authorize({.account = &bob}); @@ -661,7 +664,9 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob}}); mptAlice.create( - {.ownerCount = 1, .holderCount = 0, .flags = tfMPTRequireAuth | tfMPTCanTransfer}); + {.ownerCount = 1, + .holderCount = 0, + .flags = tfMPTRequireAuth | tfMPTCanTransfer}); // bob creates an empty MPToken mptAlice.authorize({.account = &bob}); @@ -707,7 +712,8 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob, &carol}}); - mptAlice.create({.ownerCount = 1, .flags = tfMPTCanLock | tfMPTCanTransfer}); + mptAlice.create( + {.ownerCount = 1, .flags = tfMPTCanLock | tfMPTCanTransfer}); mptAlice.authorize({.account = &bob}); mptAlice.authorize({.account = &carol}); @@ -745,7 +751,11 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob}}); - mptAlice.create({.maxAmt = 100, .ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); + mptAlice.create( + {.maxAmt = 100, + .ownerCount = 1, + .holderCount = 0, + .flags = tfMPTCanTransfer}); mptAlice.authorize({.account = &bob}); @@ -807,7 +817,8 @@ class MPToken_test : public beast::unit_test::suite mptAlice.pay(bob, carol, 100); } - // Test that non-issuer cannot send to each other if MPTCanTransfer isn't set + // Test that non-issuer cannot send to each other if MPTCanTransfer + // isn't set { Env env(*this, features); Account const alice{"alice"}; @@ -817,9 +828,7 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {&bob, &cindy}}); // alice creates issuance without MPTCanTransfer - mptAlice.create( - {.ownerCount = 1, - .holderCount = 0}); + mptAlice.create({.ownerCount = 1, .holderCount = 0}); // bob creates a MPToken mptAlice.authorize({.account = &bob}); @@ -830,7 +839,8 @@ class MPToken_test : public beast::unit_test::suite // alice pays bob 100 tokens mptAlice.pay(alice, bob, 100); - // bob tries to send cindy 10 tokens, but fails because canTransfer is off + // bob tries to send cindy 10 tokens, but fails because canTransfer + // is off mptAlice.pay(bob, cindy, 10, tecNO_AUTH); // bob can send back to alice(issuer) just fine