Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth 1d2985ce33 Merge pull request #4108 from jnewbery/2020-03-min-htlc-comment
[Docs] fix defaultBitcoinMinHTLCInMSat comment
2020-03-24 13:02:04 +01:00
Johan T. Halseth 8dc5a3c144 itest: wait for file writing in wait predicate 2020-03-24 12:18:42 +01:00
Johan T. Halseth 8623bfac22 Merge pull request #4103 from halseth/itest-multi-hop-move
[itests] multi hop test move
2020-03-24 09:37:53 +01:00
Johan T. Halseth b4ea34037a lntest: move multi-hop root test case and common utils to own file 2020-03-23 11:19:18 +01:00
Johan T. Halseth 1ade912361 itest: run multi-hop claim tests for all commit types 2020-03-23 11:16:29 +01:00
Johan T. Halseth 6ed0c83d11 itest: spin up new nodes for multi-hop tests
This will let us set their commitment type for the subtest.
2020-03-23 11:13:27 +01:00
Johan T. Halseth 1ce4abc0a9 itest: extract multi-hop tests into sub tests 2020-03-23 11:13:26 +01:00
Johan T. Halseth 5a0f2d004a itest: update multi hop test case docs
To make clear whcih sweep scenarios are actually being tested
2020-03-23 11:11:25 +01:00
Johan T. Halseth 4b5d91d24d itest: move multi hop tests to own files
PURE CODE MOVE.
2020-03-23 11:10:33 +01:00
Johan T. Halseth d81c8bbda7 itest: run force closure test for all commit types
Now that the force closure test has been extracted, spin up new nodes
for each commit type, and ensure the test succeed for all types.
2020-03-23 11:10:31 +01:00
Johan T. Halseth 651bb09c25 itest: extract channel force closure test into subtest
To make it possible to run the for close test for multiple commit types,
we extract it into a subtest, where the two nodes get passed in.
2020-03-23 11:07:36 +01:00
Johan T. Halseth 538f3baac8 itest: print wrong balance in correct format 2020-03-23 11:05:40 +01:00
Johan T. Halseth 42638183d8 Merge pull request #4105 from carlaKC/lnrpc-formatroutingprotos
routerrpc: run rpc-format on routerrpc
2020-03-20 20:57:42 +01:00
Johan T. Halseth c1d00a0c9b Merge pull request #4101 from ErikEk/typo_fixes_trivial
trivial: typo fixes
2020-03-19 21:36:38 +01:00
Johan T. HalsethandJoost Jager dc6c4637b6 lnwallet+channeldb: add anchor resolutions
Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-03-17 14:19:35 +01:00
Johan T. Halseth 7d305fdc46 lnrpc: add commitment_type to listchannels 2020-03-13 20:00:48 +01:00
Johan T. Halseth 15be39b8db Merge pull request #4071 from halseth/autopilot-log-active
[trivial] pilot: log whether autopilot is active at startup
2020-03-11 16:22:33 +01:00
Johan T. Halseth 44ba481f56 Merge pull request #4069 from guggero/windows-build
travis+lncli: fix windows build
2020-03-11 14:51:54 +01:00
Johan T. Halseth 5484436520 Merge pull request #4010 from halseth/avoid-resend-chansync-loop
peer: avoid chansync resend loop
2020-03-11 14:47:07 +01:00
Johan T. Halseth d4bb0854df Merge pull request #4070 from guggero/disable-clang-format
Makefile: don't format proto on Travis
2020-03-11 14:43:44 +01:00
Johan T. Halseth c9c667bbf2 pilot: log whether autopilot is active at startup 2020-03-11 12:56:16 +01:00
Johan T. Halseth 7b8eae38e5 peer: avoid chansync resend loop
If a peer receives a channel reestablish message shortly after the
channel has been closed, it will resend its own channel reestablish
message. In the meantime the other peer could also have seen the channel
being closed and will also resend its own message. This leads to a
resend loop that never terminates.

