Commit Graph

204 Commits

Author SHA1 Message Date
Conner Fromknecht
f50649d21b
htlcswitch/link: remove overflow queue
This commit removes the overflowQueue from the link. We do so in order
to promote better UX for senders, so that HTLCs are failed faster when
the commitment is full. This gives the sender the opportunity to try
another, more open path, rather than perceive the HTLC as being stuck.

At the same time, we remove the total number of active goroutines in lnd
by a factor of N where N is the number of active channels.
2020-04-07 13:20:36 -07:00
Conner Fromknecht
028345daea
htlcswithc/link_test: rm unused arg from generateHtlc
Linter started complaining.
2020-04-07 11:53:36 -07:00
Conner Fromknecht
2c3641e915
htlcswitch/link_test: fix preimage assertion
This flakes locally for me on darwin.
2020-04-07 11:53:15 -07:00
Conner Fromknecht
ec784db511
multi: remove returned error from WipeChannel
The linter complains about not checking the return value from
WipeChannel in certain places. Instead of checking we simply remove the
returned error because the in-memory modifications cannot fail.
2020-04-02 17:39:29 -07:00
nsa
966cd2112c multi: link notifies subscribers of ActiveLinkEvent, rpc ignores 2020-03-27 08:49:46 -04:00
nsa
f757bf48bd channeldb: use RemoteCommitment in NextLocalHtlcIndex
This commit changes the fallback in NextLocalHtlcIndex to
RemoteCommitment since the LocalHtlcIndex field lags behind
on the LocalCommitment. Without this bug fix, open circuits
would get prematurely trimmed, resulting in more erroneous
logs. A test case is included to check that the fix works.
2020-03-25 11:49:16 -04:00
Olaoluwa Osuntokun
4e68914e9d
htlcswitch: convert to use new kvdb abstraction 2020-03-18 19:34:55 -07:00
Johan T. Halseth
5d5069c477
Merge pull request #3691 from halseth/link-bandwitch-amt-aware
lnwallet: Make available balance HTLC fee aware
2020-02-20 17:56:20 +01:00
carla
abf780bf03
multi: add htlcNotifier interface to switch and link
In this commit, a htlcNotifier interface is added to allow for easy
unit testing. Instances of the HtlcNotifier are added to the server,
switch and link.
2020-02-19 17:50:28 +02:00
Johan T. Halseth
9ff79ae595
lnwallet/channel: account for HTLC fee when reporting available balance 2020-02-19 12:27:42 +01:00
carla
c08377d303
htlcswitch/test: replace mock server delta with constant 2020-01-30 10:02:44 +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
b5a2d75465
htlcswitch+routing: type check on ClearTextError
Update the type check used for checking local payment
failures to check on the ClearTextError interface rather
than on the ForwardingError type. This change prepares
for splitting payment errors up into Link and Forwarding
errors.
2020-01-14 15:07:42 +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
Johan T. Halseth
3711597fef
input: remove duplicate commit weight constant 2020-01-06 12:08:25 +01:00
Joost Jager
ddb98fcc41
multi: distinguish between htlc in and out constraints 2019-12-11 00:16:57 +01:00
Conner Fromknecht
3b253e05f6
multi: restructure invoice Terms field
This commit restructures an invoice's ContractTerms to better encompass
the restrictions placed on settling. For instance, the final ctlv delta
and invoice expiry are moved from the main invoice body (where
additional metadata is stored). Additionally, it moves the State field
outside of the terms since it is rather metadata about the invoice
instead of any terms offered to the sender in the payment request.
2019-11-22 02:25:02 -08:00
Joost Jager
de33010e90
htlcswitch/test: do not string match error 2019-11-12 14:13:25 +01:00
Joost Jager
b222b6e625
Merge pull request #3685 from cfromknecht/flat-features
flat features
2019-11-09 11:43:45 +01:00
Conner Fromknecht
16318c5a41
multi: merge local+global features from remote peer 2019-11-08 05:31:47 -08:00
Joost Jager
0b5afa64f3
htlcswitch: remove logCommitTick
Replace logCommitTick as a way to deal with revocation window exhaustion
by retrying to update the commit tx when the remote revocation is
received.

