diff --git a/src/ripple/rpc/handlers/AccountTx.cpp b/src/ripple/rpc/handlers/AccountTx.cpp index 8f100312d4f..954b0628ee7 100644 --- a/src/ripple/rpc/handlers/AccountTx.cpp +++ b/src/ripple/rpc/handlers/AccountTx.cpp @@ -374,18 +374,19 @@ populateProtoResponse( if (txnMeta) { RPC::convert(*txnProto->mutable_meta(), txnMeta); - - auto amt = getDeliveredAmount( - context, - txn->getSTransaction(), - *txnMeta, - txn->getLedger()); - if (amt) + if (!txnMeta->hasDeliveredAmount()) { - RPC::convert( - *txnProto->mutable_meta() - ->mutable_delivered_amount(), - *amt); + if (auto amt = getDeliveredAmount( + context, + txn->getSTransaction(), + *txnMeta, + txn->getLedger())) + { + RPC::convert( + *txnProto->mutable_meta() + ->mutable_delivered_amount(), + *amt); + } } } } diff --git a/src/ripple/rpc/impl/GRPCHelpers.cpp b/src/ripple/rpc/impl/GRPCHelpers.cpp index 1d2f5af69b2..0c068b08d45 100644 --- a/src/ripple/rpc/impl/GRPCHelpers.cpp +++ b/src/ripple/rpc/impl/GRPCHelpers.cpp @@ -1567,6 +1567,9 @@ convert(org::xrpl::rpc::v1::Meta& to, std::shared_ptr const& from) to.mutable_transaction_result()->set_result( transToken(from->getResultTER())); + if (from->hasDeliveredAmount()) + convert(*to.mutable_delivered_amount(), from->getDeliveredAmount()); + STArray& nodes = from->getNodes(); for (auto it = nodes.begin(); it != nodes.end(); ++it) { diff --git a/src/test/rpc/Tx_test.cpp b/src/test/rpc/Tx_test.cpp index 3dcdbd52fac..7c3668ea0b3 100644 --- a/src/test/rpc/Tx_test.cpp +++ b/src/test/rpc/Tx_test.cpp @@ -546,7 +546,10 @@ class Tx_test : public beast::unit_test::suite client.status.ok(), client.reply); }; - auto grpcAccountTx = [&grpcPort](auto hash, auto binary, auto account) { + auto grpcAccountTx = [&grpcPort]( + uint256 const& hash, + auto binary, + AccountID const& account) { GrpcAccountTxClient client(grpcPort); client.request.set_binary(binary); client.request.mutable_account()->set_address(toBase58(account)); @@ -728,11 +731,13 @@ class Tx_test : public beast::unit_test::suite tx); // Compare result to result from account_tx - // The transactions in later ledgers do not include A1 - if (index < startLegSeq + 14) + auto mentioned = tx->getMentionedAccounts(); + + if (BEAST_EXPECT(mentioned.size())) { + auto a = *mentioned.begin(); auto const accountTxResult = - grpcAccountTx(id, b, A1); + grpcAccountTx(id, b, a); BEAST_EXPECT(accountTxResult.first); if (accountTxResult.first)