mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-31 02:01:46 +02:00
routing: make sure failure message is valid
This commit is contained in:
parent
a450d85309
commit
aa9abb3d96
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user