mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
fix: Gateway balance with MPT (#6143)
When `gateway_balances` gets called on an account that is involved in the `EscrowCreate` transaction (with MPT being escrowed), the method returns internal error. This change fixes this case by excluding the MPT type when totaling escrow amount.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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<MPTIssue>())
|
||||
return;
|
||||
|
||||
auto& bal = locked[escrow.getCurrency()];
|
||||
if (bal == beast::zero)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user