diff --git a/src/ripple/rpc/handlers/AccountTx.cpp b/src/ripple/rpc/handlers/AccountTx.cpp index b577872833..59244159b6 100644 --- a/src/ripple/rpc/handlers/AccountTx.cpp +++ b/src/ripple/rpc/handlers/AccountTx.cpp @@ -163,7 +163,7 @@ Json::Value doAccountTx (RPC::Context& context) { auto meta = it.second->getJson (1); addPaymentDeliveredAmount (meta, context, it.first, it.second); - jvObj[jss::meta] = meta; + jvObj[jss::meta] = std::move(meta); std::uint32_t uLedgerIndex = it.second->getLgrSeq (); diff --git a/src/ripple/rpc/handlers/AccountTxOld.cpp b/src/ripple/rpc/handlers/AccountTxOld.cpp index 2b0c513be7..dcca79e614 100644 --- a/src/ripple/rpc/handlers/AccountTxOld.cpp +++ b/src/ripple/rpc/handlers/AccountTxOld.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include namespace ripple { @@ -183,7 +184,10 @@ Json::Value doAccountTxOld (RPC::Context& context) { 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] = bValidated && uValidatedMin <= uLedgerIndex diff --git a/src/ripple/rpc/impl/Utilities.cpp b/src/ripple/rpc/impl/Utilities.cpp index 5a80c8e373..2d1180e9ab 100644 --- a/src/ripple/rpc/impl/Utilities.cpp +++ b/src/ripple/rpc/impl/Utilities.cpp @@ -39,20 +39,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; }