Skip to content

Commit 24a7655

Browse files
htlcswitch: fix on-chain resolution error misclassification
This commit fixes a bug in `parseFailedPayment` where an on-chain resolution with an empty reason was not being correctly identified after being deserialized from disk by SubscribeResult or GetResult. This impacts callers waiting for the final settle/fail result on an htlc attempt via GetAttemptResult. The lnwire codec transforms a `nil` reason into a non-nil, empty byte slice and bypasses the existing check for `htlc.Reason == nil`. Thankfully this does not crash the daemon. Rather, it just leads to the caller (in our case, the ChannelRouter) not actually receiving the expected FailPermanentChannelFailure link error.
1 parent 3972403 commit 24a7655

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

htlcswitch/switch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ func (s *Switch) parseFailedPayment(deobfuscator ErrorDecrypter,
10901090
// the first hop. In this case, we'll report a permanent
10911091
// channel failure as this means us, or the remote party had to
10921092
// go on chain.
1093-
case isResolution && htlc.Reason == nil:
1093+
case isResolution && len(htlc.Reason) == 0:
10941094
linkError := NewDetailedLinkError(
10951095
&lnwire.FailPermanentChannelFailure{},
10961096
OutgoingFailureOnChainTimeout,

htlcswitch/switch_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5608,9 +5608,10 @@ func TestOnChainResolutionFailure(t *testing.T) {
56085608

56095609
require.NotNil(t, res.Error, "expected error for failed result")
56105610

5611-
// We expect the misclassified error which occurs when sending
5612-
// an empty encrypted failure reason to the de-obfuscator.
5613-
expectedErr := ErrUnreadableFailureMessage
5611+
expectedErr := NewDetailedLinkError(
5612+
&lnwire.FailPermanentChannelFailure{},
5613+
OutgoingFailureOnChainTimeout,
5614+
)
56145615
require.Equal(t, expectedErr, res.Error)
56155616

56165617
case <-time.After(1 * time.Second):

0 commit comments

Comments
 (0)