To avoid two peers getting into this situation, we now allow only one
such resent message per conection.
2020-03-11 12:13:25 +01:00
Johan T. Halseth b7885dbbae lnwallet+size: select HTLC fees based on channel type 2020-03-09 12:59:35 +01:00
Johan T. Halseth ea2a58e80f fundingmanager+lnwallet: enable anchor commitments
If both nodes are signalling the feature, make all opened channels using
this type.
2020-03-09 12:59:35 +01:00
Johan T. Halseth 7adb1bcbaa chanbackup: disable channel backup for anchor types 2020-03-09 12:59:35 +01:00
Johan T. Halseth fd93c568ea config+link: disable watchtower for anchors 2020-03-09 12:59:34 +01:00
Johan T. Halseth 21126ab0f3 multi: optionally enable and signal anchor support
Defaults to disabled.
2020-03-09 12:59:34 +01:00
Johan T. Halseth 44756b5811 cfg: rename legacyprotocol to protocol
Since we are also going to use it for experimental new features.
2020-03-09 12:59:34 +01:00
Johan T. Halseth 51c5352ae4 itest: make commit type enum
To prepare for adding more commit types to test for basic channel
funding, we make the commit type an enum that gets its own set of
subtests.
2020-03-09 12:59:34 +01:00
Johan T. Halseth f95a82bf5f lnwallet+funding: create CommitmentType enum 2020-03-09 12:59:34 +01:00
Johan T. Halseth 8741b93723 lnwallet/reservation: add non-initiator balance check
If we are the initiator, we check that our starting balance after
subtracting fees are not less than two times the default dust limit.

This commit adds a similar check for the non-initiator case, checking
that the remote party has a starting balance of reasonable size.
2020-03-09 12:59:34 +01:00
Johan T. Halseth ad8e9f30c6 lnwallet+breacharbiter: record local csv delay 2020-03-09 12:59:34 +01:00
Johan T. Halseth 92af2342da lnwallet+nursery+input: set sequence=1 for direct HTLC spends 2020-03-09 12:59:33 +01:00
Johan T. Halseth c5d58b4762 lnwallet: set 2nd level sequence according to channel type 2020-03-09 12:59:33 +01:00
Johan T. Halseth bddd3e128c lnwallet: make second level sigs using sighash single|anyonecanpay 2020-03-09 12:59:33 +01:00
Johan T. Halseth d1089fb449 input/test_utils: make mockSigner use SigHashType from sign descriptor 2020-03-09 12:59:33 +01:00
Johan T. Halseth 6810912c86 lnwallet: choose HTLC scripts based on channel type 2020-03-09 12:59:33 +01:00
Johan T. Halseth 21c5a957bc lnwallet/channel: add feerate sanity check 2020-03-09 12:59:22 +01:00
Johan T. Halseth ea94dbbe34 input+lnwallet: use individual commit weight calculations for channel type
Based on the channel type, the commitment weight will be calculated.
2020-03-09 12:10:59 +01:00
Johan T. HalsethandJoost Jager 1f28bd8086 contractcourt/commit_sweep_resolver: set sweep witness type based on witness script
We use the fact that we can tell whether the commit is local or remote
by inspecting the witness script. We cannot use the maturity delay
anymore, as we can have delayed to_remote outputs also now.

Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-03-09 12:10:59 +01:00
Johan T. Halseth af68ff1640 lnwallet: add anchor commitmenttype
With this commitment type, we'll add extra anchor outputs to the
commitment transaction if the anchor channel type is active.
2020-03-09 12:10:59 +01:00
Johan T. Halseth 50199aeaf3 input/script_utils: add anchor scripts + tests 2020-03-09 12:10:59 +01:00
Johan T. Halseth 6deb913a8d input: add CommitmentToRemoteConfirmed witness type 2020-03-09 12:10:59 +01:00
Johan T. Halseth 990992ce94 input/script_utils: add delayed to_remote script + tests 2020-03-09 12:10:59 +01:00
Johan T. Halseth a309132253 input/script_utils test: add test cases for delayed HTLC receiver scrpts 2020-03-09 12:10:59 +01:00
Johan T. Halseth dc271a80cb input/script_utils test: add test cases for delayed HTLC sender script 2020-03-09 12:10:58 +01:00
Johan T. Halseth 8c0deb81c2 input+lnwallet: Add scripts for CSV delayed HTLC outputs
We also increase the witness size for these types to account for the 3
extra bytes. The size won't be correct in all cases, but it is just an
upper bound in any case.
2020-03-09 12:10:58 +01:00
Johan T. Halseth b25f2fa94b channeldb: define AnchorOutputsBit channel type 2020-03-09 12:10:58 +01:00
Johan T. Halseth 6ecb379088 lnwallet: thread chanType down into genHtlcScript, gen[..]SigJobs,
create[..]Tx

NO FUNCTIONAL CHANGES
This is a commit just supplying the channel types to various methods.
2020-03-09 12:10:58 +01:00
Johan T. Halseth b228681a02 input/script_utils_test: refactor TestHTLCSenderSpendValidation
To be able to change more than the witness used for each test case, we
extract commit and sweep tx generation into own methods that can be
called from each test case.

