Commit Graph

24 Commits

Author SHA1 Message Date
carla
74e0d545fe
htlcswitch: add linkError field to htlcpacket
This commit adds a linkError field to track the value of failures
which occur at our node. This field is set when local payments or
multi hop htlcs fail in the switch or on our outgoing link. This
addition is required for the addition of a htlc notifier which will
notify these failures in handleDownstreamPacket.

The passing of link error to failAddPacket removes the need for an
additional error field, because the link error's failure detail will
contain any additional metadata. In the places where the failure detail
does not cover all the metadata that was previously supplied by addr
err, the error is logged before calling failAddPacket so that this
change does not reduce the amount of information we log.
2020-02-06 19:43:29 +02:00
carla
9390d3bbfd
htlcswitch: replace outgoing failure with interface
Add a FailureDetail interface which allows us have different kinds of
failures for link errors. This interface will be used to cover failures
that occur when on invoice payment, because the errors have already
been enumerated in the invoices package.
2020-02-06 19:43:23 +02:00
carla
bdd9411bbd
htlcswitch: rename FailureDetail to OutgoingFailure
Rename FailureDetail in a separate commit so that a FailureDetail
interface can be introduced in the following commit.
OutgoingFailureOnionDecode is renamed to OutgoingFailureDecodeError
to specifically indicate that we could not decode the wire
failure that our payment experienced.
2020-02-06 19:43:14 +02:00
carla
ec099bf5dd
htlcswitch: remove extramsg string from ForwardingError
Remove the extramsg field in ForwardingError because
it has been replaced with detailed link errors.
2020-01-14 15:23:11 +02:00
carla
f430fd50c5
htlcswitch: use LinkError for internal errors
Update the ChannelLink interface to specifically
return the LinkError struct. This error implements
the ClearTextError interface, so will be picked
up as a routing realted error by the router.

With LinkErrors implemented, the switch now
returns a LinkError for all failures on our
incoming/outgoing link and ForwardingError when
the failure occurs down the line.
2020-01-14 15:21:15 +02:00
carla
6a83b06ab7
htlcswitch: add LinkError implementation of ClearTextError
This change introduces a LinkError implementation
of the ClearTextError interface. This error is intended
to represent failures which occur on our incoming and
outgoing link when sending, receiving and forwarding
htlcs. Paired with ForwardingError, which is represents
failures that did not occur at our node, this error
covers all non-opaque errors that the switch experiences.
2020-01-14 15:07:41 +02:00
carla
102f9b003f
htlcswitch: add ClearTextError interface
This commit adds a ClearTextError interface
which is implemented by non-opaque errors that
we know the underlying wire failure message for.
This interface is implemented by ForwardingErrors,
because we can fully decrypt the onion blob to
obtain the underlying failure reason. This interface
will also be implemented by errors which originate
at our node in following commits, because we know
the failure reason when we fail the htlc.

The lnwire interface is un-embedded in the
ForwardingError struct in favour of implementing
this interface. This change is made to protect
against accidental passing of a ForwardingError
to the wire, where the embedded FailureMessage
interface will present as wire failure but
will not serialize properly.
2020-01-14 15:07:41 +02:00
carla
6f0a342f92
htlcswitch: add ForwardingError constructor
Add a constructor for the creation of forwarding errors.
A special constructor is added for the case where we have
an unknown wire failure, and must set a nil failure message.
2020-01-14 15:07:29 +02:00
Joost Jager
53076880f1
htlcswitch: report failure source index for forwarding errors 2019-11-12 14:13:29 +01:00
Joost Jager
e54b24289f
htlcswitch: move hop iterator into htlcswitch/hop package
Prepares for onion blob decoding outside of htlcswitch.
2019-09-05 15:30:31 +02:00
Joost Jager
2726f50d7c
htlcswitch: do not consider unknown failures an error 2019-07-11 19:49:49 +02:00
Joost Jager
0cdae56d28
htlcswitch+routing: make error decryption mockable 2019-07-11 10:37:28 +02:00
Joost Jager
2b47632b26
htlcswitch+routing+routerrpc: return error source as index 2019-07-11 10:37:26 +02:00
Olaoluwa Osuntokun
c67ca0a329
htlcswitch: add new EncryptMalformedError method to ErrorEncrypter
In this commit, we add a new method to the ErrorEncrypter interface:
`EncryptMalformedError`. This takes a raw error (no encryption or MAC),
and encrypts it as if we were the originator of this error. This will be
used by the switch to convert malformed fail errors to regular fully
encrypted errors.
2019-04-30 20:13:35 -07:00
Conner Fromknecht
1ded697e8d
multi: sort import paths with gofmt 2018-08-02 18:20:49 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Conner Fromknecht
dccab0a654
htlcswitch/failure: add Reextract to SphinxErrorEncrypter 2018-03-13 16:33:28 -07:00
Conner Fromknecht
fcf08382f7
htlcswitch/failure: add Encode/Decode to ErrorEncrypter 2018-03-08 21:12:03 -05:00
Olaoluwa Osuntokun
51d04e8922
htlcswitch: add new ExtraMsg field to ForwardingError
This commit adds a new field to the ForwardingError struct: ExtraMsg.
The purpose of this field is to allow the htlcswitch to tack on
additional error context to ForwardingError messages returned to the L3
router.
2017-10-16 18:15:51 -07:00
Olaoluwa Osuntokun
2eaa9fd683
htlcswitch: fix linter error 2017-10-10 22:19:29 -07:00
Olaoluwa Osuntokun
12ae63101d
Htlcswitch: rename Deobfuscator and Obfuscator interfaces
This commit renames the Deobfuscator interface to ErrorDecrypter and
the Obfuscator interface to ErrorEncrypter. With this rename, the
purpose of these two interfaces are a bit clearer.

Additionally, DecryptError (which was formerly Deobfuscate) now
directly returns an ForwardingError type instead of the
lnwire.FailureMessage.
2017-10-10 22:19:19 -07:00
Olaoluwa Osuntokun
30a46291f8
htlcswitch: introduce new ForwardingError type
This commit introduces a new type to the package: ForwardingError. It
wraps an existing lnwire.FailureMessage interface, and also includes
the _source_ of the error message. By including the source of the
message, the router can now prune the set of available routes down in
order to reduce the number of subsequent failures based on the source
of the error and the type of the error itself.
2017-10-10 22:19:18 -07:00
Olaoluwa Osuntokun
a04fa76a4c
lnwire+htlcswitch: minor grammatical, formatting fixes after error PR 2017-07-14 20:08:37 -07:00
Andrey Samokhvalov
2d378b3280 htlcswitch+router: add onion error obfuscation
Within the network, it's important that when an HTLC forwarding failure
occurs, the recipient is notified in a timely manner in order to ensure
that errors are graceful and not unknown. For that reason with
accordance to BOLT №4 onion failure obfuscation have been added.
2017-07-14 19:08:04 -07:00