Skip to content

Trampoline forwarding #3976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
let outbound_payment = match source {
None => panic!("Outbound HTLCs should have a source"),
Some(&HTLCSource::PreviousHopData(_)) => false,
Some(&HTLCSource::TrampolineForward { .. }) => false,
Some(&HTLCSource::OutboundRoute { .. }) => true,
};
return Some(Balance::MaybeTimeoutClaimableHTLC {
Expand Down Expand Up @@ -2835,6 +2836,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
let outbound_payment = match source {
None => panic!("Outbound HTLCs should have a source"),
Some(HTLCSource::PreviousHopData(_)) => false,
Some(HTLCSource::TrampolineForward { .. }) => false,
Some(HTLCSource::OutboundRoute { .. }) => true,
};
if outbound_payment {
Expand Down Expand Up @@ -3494,7 +3496,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
}
}));
}
self.counterparty_fulfilled_htlcs.insert(*claimed_htlc_id, *claimed_preimage);
let claimed = claimed_htlc_id.clone();
self.counterparty_fulfilled_htlcs.insert(claimed, *claimed_preimage);
}

Ok(())
Expand Down
12 changes: 12 additions & 0 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,14 @@ pub enum HTLCHandlingFailureType {
/// Short channel id we are requesting to forward an HTLC to.
requested_forward_scid: u64,
},
/// We couldn't forward to the next Trampoline node. That may happen if we cannot find a route,
/// or if the route we found didn't work out.
FailedTrampolineForward {
/// The node ID of the next Trampoline hop we tried forwarding to.
requested_next_node_id: PublicKey,
/// The channel we tried forwarding over, if we have settled to one.
forward_scid: Option<u64>,
},
/// We couldn't decode the incoming onion to obtain the forwarding details.
InvalidOnion,
/// Failure scenario where an HTLC may have been forwarded to be intended for us,
Expand Down Expand Up @@ -572,6 +580,10 @@ impl_writeable_tlv_based_enum_upgradable!(HTLCHandlingFailureType,
(4, Receive) => {
(0, payment_hash, required),
},
(5, FailedTrampolineForward) => {
(0, requested_next_node_id, required),
(2, forward_scid, option),
}
);

/// The reason for HTLC failures in [`Event::HTLCHandlingFailed`].
Expand Down
Loading
Loading