Commit Graph

123 Commits

Author SHA1 Message Date
Joost Jager
2b47632b26
htlcswitch+routing+routerrpc: return error source as index 2019-07-11 10:37:26 +02:00
Johan T. Halseth
2cc778d309
htlcswitch/switch: use paymentResultStore to keep track of results 2019-06-07 16:53:32 +02:00
Johan T. Halseth
2dea790b55
multi: make GetPaymentResult take payment hash
Used for logging in the switch, and when we remove the pending payments,
only the router will have the hash stored across restarts.
2019-06-07 16:53:32 +02:00
Johan T. Halseth
d027e10201
htlcswitch+channeldb: move control tower to channeldb 2019-05-27 20:18:56 +02:00
Johan T. Halseth
cd02c22977
htlcswitch+router: move deobfuscator creation to GetPaymentResult call
In this commit we move handing the deobfuscator from the router to the
switch from when the payment is initiated, to when the result is
queried.

We do this because only the router can recreate the deobfuscator after a
restart, and we are preparing for being able to handle results across
restarts.

Since the deobfuscator cannot be nil anymore, we can also get rid of
that special case.
2019-05-16 23:56:12 +02:00
Johan T. Halseth
f99d0c4c68
htlcswitch/switch+payment_result: define networkResult, extractResult 2019-05-16 23:56:12 +02:00
Johan T. Halseth
ec087a9f73
htlcswitch+router: define PaymentResult, GetPaymentResult
This lets us distinguish an critical error from a actual payment result
(success or failure). This is important since we know that we can only
attempt another payment when a final result from the previous payment
attempt is received.
2019-05-16 23:56:12 +02:00
Johan T. Halseth
be129eb7c7
htlcswitch/switch: remove numPendingPayments only used in tests 2019-05-16 23:56:12 +02:00
Johan T. Halseth
cff4d3547d
htlcswitch/switch: clarify paymentID uniqueness
With the following commits, it'll become important to not resuse
paymentIDs, since there is no way to tell whether the HTLC in question
has already been forwarded and settled/failed.

We clarify this in the SendHTLC comments, and alter the tests to not
attempt to resend an HTLC with a duplicate payment ID.
2019-05-16 23:56:11 +02:00
Johan T. Halseth
bbbe3a37f5
htlcswitch/switch: make parseFailedPayment not dependent on pkt
We will later persist the fields necessary to decrypt a received error.
2019-05-16 23:56:11 +02:00
Johan T. Halseth
c9e8ff6a34
switch+router+server: move NextPaymentID to router
This commit moves the responsibility of generating a unique payment ID
from the switch to the router. This will make it easier for the router
to keep track of which HTLCs were successfully forwarded onto the
network, as it can query the switch for existing HTLCs as long as the
paymentIDs are kept.

The router is expected to maintain a map from paymentHash->paymentID,
such that they can be replayed on restart. This also lets the router
check the status of a sent payment after a restart, by querying the
switch for the paymentID in question.
2019-05-16 23:56:06 +02:00
Olaoluwa Osuntokun
a8fa4094ba
Merge pull request #3027 from Roasbeef/new-onion-structs
router+build: update to the latest version of lightning-onion
2019-05-03 13:30:41 -07:00
Joost Jager
f5f6a52ed8
htlcswitch: check channel policy for local htlcs 2019-05-03 12:22:36 +02:00
Olaoluwa Osuntokun
be63c7d286
htlcswitch: properly convert multi-hop malformed HTLC failures
In this commit, we now properly convert multi-hop malformed HTLC
failures. Before this commit, we wouldn't properly add a layer of
encryption to these errors meaning that the destination would fail to
decrypt the error as it was actually plaintext.