We do the same for TestHTLCReceiverSpendValidation
2020-03-09 12:10:58 +01:00
Johan T. Halseth b56c7e308b input/script_utils_test: extract script execution into assert method
This fixes an error case that wouldn't have been caught, since
vm.Execute applies more rules than the individual steps (most notably
the clean stack rule).

Instead we execute the engine as normal, and only step through if we
decide that the outcome is unexpected.
2020-03-09 12:10:58 +01:00
Johan T. Halseth 865776c776 lnwallet/channel: use genHtlcScript to create scripts
It takes into account the necessary variables and will prepare us for
doing commitment type dependent script generation later.
2020-03-09 12:10:57 +01:00
Johan T. Halseth 02dd8d23fd input/size: remove unused constants
Since we never attempt to sweep an HTLC we offered with the preimage on
the remote's commitment, we never use the constant
AcceptedHtlcSuccessWitnessSize for weight estimation. Similarly, we
never timout an HTLC offered by the remote on our own commitment, and
don't need the constant OfferedHtlcTimeoutWitnessSize.
2020-03-09 12:10:57 +01:00
Johan T. Halseth bee2380441 channeldb: rename PaymentAttemptInfo to HTLCAttemptInfo
To better distinguish payments from HTLCs, we rename the attempt info
struct to HTLCAttemptInfo. We also embed it into the HTLCAttempt struct,
to avoid having to duplicate this information.

The paymentID term is renamed to attemptID.
2020-03-09 11:43:26 +01:00
Johan T. Halseth 42e65d4ae5 Merge pull request #4030 from halseth/route-cutoff-flake-fix
chancloser: unregister channel before db modification
2020-03-04 13:14:32 +01:00
Johan T. Halseth 03a0706593 chancloser: unregister channel before db modification
This fixes a race during channel closing, where the last channel state
update was still not finished when we set the channel close bit in the
database. This lead to a flake during integration tests, where the last
state update would not finish, and the channel wasn't closes
successfully.

We fix it by first unregistering the channel, making sure it is removed
fully from the link before doing the db modification.
2020-03-04 10:31:38 +01:00
Johan T. Halseth 38b521d87d Merge pull request #3961 from carlaKC/3709-cooperativecloseinitiator
channeldb: Indicate cooperative close initator
2020-02-21 14:27:48 +01:00
Johan T. Halseth 214c73a9a0 Merge pull request #4026 from guggero/lint-fix
travis: remove git clone depth limitation to fix linter
2020-02-20 22:33:13 +01: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
Johan T. Halseth 3e5f2e437d lnwallet/channel: add TODO 2020-02-19 12:27:42 +01:00
Johan T. Halseth e398544b8b lnwallet/channel: take remote commitment view into availableBalance calculation
Since our HTLC must also be added to the remote commitment, we do the
balance caluclation also from the remote chain perspective and report
our minimum balance from the two commit views as our available balance.
2020-02-19 12:27:42 +01:00
Johan T. Halseth f94464d987 lnwallet: take remote initiator's balance into account
When we send non-dust HTLCs as the non-initiator, the remote party will
have to pay the extra commitment fee. To account for this we figure out
if they can afford paying this fee, if not we report that we only have
balance available for dust HTLCs, since these HTLCs won't increase the
commitment fee.
2020-02-19 12:27:42 +01:00
Johan T. Halseth 9ff79ae595 lnwallet/channel: account for HTLC fee when reporting available balance 2020-02-19 12:27:42 +01:00
Johan T. Halseth 5e89d5b6c2 link+lnwallet: move bandwidth channel reserve validation into channel
Since we want to handle the edge case where paying the HTLC fee would
take the initiator below the reserve, we move the subtraction of the
reserve into availableBalance where this calculation will be performed.
2020-02-19 12:27:42 +01:00
Johan T. Halseth 58dec10680 lnwallet/channel: break up availableBalance 2020-02-19 12:27:41 +01:00
Johan T. Halseth 0d9a1b8656 lnwallet: check local commitment sanity when adding HTLC
This commit adds an extra validation step when adding HTLCs. Previously
we would only validate the remote commitment resulting from adding an
HTLC, which in most cases is enough. However, there are situations where
the dustlimits are different, which could lead to the resulting remote
commitment from adding the HTLC being valid, but not the local
commitment.

