multi: allow invalid tlv data when decoding payment fail info
Older payments might have a invalid tlv stream, we now catch this case and add a unit test.
This commit is contained in:
5 files changed
+139
-3
No files matched your search
@@ -169,7 +169,7 @@ func (a *ChannelUpdate1) Decode(r io.Reader, _ uint32) error {
|
||||
var inboundFee = a.InboundFee.Zero()
|
||||
typeMap, err := tlvRecords.ExtractRecords(&inboundFee)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %w", ErrParsingExtraTLVBytes, err)
|
||||
}
|
||||
|
||||
val, ok := typeMap[a.InboundFee.TlvType()]
|
||||
|
||||
@@ -6,6 +6,13 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrParsingExtraTLVBytes is returned when we attempt to parse
|
||||
// extra opaque bytes as a TLV stream, but the parsing fails due to
|
||||
// and invalid TLV stream.
|
||||
ErrParsingExtraTLVBytes = fmt.Errorf("error parsing extra TLV bytes")
|
||||
)
|
||||
|
||||
// FundingError represents a set of errors that can be encountered and sent
|
||||
// during the funding workflow.
|
||||
type FundingError uint8
|
||||
|
||||
@@ -1361,7 +1361,7 @@ func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error) {
|
||||
case Serializable:
|
||||
if err := f.Decode(r, pver); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode error "+
|
||||
"update (type=%T): %v", failure, err)
|
||||
"update (type=%T): %w", failure, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user