From aa9abb3d96f8e8e43be8af792661540855b3471e Mon Sep 17 00:00:00 2001 From: bitromortac Date: Wed, 30 Apr 2025 15:31:05 +0200 Subject: [PATCH] routing: make sure failure message is valid --- routing/missioncontrol.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/routing/missioncontrol.go b/routing/missioncontrol.go index 9d89c8092..89e14f523 100644 --- a/routing/missioncontrol.go +++ b/routing/missioncontrol.go @@ -837,21 +837,29 @@ func (n *namespacedDB) purge() error { func newPaymentFailure(sourceIdx *int, failureMsg lnwire.FailureMessage) paymentFailure { + // If we can't identify a failure source, we also won't have a decrypted + // failure message. In this case we return an empty payment failure. if sourceIdx == nil { return paymentFailure{} } - return paymentFailure{ + info := paymentFailure{ sourceIdx: tlv.SomeRecordT( tlv.NewPrimitiveRecord[tlv.TlvType0]( uint8(*sourceIdx), - )), - msg: tlv.SomeRecordT( - tlv.NewRecordT[tlv.TlvType1]( - failureMessage{failureMsg}, ), ), } + + if failureMsg != nil { + info.msg = tlv.SomeRecordT( + tlv.NewRecordT[tlv.TlvType1]( + failureMessage{failureMsg}, + ), + ) + } + + return info } // paymentFailure holds additional information about a payment failure.