mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
htlcswitch/link: return InvalidOnionPayload failure
This commit modifies the link return an InvalidOnionPayload failure when it cannot parse a TLV payload. The offset is left at zero, since its unclear how useful it will be in practice and would require some significant reworkings of the abstractions in the tlv package. TODO: add unit tests. currently none of the test unit infrastructure is setup to handle TLV payloads, so this would require implementing a separate mock iterator for TLV payloads that also supports injecting invalid payloads. Deferring this non-trival effor till a later date
This commit is contained in:
parent
0fc506e044
commit
3455f7965d
1 changed files with 15 additions and 4 deletions
|
@ -2646,12 +2646,23 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
|||
fwdInfo, err := chanIterator.ForwardingInstructions()
|
||||
if err != nil {
|
||||
// If we're unable to process the onion payload, or we
|
||||
// we received malformed TLV stream, then we should
|
||||
// send an error back to the caller so the HTLC can be
|
||||
// canceled.
|
||||
// received invalid onion payload failure, then we
|
||||
// should send an error back to the caller so the HTLC
|
||||
// can be canceled.
|
||||
var failedType uint64
|
||||
if e, ok := err.(hop.ErrInvalidPayload); ok {
|
||||
failedType = uint64(e.Type)
|
||||
}
|
||||
|
||||
// TODO: currently none of the test unit infrastructure
|
||||
// is setup to handle TLV payloads, so testing this
|
||||
// would require implementing a separate mock iterator
|
||||
// for TLV payloads that also supports injecting invalid
|
||||
// payloads. Deferring this non-trival effort till a
|
||||
// later date
|
||||
l.sendHTLCError(
|
||||
pd.HtlcIndex,
|
||||
lnwire.NewInvalidOnionVersion(onionBlob[:]),
|
||||
lnwire.NewInvalidOnionPayload(failedType, 0),
|
||||
obfuscator, pd.SourceRef,
|
||||
)
|
||||
needUpdate = true
|
||||
|
|
Loading…
Add table
Reference in a new issue