lnd.xprv/htlcswitch
Olaoluwa Osuntokun 7037d55f65
htlcswitch: perform fee related checks at forwarding time
In this commit, we fix a very old, lingering bug within the link. When
accepting an HTLC we are meant to validate the fee against the
constraints of the *outgoing* link. This is due to the fact that we're
offering a payment transit service on our outgoing link. Before this
commit, we would use the policies of the *incoming* link. This would at
times lead to odd routing errors as we would go to route, get an error
update and then route again, repeating the process.

With this commit, we'll properly use the incoming link for timelock
related constraints, and the outgoing link for fee related constraints.
We do this by introducing a new HtlcSatisfiesPolicy method in the link.
This method should return a non-nil error if the link can carry the HTLC
as it satisfies its current forwarding policy. We'll use this method now
at *forwarding* time to ensure that we only forward to links that
actually accept the policy. This fixes a number of bugs that existed
before that could result in a link accepting an HTLC that actually
violated its policy. In the case that the policy is violated for *all*
links, we take care to return the error returned by the *target* link so
the caller can update their sending accordingly.

In this commit, we also remove the prior linkControl channel in the
channelLink. Instead, of sending a message to update the internal link
policy, we'll use a mutex in place. This simplifies the code, and also
adds some necessary refactoring in anticipation of the next follow up
commit.
2018-04-06 14:52:00 -07:00
..
circuit_map.go htlcswitch/circuit_map: add Config and Reextract obfuscators 2018-03-13 16:33:27 -07:00
circuit_test.go htlcswitch/circuit_test: use circuit map config and test rextraction 2018-03-13 16:33:28 -07:00
circuit.go htlcswitch/circuit: add half adds to circuit map 2018-03-09 21:08:42 -08:00
failure.go htlcswitch/failure: add Reextract to SphinxErrorEncrypter 2018-03-13 16:33:28 -07:00
interfaces.go htlcswitch: perform fee related checks at forwarding time 2018-04-06 14:52:00 -07:00
iterator.go htlcswitch/iterator: extract error encrypter from ephemeral key 2018-03-13 16:33:28 -07:00
link_test.go htlcswitch: modify the SendMessage method on the Peer interface to optionally block 2018-04-04 17:36:44 -07:00
link.go htlcswitch: perform fee related checks at forwarding time 2018-04-06 14:52:00 -07:00
log.go htlcswitch: add additional comments and logging 2018-03-12 18:58:44 -07:00
mailbox_test.go htlcswitch/mailbox_test: adds checks for reset and replay of pkts 2018-03-09 21:08:43 -08:00
mailbox.go htlcswitch: add additional comments and logging 2018-03-12 18:58:44 -07:00
mock.go htlcswitch: modify the SendMessage method on the Peer interface to optionally block 2018-04-04 17:36:44 -07:00
packet.go htlcswitch/packet: adds serialization to htlcPacket 2018-03-09 21:08:44 -08:00
queue_test.go htlcswitch: Remove obsolete fields from htlcPacket. 2017-12-14 17:53:58 -08:00
queue.go htlcswitch: fix alignment of the packetQueue's fields for 32-bit systems (#507) 2017-12-22 16:32:11 +01:00
sequencer.go build+multi: switch from bolt to bbolt 2018-03-10 19:01:13 -08:00
switch_test.go htlcswitch/switch_test: change forward() -> send() 2018-03-09 21:08:44 -08:00
switch.go htlcswitch: perform fee related checks at forwarding time 2018-04-06 14:52:00 -07:00
test_utils.go htlcswitch/test_utils: DecodeOnionObfuscator - ExtractErrorEncrypter 2018-03-13 16:33:29 -07:00