Commit Graph

23 Commits

Author SHA1 Message Date
Johan T. Halseth
4dfb4547a0
htlcswitch: remove unused Disconnect from Peer interface 2018-05-25 06:58:24 +02:00
Conner Fromknecht
b5591cd66c
htlcswitch/interfaces: return err from UpdateShortChanID 2018-05-09 16:06:49 -07:00
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
Olaoluwa Osuntokun
e30881a14c
Merge pull request #1033 from stevenroose/close-offline
rpcserver: Clarify failure closing offline channel
2018-04-06 12:20:30 -07:00
Steven Roose
445924b7a9 rpcserver: Clarify failure closing offline channel 2018-04-06 10:42:14 +02:00
Olaoluwa Osuntokun
ca9174e166
peer: extend SendMessage to allow callers to block until msg is sent 2018-04-04 17:43:57 -07:00
Olaoluwa Osuntokun
f53a99e18e
htlcswitch: modify the SendMessage method on the Peer interface to optionally block
In this commit, add a new argument to the SendMessage method to allow
callers to request that the method block until the message has been sent
on the socket to the remote peer.
2018-04-04 17:36:44 -07:00
Conner Fromknecht
2c3d35bb40
htlcswitch/interfaces: have HandleSwitchPacket return an error 2018-03-09 21:08:43 -08:00
Olaoluwa Osuntokun
ad522a72c1
htlcswitch: add new ticker in switch to batch log forwarding events
In this commit, we extend the switch as is, to record details
concerning settled payment circuits. To do this, we introduce a new
interface to the package: the ForwardingLog. This is a tiny interface
that simply lets us abstract away the details of the storage backing of
the forwarding log.

Each time we receive a successful HTLC settle, we’ll log the full
details (chans, fees, time) as a pending forwarding log entry. Every 15
seconds, we’ll then batch flush out these entries to disk. When we’re
exiting, we’ll try to flush out all entries to ensure everything gets
recorded to disk.
2018-03-06 13:56:11 -05:00
practicalswift
b8e1351cf3 multi: fix some recently introduced typos 2018-02-18 15:27:29 -08:00
Daniel McNally
8543497dcc multi: fixing it's/its typos in comments 2018-02-06 19:13:07 -08:00
Olaoluwa Osuntokun
30dbbd69a0
funding+htlcswitch: dynamically update short chan id of existing link
In this commit, we fix an existing bug that would result in some
payments getting “stuck”. This would happen if one side restarted
before the channel was fully locked in. In this case, since upon
re-connection, the link will get added to the switch with a *short
channel ID of zero*. If A then tries to make a multi-hop payment
through B, B will fail to forward the payment, as it’ll mistakenly
think that the payment originated from a local-subsystem as the channel
ID is zero. A short channel ID of zero is used to map local payments
back to their caller.

With fix this by allowing the funding manager to dynamically update the
short channel ID of a link after it discovers the short channel ID.

In this commit, we fix a second instance of reported “stuck” payments
by users.
2018-02-03 18:14:15 -08:00
Olaoluwa Osuntokun
36956d390f
htlcswitch: add new method to the ChannelLink interface, EligibleToForward
In this commit, we add a new method to the ChanneLink interface:
EligibleToForward. This method allows a link to be added to the switch,
but in an intermediate state which indicates that it isn’t yet ready to
forward any incoming HTLC’s.
2017-12-06 16:42:57 -08:00
Olaoluwa Osuntokun
25082f0b5b
htlcswitch: update WipeChannel on Peer interface to simply take the chanPoint
The WipeChannel method doesn’t need to take the channel itself, as any
relevant indexes should be able to be queried based on the channel
point along.
2017-11-23 23:10:10 -06:00
Olaoluwa Osuntokun
b6f64932c2
htlcswitch: face race condition in unit tests by returning invoice
In this commit we modify the primary InvoiceRegistry interface within
the package to instead return a direct value for LookupInvoice rather
than a pointer. This fixes an existing race condition wherein a caller
could modify or read the value of the returned invoice.
2017-11-11 16:09:29 -08:00
Olaoluwa Osuntokun
70ed50738a
htlcswitch: utilize memoryMailBox within link, no longer spawn goroutine to forward in switch
In this commit, we’ve modified the link and the switch to start to use
the new mailBox in place of the existing synchronous message send
directly into the link’s upstream/downstream channels. With his change,
we no longer need to spawn a new goroutine each time an HTLC needs to
be forwarded, or a user payment is initiated.
2017-11-10 19:51:02 -08:00
Olaoluwa Osuntokun
8a51b1a0c6
Htlcswitch: switch all accounting and forwarding decisions to use mSAT's 2017-08-22 00:53:04 -07:00
Andrey Samokhvalov
ef73062c14 peer+server+htlcswitch: add reason to disconnnect function
In order to recognize exact reason of the disconnect the additional
field have been added in the disconnect function.
2017-07-14 19:08:04 -07:00
Olaoluwa Osuntokun
399d193e2c
htlcswitch: add a new UpdateFeePolicy to ChannelLink interface
This commit adds a new method to the ChannelLink interface which is
meant to allow outside sub-system to update the forwarding policy of a
channel. This can be triggered either by a new RPC method, or
automatically by some sort of control system which seeks to optimize
fee revenue, or block off channels, etc.
2017-06-17 00:01:10 +02:00
Olaoluwa Osuntokun
4c7af9f16d
htlcswitch: eliminate HopID in favor of a [33]byte for compressed pub keys 2017-06-16 23:38:52 +02:00
Olaoluwa Osuntokun
ea57a94c2e
htlcswitch: add a ShortChanID method to the ChannelLink interface 2017-06-16 23:32:47 +02:00
Andrey Samokhvalov
7f572fc155 htlcswitch: add channel link config
Step №1 in making htlcManager (aka channelLink) testable:
Start use config which will allow as mock/stub external subsystems.
2017-05-31 11:06:08 -07: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