From 0aa3b2ed74994ee368791a4a1b4f2c47bc5cb65c Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Mon, 13 Feb 2023 13:40:37 +0000 Subject: [PATCH] fix txn hash lookup from index --- src/ripple/app/ledger/impl/LedgerMaster.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index b22a22b70..2b85110b7 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -2380,14 +2380,11 @@ LedgerMaster::txnIDfromIndex(uint32_t ledgerSeq, uint32_t txnIndex) if (!lgr || lgr->txs.empty()) return {}; - uint32_t counter = 0; - for (auto it = lgr->txs.begin(); it != lgr->txs.end() && counter <= txnIndex; it++, counter++) - { - if (counter != txnIndex) - continue; - - return it->first->getTransactionID(); - } + for (auto it = lgr->txs.begin(); it != lgr->txs.end(); it++) + if (it->first && it->second && + it->second->isFieldPresent(sfTransactionIndex) && + it->second->getFieldU32(sfTransactionIndex) == txnIndex) + return it->first->getTransactionID(); return {}; }