Skip to content

Commit aa9abb3

Browse files
committed
routing: make sure failure message is valid
1 parent a450d85 commit aa9abb3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

routing/missioncontrol.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,21 +837,29 @@ func (n *namespacedDB) purge() error {
837837
func newPaymentFailure(sourceIdx *int,
838838
failureMsg lnwire.FailureMessage) paymentFailure {
839839

840+
// If we can't identify a failure source, we also won't have a decrypted
841+
// failure message. In this case we return an empty payment failure.
840842
if sourceIdx == nil {
841843
return paymentFailure{}
842844
}
843845

844-
return paymentFailure{
846+
info := paymentFailure{
845847
sourceIdx: tlv.SomeRecordT(
846848
tlv.NewPrimitiveRecord[tlv.TlvType0](
847849
uint8(*sourceIdx),
848-
)),
849-
msg: tlv.SomeRecordT(
850+
),
851+
),
852+
}
853+
854+
if failureMsg != nil {
855+
info.msg = tlv.SomeRecordT(
850856
tlv.NewRecordT[tlv.TlvType1](
851857
failureMessage{failureMsg},
852858
),
853-
),
859+
)
854860
}
861+
862+
return info
855863
}
856864

857865
// paymentFailure holds additional information about a payment failure.

0 commit comments

Comments
 (0)