Improved reporting for delivered_amount:

* Determine tx success from metadata result.
* Report delivered_amount for legacy account_tx queries.
This commit is contained in:
Miguel Portilla
2016-02-10 13:23:02 -05:00
committed by Vinnie Falco
parent 1e92ac3cf5
commit fbf736f169
3 changed files with 23 additions and 10 deletions

View File

@@ -42,20 +42,29 @@ addPaymentDeliveredAmount (
{
// We only want to add a "delivered_amount" field if the transaction
// succeeded - otherwise nothing could have been delivered.
if (!transaction || transaction->getResult () != tesSUCCESS)
if (! transaction)
return;
auto serializedTx = transaction->getSTransaction ();
if (!serializedTx || serializedTx->getTxnType () != ttPAYMENT)
if (! serializedTx || serializedTx->getTxnType () != ttPAYMENT)
return;
// If the transaction explicitly specifies a DeliveredAmount in the
// metadata then we use it.
if (transactionMeta && transactionMeta->hasDeliveredAmount ())
if (transactionMeta)
{
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;
}