From 4e6cba3324eaf5cadf623600c0f1b2a3cd3b7c47 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 23 May 2025 15:21:04 +0200 Subject: [PATCH] feat: add get_recovered_transaction helper (#16436) --- crates/primitives-traits/src/block/recovered.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/primitives-traits/src/block/recovered.rs b/crates/primitives-traits/src/block/recovered.rs index c565691dc6..44631cd38e 100644 --- a/crates/primitives-traits/src/block/recovered.rs +++ b/crates/primitives-traits/src/block/recovered.rs @@ -283,6 +283,15 @@ impl RecoveredBlock { (self.block.into_block(), self.senders) } + /// Returns the `Recovered<&T>` transaction at the given index. + pub fn recovered_transaction( + &self, + idx: usize, + ) -> Option::Transaction>> { + let sender = self.senders.get(idx).copied()?; + self.block.body().transactions().get(idx).map(|tx| Recovered::new_unchecked(tx, sender)) + } + /// Returns an iterator over all transactions and their sender. #[inline] pub fn transactions_with_sender(