From ecd1b7ade87b2743ebb131c96feab195c9248124 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 19 Nov 2025 16:28:50 +0000 Subject: [PATCH] lnonion: explicitly forbid nesting trampoline-in-trampoline This assert is needed because I don't want to reason about what could happen without it. We currently use fixed 400 bytes trampoline onion sizes, which would implicitly prevent this. However the current bolts PR actually specifies variable size trampoline onions. --- electrum/lnonion.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/electrum/lnonion.py b/electrum/lnonion.py index 2f53b369e..a2f1a56a7 100644 --- a/electrum/lnonion.py +++ b/electrum/lnonion.py @@ -396,6 +396,8 @@ def process_onion_packet( # trampoline trampoline_onion_packet = hop_data.payload.get('trampoline_onion_packet') if trampoline_onion_packet: + if is_trampoline: + raise Exception("found nested trampoline inside trampoline") top_version = trampoline_onion_packet.get('version') top_public_key = trampoline_onion_packet.get('public_key') top_hops_data = trampoline_onion_packet.get('hops_data')