lnworker: use channel_id instead of scid in ReceivedMPPHtlc

Store the channel id instead of the scid in ReceivedMPPHtlc.
The scid can be None, in theory even for multiple channels at the same
time. Using the channel_id which is always available and unique seems
less error prone at the cost of temporarily higher storage requirements
in the db for the duration of the pending htlcs.

Alternatively we could use the local scid alias however using the
channel_id seems less complex and leaves less room for ambiguity.
This commit is contained in:
f321x
2025-12-08 12:00:52 +01:00
parent 8a88ebe6bc
commit 5be598b808
4 changed files with 46 additions and 18 deletions
+5 -5
View File
@@ -1965,18 +1965,18 @@ del r
class ReceivedMPPHtlc(NamedTuple):
scid: ShortChannelID
channel_id: bytes
htlc: UpdateAddHtlc
unprocessed_onion: str
def __repr__(self):
return f"{self.scid}, {self.htlc=}, {self.unprocessed_onion[:15]=}..."
return f"chan_id={self.channel_id.hex()}, {self.htlc=}, {self.unprocessed_onion[:15]=}..."
@staticmethod
def from_tuple(scid, htlc, unprocessed_onion) -> 'ReceivedMPPHtlc':
assert is_hex_str(unprocessed_onion) and is_hex_str(scid)
def from_tuple(channel_id, htlc, unprocessed_onion) -> 'ReceivedMPPHtlc':
assert is_hex_str(unprocessed_onion) and is_hex_str(channel_id)
return ReceivedMPPHtlc(
scid=ShortChannelID(bytes.fromhex(scid)),
channel_id=bytes.fromhex(channel_id),
htlc=UpdateAddHtlc.from_tuple(*htlc),
unprocessed_onion=unprocessed_onion,
)