mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Improved reporting for delivered_amount:
* Determine tx success from metadata result. * Report delivered_amount for legacy account_tx queries.
This commit is contained in:
committed by
Vinnie Falco
parent
c717006c44
commit
2beeb9a293
@@ -163,7 +163,7 @@ Json::Value doAccountTx (RPC::Context& context)
|
|||||||
{
|
{
|
||||||
auto meta = it.second->getJson (1);
|
auto meta = it.second->getJson (1);
|
||||||
addPaymentDeliveredAmount (meta, context, it.first, it.second);
|
addPaymentDeliveredAmount (meta, context, it.first, it.second);
|
||||||
jvObj[jss::meta] = meta;
|
jvObj[jss::meta] = std::move(meta);
|
||||||
|
|
||||||
std::uint32_t uLedgerIndex = it.second->getLgrSeq ();
|
std::uint32_t uLedgerIndex = it.second->getLgrSeq ();
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <ripple/resource/Fees.h>
|
#include <ripple/resource/Fees.h>
|
||||||
#include <ripple/rpc/Context.h>
|
#include <ripple/rpc/Context.h>
|
||||||
#include <ripple/rpc/impl/LookupLedger.h>
|
#include <ripple/rpc/impl/LookupLedger.h>
|
||||||
|
#include <ripple/rpc/impl/Utilities.h>
|
||||||
#include <ripple/server/Role.h>
|
#include <ripple/server/Role.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -183,7 +184,10 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
|||||||
{
|
{
|
||||||
std::uint32_t uLedgerIndex = it->second->getLgrSeq ();
|
std::uint32_t uLedgerIndex = it->second->getLgrSeq ();
|
||||||
|
|
||||||
jvObj[jss::meta] = it->second->getJson (0);
|
auto meta = it->second->getJson(0);
|
||||||
|
addPaymentDeliveredAmount(meta, context, it->first, it->second);
|
||||||
|
jvObj[jss::meta] = std::move(meta);
|
||||||
|
|
||||||
jvObj[jss::validated]
|
jvObj[jss::validated]
|
||||||
= bValidated
|
= bValidated
|
||||||
&& uValidatedMin <= uLedgerIndex
|
&& uValidatedMin <= uLedgerIndex
|
||||||
|
|||||||
@@ -39,20 +39,29 @@ addPaymentDeliveredAmount (
|
|||||||
{
|
{
|
||||||
// We only want to add a "delivered_amount" field if the transaction
|
// We only want to add a "delivered_amount" field if the transaction
|
||||||
// succeeded - otherwise nothing could have been delivered.
|
// succeeded - otherwise nothing could have been delivered.
|
||||||
if (!transaction || transaction->getResult () != tesSUCCESS)
|
if (! transaction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto serializedTx = transaction->getSTransaction ();
|
auto serializedTx = transaction->getSTransaction ();
|
||||||
|
if (! serializedTx || serializedTx->getTxnType () != ttPAYMENT)
|
||||||
if (!serializedTx || serializedTx->getTxnType () != ttPAYMENT)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If the transaction explicitly specifies a DeliveredAmount in the
|
if (transactionMeta)
|
||||||
// metadata then we use it.
|
{
|
||||||
if (transactionMeta && transactionMeta->hasDeliveredAmount ())
|
if (transactionMeta->getResultTER() != tesSUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If the transaction explicitly specifies a DeliveredAmount in the
|
||||||
|
// metadata then we use it.
|
||||||
|
if (transactionMeta->hasDeliveredAmount ())
|
||||||
|
{
|
||||||
|
meta[jss::delivered_amount] =
|
||||||
|
transactionMeta->getDeliveredAmount ().getJson (1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (transaction->getResult() != tesSUCCESS)
|
||||||
{
|
{
|
||||||
meta[jss::delivered_amount] =
|
|
||||||
transactionMeta->getDeliveredAmount ().getJson (1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user