From 9f96d7ea38c0e8aa536455c777991e3910d220f0 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 10 Nov 2015 11:02:56 -0800 Subject: [PATCH] Correct delivered_amount reporting for minor ledgers (RIPD-1051) The existing delivered_amount logic will erroneously report unavailable for ledgers that aren't in the network's live chain because it is based solely on ledger sequence number. This adds a check based on the ledger close time to permit the code to give correct results in standalone mode and on test networks. --- src/ripple/rpc/impl/Utilities.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ripple/rpc/impl/Utilities.cpp b/src/ripple/rpc/impl/Utilities.cpp index 3966199bdb..1b651809cd 100644 --- a/src/ripple/rpc/impl/Utilities.cpp +++ b/src/ripple/rpc/impl/Utilities.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -65,6 +66,19 @@ addPaymentDeliveredAmount ( return; } + // If the ledger closed long after the DeliveredAmount code was deployed + // then its absence indicates that the amount delivered is listed in the + // Amount field. DeliveredAmount went live January 24, 2014. + auto ct = + context.ledgerMaster.getCloseTimeBySeq (transaction->getLedger ()); + if (ct && (*ct > 446000000)) + { + // 446000000 is in Feb 2014, well after DeliveredAmount went live + meta[jss::delivered_amount] = + serializedTx->getFieldAmount (sfAmount).getJson (1); + return; + } + // Otherwise we report "unavailable" which cannot be parsed into a // sensible amount. meta[jss::delivered_amount] = Json::Value ("unavailable");