To remedy this, we'll now check if we need to convert an error, and if
so we'll encrypt it as if it we were the source of the error (the true
source is our direct channel peer).
2019-04-30 20:13:37 -07:00
Olaoluwa Osuntokun
cdc4aca40f
htlcswitch: properly handle direct link malformed HTLC failures
In this commit, we fix a bug that caused us to be unable to properly
handle malformed HTLC failures from our direct link. Before this commit,
we would attempt to decrypt it and fail since it wasn't well formed. In
this commit, if its an error for a local payment, and it needed to be
converted, then we'll decode it w/o decrypting since it's already
plaintext.
2019-04-30 20:13:36 -07:00
cryptagoras
a50428ca96 htlcswitch/switch: log target node on insufficient cap error 2019-03-25 18:25:58 +02:00
Valentine Wallace
bdd8ce14c9 switch: notify the ChannelNotifier on newly active/inactive channels. 2019-02-05 18:17:54 -08:00
Olaoluwa Osuntokun
9c59ac4383
Merge pull request #2397 from halseth/reject-commitment-expected-fee-reset-bug
[bugfix] Process fee updates as any other update message
2019-01-14 17:06:27 -08:00
Conner Fromknecht
164250d1cd
htlcswitch/switch: check EligibleToForward in HasActiveLink
This commit modifies the behavior of the
HasActiveLink method within the switch to
only return true if the link is in the
link index and is eligible to forward
HTLCs.

The prior version returns true whenever
the link is found in the link index,
which may return true for pending
channels that are not actually active.
2019-01-10 16:34:02 -08:00
Johan T. Halseth
480f43f1dc
lnwallet/channel: add lnwire<->PaymentDescriptor FeeUpdate conversion
This commit adds conversion between the lnwire.UpdateFee message and the
new FeeUpdate PaymentDescriptor. We re-purpose the existing Amount field
in the PaymentDescriptor stuct to hold the feerate.
2019-01-10 12:26:33 +01:00
Joost Jager
6c027e2bc9 htlcswitch: remove lnrpc dependency
This commits removes an unwanted dependency that prevents
moving parts of rpcserver to a sub server.
2019-01-03 09:07:56 +01:00
Olaoluwa Osuntokun
1fd3aac925
multi: switch from bolt packge to bbolt package for all imports 2018-11-29 20:33:49 -08:00
Alex Bosworth
2d8e239fe9
Move pewpew diff log into debug log 2018-11-01 17:46:03 -07:00
Olaoluwa Osuntokun
d8e6085c17
multi: update to go 1.11 gofmt 2018-10-07 14:37:38 +09:00
Wilmer Paulino
33dda07b62
htlcswitch: return concrete error from GetLinksByInterface 2018-08-28 20:34:18 -07:00
Conner Fromknecht
9c5c1d0cb5
htlcswitch/switch: prevent panic for unknown error decryptor 2018-08-22 10:26:27 -07:00
Conner Fromknecht
b59fea460a
htlcswitch/switch: make local response handling async
This commit moves the logic handling responses to
locally-initiated payments to be asynchronous. The
reordering of operations into handleLocalDispatch
brings a serious performance burden to the switch's
main event loop. However, the at-most once semantics
of circuit map and idempotency of cleanup methods
allows concurrent operations to run in parallel.

Prior to this commit, the async_payments_benchmark
would timeout due to the forcibly serial nature of
the prior design. With this change, there is no
perceptible difference in the benchmark OMM, even
though we've added two extra db calls.
2018-08-22 10:26:26 -07:00
Conner Fromknecht
2dd8f07014
htlcswitch/switch: use non-strict PaymentControl 2018-08-21 19:23:25 -07:00
Conner Fromknecht
d6083e0d66
htlcswitch/switch: reorder persistent calls and app ntfn...
for Settle/Fail responses.
2018-08-21 19:23:24 -07:00
Vadym Popov
21fc7aa829
htlcswitch: integration of control tower to htlc switch 2018-08-21 19:23:22 -07:00
Olaoluwa Osuntokun
f028eaa152
Merge pull request #1698 from cfromknecht/switch-fwdpkg-cleanup
[htlcswitch] fwdpkg cleanup
2018-08-21 18:56:15 -07:00
Conner Fromknecht
6a8507cfb5
htlcswitch/switch: ignore pending/local responses on reforward 2018-08-21 17:13:58 -07:00
Conner Fromknecht
4e093a6cd2
htlcswitch/switch: shutdown links concurrently 2018-08-20 22:05:05 -07:00
Wilmer Paulino
44e97ee72f htlcswitch: remove no longer needed destNode field in htlcPacket 2018-08-20 21:04:52 -07:00
Wilmer Paulino
7535371238 htlcswitch: implement strict forwarding for locally dispatched payments
In this commit, we address an issue that could arise when using the
SendToRoute RPC. In this RPC, we specify the exact hops that a payment
should take. However, within the switch, we would set a constraint for
the first hop to be any hop as long as the first peer was at the end of
it. This would cause discrepancies when attempting to use the RPC as the
payment would actually go through another hop with the same peer. We fix
this by explicitly specifying the channel ID of the first hop.

