diff --git a/src/test/rpc/GatewayBalances_test.cpp b/src/test/rpc/GatewayBalances_test.cpp index a13e5bc20c..e1cafb2f9c 100644 --- a/src/test/rpc/GatewayBalances_test.cpp +++ b/src/test/rpc/GatewayBalances_test.cpp @@ -247,6 +247,46 @@ public: expect(jv[jss::result][jss::obligations]["USD"] == maxUSD.getText()); } + void + testGWBWithMPT() + { + testcase("Gateway Balances with MPT Escrow"); + using namespace std::chrono_literals; + using namespace jtx; + + // Ensure MPT is enabled + FeatureBitset features = testable_amendments() | featureMPTokensV1; + Env env(*this, features); + + Account const alice{"alice"}; + Account const bob{"bob"}; + + env.fund(XRP(10000), alice, bob); + env.close(); + + // Create MPT issuance (Alice) with Escrow capability + MPTTester mpt(env, alice, {.holders = {bob}, .fund = false}); + mpt.create({.flags = tfMPTCanEscrow}); + + // Authorize Bob and fund him + mpt.authorize({.account = bob, .holderCount = 1}); + mpt.pay(alice, bob, 1000); + + // Bob creates an escrow of MPT to Alice. + auto const MPT = mpt["MPT"]; + env(escrow::create(bob, alice, MPT(100)), + escrow::finish_time(env.now() + 10s)); + env.close(); + + // Query gateway_balances for Bob. + auto wsc = makeWSClient(env.app().config()); + Json::Value qry; + qry[jss::account] = bob.human(); + + auto jv = wsc->invoke("gateway_balances", qry); + expect(jv[jss::status] == "success"); + } + void run() override { @@ -257,7 +297,7 @@ public: testGWB(feature); testGWBApiVersions(feature); } - + testGWBWithMPT(); testGWBOverflow(); } }; diff --git a/src/xrpld/rpc/handlers/GatewayBalances.cpp b/src/xrpld/rpc/handlers/GatewayBalances.cpp index a4542f682f..6c6867b248 100644 --- a/src/xrpld/rpc/handlers/GatewayBalances.cpp +++ b/src/xrpld/rpc/handlers/GatewayBalances.cpp @@ -151,6 +151,10 @@ doGatewayBalances(RPC::JsonContext& context) if (sle->getType() == ltESCROW) { auto const& escrow = sle->getFieldAmount(sfAmount); + // Gateway Balance should not include MPTs + if (escrow.holds()) + return; + auto& bal = locked[escrow.getCurrency()]; if (bal == beast::zero) {