Commit Graph

16 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
7b4c150983
htlcswitch: add new incoming+outgoing timeout fields to htlcPacket 2018-06-26 17:29:41 -07:00
Conner Fromknecht
e4fb420665
htlcswitch/packet: adds serialization to htlcPacket 2018-03-09 21:08:44 -08:00
Olaoluwa Osuntokun
157e052958
htlcswitch: add the incoming payment amount to the htlcPacket
We’ll need this value within the link+switch in order to fully populate
the forwarding event that will be generated if this HTLC circuit is
successfully completed.
2018-03-06 13:56:10 -05:00
Olaoluwa Osuntokun
9cb3657314
htlcswitch: add new ProcessContractResolution method
In this commit, we add a new method: ProcessContractResolution. This
will be used by entities of the contract court package to notify us
whenever they discover that we can resolve an incoming contract
off-chain after the outgoing contract was fully resolved on-chain.

We’ll take a contractcourt.ResolutionMsg and map it to the proper
internal package so we can fully resolve an active circuit.
2018-01-22 19:19:38 -08:00
Jim Posen
88dc73adb0 htlcswitch: Fix failure error handling on outgoing adds. 2017-12-14 17:53:58 -08:00
Jim Posen
6ea533275c htlcswitch: Remove obsolete fields from htlcPacket. 2017-12-14 17:53:58 -08:00
Jim Posen
4a29fbdab2 htlcswitch: Rename htlcPacket fields for clarity.
The src/dest terminology for routing packets is kind of confusing
because the source HTLC may not be the source of the packet for
settles/fails traversing the circuit in the opposite direction. This
changes the nomenclature to incoming/outgoing and always references
the HTLCs themselves.
2017-12-14 17:53:58 -08:00
Jim Posen
1328e61c00 htlcswitch: Change circuit map keys to (channel ID, HTLC ID).
This changes the circuit map internals and API to reference circuits
by a primary key of (channel ID, HTLC ID) instead of paymnet
hash. This is because each circuit has a unique offered HTLC, but
there may be multiple circuits for a payment hash with different
source or destination channels.
2017-12-14 17:53:58 -08:00
Jim Posen
bc8d674958 htlcswitch: Remove constructor functions for htlcPacket.
The constructor functions have no additional logic other than passing
function parameters into struct fields. Given the large function
signatures, it is more clear to directly construct the htlcPacket in
client code than call a function with lots of positional arguments.
2017-12-14 17:53:58 -08:00
Olaoluwa Osuntokun
de3af9b0c0
htlcswitch: modify Bandwidth() method on links to use more accurate accoutning
In this commit, we modify the existing implementation of the
Bandwidth() method on the default ChannelLink implementation to use
much tighter accounting. Before this commit, there was a bug wherein if
the link restarted with pending un-settled HTLC’s, and one of them was
settled, then the bandwidth wouldn’t properly be updated to reflect
this fact.

To fix this, we’ve done away with the manual accounting and instead
grab the current balances from two sources: the set of active HTLC’s
within the overflow queue, and the report from the link itself which
includes the pending HTLC’s and factors in the amount we’d need to (or
not need to) pay in fees for each HTLC.
2017-11-10 19:51:02 -08: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
8a51b1a0c6
Htlcswitch: switch all accounting and forwarding decisions to use mSAT's 2017-08-22 00:53:04 -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
Olaoluwa Osuntokun
1f5a4fcb8e
htlcswitch: change over all internal indexes to use short channel ID's 2017-06-16 23:49:46 +02:00
Andrey Samokhvalov
b86409cdb3 htlcswitch: recreate hlcswitch from scratch
This commit gives the start for making the htlc manager and htlc switch
testable. The testability of htlc switch have been achieved by mocking
all external subsystems. The concrete list of updates:

1. create standalone package for htlc switch.
2. add "ChannelLink" interface, which represent the previous htlc link.
3. add "Peer" interface, which represent the remote node inside our
subsystem.
4. add htlc switch config to htlc switch susbystem, which stores the
handlers which are not elongs to any of the above interfaces.

With this commit we are able test htlc switch even without having
the concrete implementation of Peer, ChannelLink structures, they will
be added later.
2017-05-31 11:06:08 -07:00