Skip to content

Commit de9c9c0

Browse files
committed
htlcswitch: set packet obfuscator for failures through switch
Set obfuscator for use in blinded error handling when we forward failures through the switch.
1 parent 72260ad commit de9c9c0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

htlcswitch/mailbox.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
738738
sourceRef: pkt.sourceRef,
739739
hasSource: true,
740740
localFailure: localFailure,
741+
obfuscator: pkt.obfuscator,
741742
linkFailure: linkError,
742743
htlc: &lnwire.UpdateFailHTLC{
743744
Reason: reason,

htlcswitch/switch.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,11 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
12971297

12981298
fail, isFail := htlc.(*lnwire.UpdateFailHTLC)
12991299
if isFail && !packet.hasSource {
1300+
// HTLC resolutions and messages restored from disk
1301+
// don't have the obfuscator set from the original htlc
1302+
// add packet - set it here for use in blinded errors.
1303+
packet.obfuscator = circuit.ErrorEncrypter
1304+
13001305
switch {
13011306
// No message to encrypt, locally sourced payment.
13021307
case circuit.ErrorEncrypter == nil:
@@ -1485,6 +1490,7 @@ func (s *Switch) failAddPacket(packet *htlcPacket, failure *LinkError) error {
14851490
incomingTimeout: packet.incomingTimeout,
14861491
outgoingTimeout: packet.outgoingTimeout,
14871492
circuit: packet.circuit,
1493+
obfuscator: packet.obfuscator,
14881494
linkFailure: failure,
14891495
htlc: &lnwire.UpdateFailHTLC{
14901496
Reason: reason,
@@ -1841,6 +1847,10 @@ out:
18411847
// resolution message on restart.
18421848
resolutionMsg.errChan <- nil
18431849

1850+
// Create a htlc packet for this resolution. We do
1851+
// not have some of the information that we'll need
1852+
// for blinded error handling here , so we'll rely on
1853+
// our forwarding logic to fill it in later.
18441854
pkt := &htlcPacket{
18451855
outgoingChanID: resolutionMsg.SourceChan,
18461856
outgoingHTLCID: resolutionMsg.HtlcIndex,
@@ -2065,6 +2075,8 @@ func (s *Switch) reforwardResolutions() error {
20652075

20662076
// The circuit is still open, so we can assume that the link or
20672077
// switch (if we are the source) hasn't cleaned it up yet.
2078+
// We rely on our forwarding logic to fill in details that
2079+
// are not currently available to us.
20682080
resPkt := &htlcPacket{
20692081
outgoingChanID: resMsg.SourceChan,
20702082
outgoingHTLCID: resMsg.HtlcIndex,
@@ -2214,7 +2226,8 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
22142226
// we can continue to propagate it. This
22152227
// failure originated from another node, so
22162228
// the linkFailure field is not set on this
2217-
// packet.
2229+
// packet. We rely on the link to fill in
2230+
// additional circuit information for us.
22182231
failPacket := &htlcPacket{
22192232
outgoingChanID: fwdPkg.Source,
22202233
outgoingHTLCID: pd.ParentIndex,

0 commit comments

Comments
 (0)