`rustfmt` and clean up `get_onchain_failed_outbound_htlcs`
What changed, and why it matters
This commit is purely a code cleanup: it removes a `#[rustfmt::skip]` annotation and reformats a helper function, converting a macro into an equivalent closure. There is no functional change to how the software processes payments or channel data.
No security action needed. Treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors get_all_current_outbound_htlcs in lightning/src/chain/channelmonitor.rs. A local macro walk_counterparty_commitment! is replaced by an equivalent closure, and the function signature is reformatted to satisfy rustfmt. The logic—iterating counterparty commitment txids, collecting outbound HTLCs, and looking up preimages—remains identical. No behavior, state access, or trust boundary changes.
Changed components
lightning/src/chain/channelmonitor.rsInspect captured patch +13 / −13
diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs
index 70bd2ad..7d54de7 100644
--- a/lightning/src/chain/channelmonitor.rs
+++ b/lightning/src/chain/channelmonitor.rs
@@ -3007,29 +3007,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
/// This is similar to [`Self::get_pending_or_resolved_outbound_htlcs`] except it includes
/// HTLCs which were resolved on-chain (i.e. where the final HTLC resolution was done by an
/// event from this `ChannelMonitor`).
- #[rustfmt::skip]
- pub(crate) fn get_all_current_outbound_htlcs(&self) -> HashMap<HTLCSource, (HTLCOutputInCommitment, Option<PaymentPreimage>)> {
+ pub(crate) fn get_all_current_outbound_htlcs(
+ &self,
+ ) -> HashMap<HTLCSource, (HTLCOutputInCommitment, Option<PaymentPreimage>)> {
let mut res = new_hash_map();
// Just examine the available counterparty commitment transactions. See docs on
// `fail_unbroadcast_htlcs`, below, for justification.
let us = self.inner.lock().unwrap();
- macro_rules! walk_counterparty_commitment {
- ($txid: expr) => {
- if let Some(ref latest_outpoints) = us.funding.counterparty_claimable_outpoints.get($txid) {
- for &(ref htlc, ref source_option) in latest_outpoints.iter() {
- if let &Some(ref source) = source_option {
- res.insert((**source).clone(), (htlc.clone(),
- us.counterparty_fulfilled_htlcs.get(&SentHTLCId::from_source(source)).cloned()));
- }
+ let mut walk_counterparty_commitment = |txid| {
+ if let Some(latest_outpoints) = us.funding.counterparty_claimable_outpoints.get(txid) {
+ for &(ref htlc, ref source_option) in latest_outpoints.iter() {
+ if let &Some(ref source) = source_option {
+ let htlc_id = SentHTLCId::from_source(source);
+ let preimage_opt = us.counterparty_fulfilled_htlcs.get(&htlc_id).cloned();
+ res.insert((**source).clone(), (htlc.clone(), preimage_opt));
}
}
}
- }
+ };
if let Some(ref txid) = us.funding.current_counterparty_commitment_txid {
- walk_counterparty_commitment!(txid);
+ walk_counterparty_commitment(txid);
}
if let Some(ref txid) = us.funding.prev_counterparty_commitment_txid {
- walk_counterparty_commitment!(txid);
+ walk_counterparty_commitment(txid);
}
res
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.