From 4d2ec0004ba8367ee264f917a49b710fc042dc6b Mon Sep 17 00:00:00 2001 From: RichardAH Date: Thu, 2 Nov 2023 11:47:57 +0100 Subject: [PATCH] fix for ctid on tx rpc (#177) * fix for ctid on tx rpc * clang-format --------- Co-authored-by: Denis Angell --- src/ripple/rpc/handlers/Tx.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index 72afcc869..4574d7541 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -268,19 +268,18 @@ doTxHelp(RPC::Context& context, TxArgs args) result.validated = isValidated( context.ledgerMaster, ledger->info().seq, ledger->info().hash); - /* - // RH NOTE: this is now handled inside the Transaction class - // leaving a copy here in case for some reason it's needed again - // compute outgoing CTID - uint32_t lgrSeq = ledger->info().seq; - uint32_t txnIdx = meta->getAsObject().getFieldU32(sfTransactionIndex); - uint32_t netID = context.app.config().NETWORK_ID; + if (meta->getAsObject().isFieldPresent(sfTransactionIndex)) + { + uint32_t lgrSeq = ledger->info().seq; + uint32_t txnIdx = + meta->getAsObject().getFieldU32(sfTransactionIndex); + uint32_t netID = context.app.config().NETWORK_ID; - if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL) - result.ctid = - RPC::encodeCTID(lgrSeq, (uint16_t)txnIdx, (uint16_t)netID); - */ + if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL) + result.ctid = + RPC::encodeCTID(lgrSeq, (uint16_t)txnIdx, (uint16_t)netID); + } } return {result, rpcSUCCESS};