Now we also validate the local commitment. A test to trigger the case is
added.
2020-02-19 12:27:41 +01:00
Johan T. Halseth 4ea822efeb lnwallet tests: add test for dipping remote below chan reserve
This commit adds a test that was previously not performed, namely that
adding a HTLC would dip the remote initiator below its channel reserve.
2020-02-19 12:27:41 +01:00
Johan T. Halseth 05fb272deb lnwallet/channel: make validateCommitmentSanity take our/their predict
add

To ba able to validate the commitment sanity both for remote and local
commitments, and at the same time predict both our and their add, we let
validateCommitmentSanity take an extra payment descriptor to make this
possible.
2020-02-19 12:27:41 +01:00
Johan T. Halseth 3da5ca0bd2 Merge pull request #4012 from halseth/mpp-paymentid-error
[trivial] channeldb: remove unused payments status serialization
2020-02-18 21:37:02 +01:00
Johan T. Halseth cdf3a49c54 channeldb: remove unused payments status serialization 2020-02-18 13:01:57 +01:00
Johan T. Halseth 13ca3f4ff9 Merge pull request #3998 from halseth/panic-addentry
Fix TestNewBreachRetributionSkipsDustHtlcs incorrect state transtion
2020-02-17 12:21:19 +01:00
Johan T. Halseth 8904b68626 Merge pull request #3932 from halseth/tls-oudated-check
Re-create TLS files if IPs or domains changed
2020-02-13 10:47:11 +01:00
Johan T. Halseth 5943e5d8b1 lnwallet: state transition from correct node during test, remove panic
The unit test TestNewBreachRetributionSkipsDustHtlcs triggered a state
transition from Bob, even though it was Alice that had added the HTLCs.
This is wrong since it will lead to Bob still owing Alice a commitment,
which is not accounted for in the unit tests.

We add a sanity check that the add heights has been set for all entries
found in the logs, and return an error otherwise. This won't happen
during normal operation, but it does reveal the mistake in the unit
test, which is fixed by making Alice trigger the transition.

In addition we resolve a long standing TODO by removing a (purposeful)
panic in the channel state machine. Old version of lnd had a bug that
could lead to the parent entries being lost during channel restore. A
panic was added to get to the bottom of if.

This is now fixed, so new nodes shouldn't encounter it. However, to be
on the safe side, instead of panicking we return an error back to
gracefully exit the channel state machine.
2020-02-12 11:10:19 +01:00
Johan T. Halseth e114f58b5e lnwallet: unify remote and local update log fetch 2020-02-12 11:10:18 +01:00
Johan T. Halseth ba38bda5f0 lnd: reload cert data after renewal
After renewing the certificate, the new certificate wasn't actually
loaded and used, causing the old one to be used until lnd was restarted.
This fixes that by reloading it after it has been written.
2020-02-12 10:59:52 +01:00
Johan T. Halseth f7a85e07b0 lnd+cert: recreate TLS files if IPs or DNS changed
This commit makes lnd recreate its TLS certificate if the config's
tlsextradomains or tlsextraips changed. This is useful, since earlier
user would have to manually delete the files to trigger lnd to recreate
them.

To ensure users don't accidentally have their TLS certificate recreated,
we gate it behind a flag --tlsautorefresh that defaults to false.
2020-02-12 10:59:51 +01:00
Johan T. Halseth 83dcf95f92 cert+test: IsOutdated check for TLS files if IPs or DNS changed
This commit creates a new utility method IsOutdated that can be used to
check whether a TLS certificate mathces the extra IPs and domains given
in the lnd config.
2020-02-12 10:59:51 +01:00
Johan T. Halseth d316107749 cert: extract IP and DNS parsing into methods 2020-02-12 10:59:51 +01:00
Johan T. Halseth 2a73dabdee Merge pull request #3995 from halseth/trivial-chanpoint-log
[trivial] contractcourt/chainwatcher: add missing chanpoint log
2020-02-11 14:12:31 +01:00
Johan T. Halseth 99ebe50f4c contractcourt/chainwatcher: add missing chanpoint log 2020-02-11 13:23:34 +01:00
Johan T. Halseth 5556735fb6 Merge pull request #3990 from yaslama/signrpc-input-index-fix
Copy InputIndex into the underlying SignDescriptor struct
2020-02-11 08:47:03 +01:00
Johan T. Halseth f16fe7b483 Merge pull request #3916 from chokoboko/rpcserver-remove-duplicated-permission-entity
[trivial] rpcserver: remove duplicated 'address' permission entity
2020-02-11 08:15:34 +01:00
Johan T. Halseth 80c5232d4f Merge pull request #3978 from bhandras/hotfix
invoices: fix log messages
2020-02-04 12:56:18 +01:00
Johan T. Halseth b39e21f6dd Merge pull request #3926 from C-Otto/master
Fix typos
2020-01-31 11:34:34 +01:00
Johan T. Halseth 1dadce7cfd Merge pull request #3945 from joostjager/node-level-penalty
routing: penalize node-level failures harder
2020-01-25 12:50:09 +01:00
Johan T. Halseth a8ec8f2db6 Merge pull request #3582 from hsjoberg/pendingchannelevent
rpc: Add PendingOpenChannel to SubscribeChannelEvents
2020-01-24 14:42:40 +01:00
Johan T. Halseth fd75f29480 Merge pull request #3908 from halseth/mobile-trim-spaces
[mobile] trim arg spaces before comparison
2020-01-23 11:54:25 +01:00
Johan T. Halseth bebb6395ec Merge pull request #2137 from halseth/payintent-recv-eof
rpcserver: fix error handling in bidirectional sendPayment
2020-01-23 11:53:56 +01:00
Johan T. Halseth 2b6575463b mobile: bump falafel dep to 0.7 2020-01-21 20:45:58 +01:00
Johan T. Halseth dc23810118 rpcServer: wait for all goroutines to finish before exiting
Returning from the sendPayments method closes the underlying stream, so
we would risk payments still being in flight when returning.