Fixes #1500.
Fixes #1515.
2018-08-20 21:04:47 -07:00
Conner Fromknecht
4f2137eafc
htlcswitch/switch: set SourceRef of failed packets 2018-08-20 18:47:03 -07:00
Conner Fromknecht
48b616629a
htlcswitch/switch: remove unnecessary defer closure 2018-08-18 20:19:17 -07:00
Conner Fromknecht
9047eee2f1
htlcswitch/switch: adds concrete ErrSwitchExisting 2018-08-18 20:19:17 -07:00
Conner Fromknecht
0d49a60924
htlcswitch/switch: remove go-errors pkg 2018-08-18 20:19:17 -07:00
Johan T. Halseth
887722f38f
htlcswitch/switch: add method HasActiveLink 2018-08-17 23:24:12 +02:00
Olaoluwa Osuntokun
7a113d469b
Merge pull request #1551 from cfromknecht/switch-revert-replace-link
[htlcswitch]: revert replace link, ensure removed links are stopped
2018-08-13 21:44:42 -07:00
Conner Fromknecht
f84cd14b12
htlcswitch/switch: permit link shutdown mid-forwarding
In this commit, we thread through a link's quit channel into
routeAsync, the primary helper method allowing links to send
htlcPackets through the switch. This is intended to remove
deadlocks from happening, where the link is synchronously
blocking on forwarding packets to the switch, but also
needs to shutdown.
2018-08-10 11:42:26 -07:00
Conner Fromknecht
c78e81d32b
htlcswitch/switch: synchronous stop of links after removal 2018-08-10 11:42:25 -07:00
Conner Fromknecht
1113684dc3
Revert "htlcswitch: in event of duplicate link add, prefer newer link"
This reverts commit e60d2b774a35e446081f9be2d4901925cac05379.
2018-08-10 11:42:20 -07:00
Valentine Wallace
1ffc3bb82e
multi: update to latest RegisterBlockEpochNtfn interface 2018-08-10 01:08:57 -07:00
Conner Fromknecht
e3253a4f3b
htlcswitch/switch: add log/fwd event tickers to Config 2018-08-09 02:48:07 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Olaoluwa Osuntokun
d889644f52
htlcswitch: use Batch for calls within ackSettleFail 2018-06-30 17:15:31 -05:00
Olaoluwa Osuntokun
bdecc5bea9
htlcswitch: update forwarding policy verification to use new time lock info 2018-06-26 17:29:42 -07:00
Olaoluwa Osuntokun
19a0eab804
htlcswitch: in removeLink use new goroutine to stop existing link
In this commit, we modify the removeLink method to be more asynchronous.
Before this commit, we would attempt to block until the peer exits.
However, it may be the case that at times time, then target link is
attempting to forward a batch of packets to the switch (forwardBatch).
Atm, this method doesn't pass in an external context/quit, so we can't
cancel this message/request. As a result, we'll now ensure that
`removeLink` doesn't block, so we can resume the switch's main loop as
soon as possible.
2018-06-25 16:04:24 -07:00