The rationale is that the revocation window always opens up because of a
revoke message that is received from the other party. It is therefore
not necessary to set a timer for this. The reception of the revoke
message is the trigger to send a new commit sig if necessary.
2019-11-06 09:21:33 +01:00
Joost Jager
ae67b1a4a4
htlcswitch/test: test revocation window exhaustion 2019-11-06 09:21:31 +01:00
Joost Jager
f59b4d62bf
htlcswitch: check for signature owed in link
Previously the channel method FullySynced was used to decide whether to
send a new commit sig message. However, it could happen that FullySynced
was false, but that we didn't owe a commitment signature. Instead we
were waiting on the other party to send us a signature. If that
happened, we'd send out an empty commit sig. This commit modifies the
condition that triggers a new commit sig and fixes this deviation from
the spec.
2019-11-06 09:21:23 +01:00
Joost Jager
64f4421d6c
htlcswitch/test: add test cases that triggers empty commit sig
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2019-11-06 09:21:21 +01:00
Conner Fromknecht
70708e2e71
htlcswitch: return hop.Payload from HopIterator 2019-11-04 15:10:15 -08:00
Olaoluwa Osuntokun
777ed104a3
chainfee: create new chainfee package extracting fees from lnwallet
In this commit, we create a new chainfee package, that houses all fee
related functionality used within the codebase. The creation of this new
package furthers our long-term goal of extracting functionality from the
bloated `lnwallet` package into new distinct packages. Additionally,
this new packages resolves a class of import cycle that could arise if a
new package that was imported by something in `lnwallet` wanted to use
the existing fee related functions in the prior `lnwallet` package.
2019-10-31 16:41:57 -07:00
Joost Jager
200be87212
htlcswitch: fix returned failure for insufficient balance
In the scenario where the requested channel does not have enough balance
and another channel towards the same node generates a different failure,
we erroneously returned UnknownNextPeer instead of the expected
TemporaryChannelFailure.

This commit rewrites the non-strict forwarding logic in the switch to
return the proper failure message. Part of this is moving the link
balance check inside the link.
2019-10-23 09:57:34 +02:00
Joost Jager
5404348f51
htlcswitch: rename policy check functions 2019-10-23 09:57:22 +02:00
Joost Jager
654b3cc718
htlcswitch: use prefix logger for remaining log statements in link 2019-10-03 10:22:05 +02:00
Joost Jager
426ee28895
htlcswitch/test: move test functions into context 2019-09-26 15:11:23 +02:00
Joost Jager
23617bb9fd
htlcswitch/test: move test code 2019-09-26 15:11:21 +02:00
Olaoluwa Osuntokun
3f8526a0ca
peer+lnpeer: add new methods to expose local+global features for lnpeer interface 2019-09-25 18:26:01 -07:00
Valentine Wallace
9a52cb6dab
multi: update internals to support updating max htlc
In this commit, we update the router and link to support users
updating the max HTLC policy for their channels. By updating these internal
systems before updating the RPC server and lncli, we protect users from
being shown an option that doesn't actually work.
2019-09-23 13:07:10 +02:00
Conner Fromknecht
6dca07577d
multi: move active/inactive ntfns from switch to link
Since we will now wait to deliver the event after channel reestablish,
notifying when the link is added to the switch will no longer be
sufficient. Later, we will add receiving reestablish as an additional
requirement for EligibleToForward returning true.