We add the running goroutines to a waitgroup, such that we can wait for
them all to exit before exiting and closing the stream.

In case an error is encountered in the process, we will return directly,
which will close the `reqQuit` channel and prompt the gorpoutines to
shut down.
2020-01-21 12:45:12 +01:00
Johan T. Halseth 5b85721c04 rpcServer: ensure all payIntents are handled before exiting
This commit fixes a problem that could arise when handling a continuous
stream of payIntents. We would risk the client sending a set of payment
intents and closing the stream, but we wouldn't be sure the sendLoop had
read all messages on the `payChan` before exiting with the nil error
from the `errChan`.

Instead, we close the `payChan` to indicate that no more payments are
going to be received.
2020-01-21 12:45:12 +01:00
Johan T. Halseth c49ba0c5cb rpcServer: ensure we don't get blocked on bidirectional payment errors
This commit fixes a potential issue in the bidirectional sendPayment
case, where multiple goroutines could be sending on an errChan with
buffer 1. Instead we select on default as well, as it is enough to
handle the first error that was received.
2020-01-21 12:45:12 +01:00
Johan T. Halseth f20f29696a rpcserver: let sendPayment sendLoop listen for shutdown
Intead of checking for shutdown in the receive loop, we let the sendLoop
handle it, as it can return the error directly. This works since the
returning sendLoop will trigger a close of the `reqQuit` channel, which
will ensure the receive loop exits.
2020-01-21 12:28:31 +01:00
Johan T. Halseth 80ad0fdd5c lntest: restart Alice after on-chain settle
To ensure lnd is able to pick up an on-chain preimage properly after a
restart, we suspend Alice and check that the payment is listed correctly
as succeeded after a restart.
2020-01-20 14:01:19 +01:00
Johan T. Halseth bb619352be lntest: check payment status settled after claim test 2020-01-20 13:55:13 +01:00
Johan T. Halseth daa08be62a Merge pull request #3907 from halseth/mobile-walletunlocker-tls
[mobile] Set walletunlocker TLS credentials
2020-01-14 10:30:02 +01:00
Johan T. Halseth 56230f5de2 mobile: add note about using lnddir
On both Android and iOS (when not using a simulator) the application
procees doesn't have write permissions to the default lnd directory.
This commit adds a note about using the app directory given by the used
platform.
2020-01-14 09:30:09 +01:00
Johan T. Halseth f5a9813304 mobile: add TLS options to wallet unlocker listener
The wallet unlocker service also requires the TLS certificates to be
added, but this was not set. This commit sets the options similar to
what is done for the regular RPC server.
2020-01-14 09:30:09 +01:00
Johan T. Halseth a870ed5fb7 lnd: add WalletUnlockerAuthOptions
Similar to what was done for the regular RPC server, we add auth dial
options for the wallet unlocker, as it also requires TLS now.
2020-01-14 09:30:09 +01:00
Johan T. Halseth dae5dddfd2 mobile: trim arg spaces before comparison
Since spaces where trimmed only after checking for empty strings, an
empty flag '-- ' would be passed along to lnd. Intead we trim first to
properly ingore such flags.
2020-01-13 13:25:14 +01:00