The inactive ntfn is also moved, to ensure that we don't fire inactive
notifications if no corresponding active notification was sent.
2019-09-19 12:46:44 -07:00
Joost Jager
3d7de2ad39
multi: remove dead code 2019-09-10 17:21:59 +02:00
Valentine Wallace
8ce7f82da0 discovery+switch: apply zero forwarding policy updates in-memory as well as on disk
In this commit, we fix a bug where if a user updates a forwarding policy to be
zero, the update will be applied to the policy correctly on-disk, but not
in-memory.

We solve this issue by having the gossiper return the list of on-disk updated
policies and passing these policies to the switch, so the switch can assume
that zero-valued fields are intentional and not just uninitialized.
2019-09-09 23:39:44 -07: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
Conner Fromknecht
378e0558c5
htlcswitch/hop: move hop.Exit and hop.Source to hop pkg 2019-09-05 01:35:23 -07:00
Conner Fromknecht
fc0e4be4d8
htlcswitch+hop: move ForwardingInfo to hop.ForwaringInfo 2019-09-05 01:35:23 -07:00
Conner Fromknecht
83d2112e8b
htlcswitch/hop: move NetworkHop to hop.Network 2019-09-05 01:35:20 -07:00
Olaoluwa Osuntokun
866867a4b0
Merge pull request #3401 from wpaulino/channel-initiator-max-fee
htlcswitch: avoid proposing fee updates exceeding max fee allowed
2019-09-04 20:38:52 -07:00
Joost Jager
c1345a4117
multi: use separate cltv expiry field from invoice
Now that the Invoice struct contains the decoded final cltv delta value,
the decoding of payment requests can be removed from the invoice
registry.
2019-09-04 19:20:19 +02:00
Wilmer Paulino
d8dd6b3245
htlcswitch: cap fee updates to max fee allocation
In this commit, we begin to enforce a maximum channel commitment fee for
channel initiators when attempting to update their commitment fee. Now,
if the new commitment fee happens to exceed their maximum, then a fee
update of the maximum fee allocation will be proposed instead if needed.

A default of up to 50% of the channel initiator's balance is enforced
for the maximum channel commitment fee. It can be modified through the
`--max-channel-fee-allocation` CLI flag.
2019-09-03 16:49:59 -07:00
Wilmer Paulino
047d5b173c
htlcswitch: refactor TestChannelLinkUpdateCommitFee common code into closure 2019-09-03 16:49:56 -07:00
Joost Jager
4dd054ae90
multi: remove debug invoices
Debug invoices are rarely used nowadays, but keep asking for maintenance
every time refactoring in primarily the invoice registry occurs. We have
passed the cost/benefit tipping point, so therefore the debug invoice
concept is removed in this commit.

Previously the debughtlc flag also controlled whether hodl masks were
active. It is safe to remove that additional condition because the hodl
masks are still guarded by the dev build tag.
2019-08-14 21:33:03 +02:00
Joost Jager
98fac9fb99
htlcswitch+invoices: always return incorrect_or_unknown_payment_details
In order to prevent information leaks by nodes probing with a payment
hash, this commit changes exit hop processing so that it always returns
incorrect_or_unknown_payment_details and leaves the prober in the dark
about whether an invoice actually exists.
2019-08-08 11:04:23 +02:00
Joost Jager
45b3c647f7
htlcswitch: return final_incorrect_htlc_amount on onion payload mismatch
This commit fixes exit hop behavior to be in line with the lightning
spec.
2019-08-08 11:04:19 +02:00
Joost Jager
aabd68ebcd
multi: rename FailUnknownPaymentHash to FailIncorrectDetails
Align naming better with the lightning spec. Not the full name of the
failure (FailIncorrectOrUnknownPaymentDetails) is used, because this
would cause too many long lines in the code.
2019-08-08 11:04:17 +02:00
Joost Jager
8681729561
htlcswitch/test: extract failure code assertion to function 2019-08-08 11:04:15 +02:00
Wilmer Paulino
87ff463abd
htlcswitch+lnd: make max cltv expiry configurable 2019-07-26 18:05:58 -07:00