Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth 0b84d5f976 contractcourt/success_resolver: extract HTLC success handling into broadcastSuccessTx 2020-12-10 14:24:19 +01:00
Johan T. Halseth 9d33b00082 contractcourt/success_resolver: extract remoteHTLC sweep into resolveRemoteCommitOutput
This move the logic for sweeping the HTLC output on the remote
commitment into its own method.
2020-12-10 14:24:19 +01:00
Johan T. Halseth 9b08ef6d4e contractcourt/[incoming|outgoing]_contest_resolver: make inner resolver pointer
To make the linter happy, make a pointer to the inner resolver.
Otherwise the linter would complain with

copylocks: literal copies lock value

since we'll add a mutex to the resolver in following commits.
2020-12-10 14:24:19 +01:00
Johan T. Halseth 4da2b290f9 contractcourt/succes+timeout resolver: extract waitForSpend logic 2020-12-10 14:24:19 +01:00
Johan T. Halseth 5f613147ad contractcourt: decouple waitForHeight from commit sweep resolver
To make it usable from other resolvers.
2020-12-10 14:24:19 +01:00
Johan T. Halseth 65e50f6952 input/witnessgen: define witness type for HTLC 2nd level inputs
These will only be used for size upper bound estimations by the sweeper.
2020-12-10 14:24:19 +01:00
Johan T. Halseth 8eb6d7cf87 input/size: define witness constants needed
We define the witness constanst we need for fee estimation for this
HTLC second level type.
2020-12-10 14:24:19 +01:00
Johan T. Halseth 241e21a0d1 itest: use hex encoded hash in error message 2020-12-10 14:24:18 +01:00
Johan T. Halseth 09f2307d14 itest: increase htlc amt for local force close tests
Since the tests set a quite high fee rate before the node goes to chain,
the HTLCs wouldn't be economical to sweep at this fee rate.

Pre sweeper handling of the second-level transactions this was not a
problem, since the fees were set when the second-levels were created,
before the fee estimate was increased.
2020-12-10 14:24:18 +01:00
Johan T. Halseth 83f9aaec98 sweeper/tx_input_set: add logging for input set construction 2020-12-10 14:24:18 +01:00
Johan T. Halseth 6150995b46 sweep/txgenerator: log in case of no change output 2020-12-10 14:24:18 +01:00
Johan T. Halseth 1e68cdc8cf input+lnwallet+contractcourt: define SignDetails for HTLC resolutions 2020-12-10 14:24:18 +01:00
Johan T. Halseth eb8d22e194 lnwallet/channel: properly set SignDesc.Output
Only value was populated for some, which would cause code to rely on the
PkScript being there to fail.
2020-12-10 14:24:18 +01:00
Johan T. Halseth 08bb8abaa3 Merge pull request #4851 from halseth/sweeper-cnct-deadlock
sweeper: avoid deadlock on shutdown
2020-12-10 14:23:36 +01:00
Johan T. Halseth f6f3ab5b0b Merge pull request #4829 from yyforyongyu/typo-fix
multi: Typo fix
2020-12-10 13:55:35 +01:00
Johan T. Halseth 77daa3dbe4 sweeper: avoid deadlock on shutdown
We risked deadlocking on shutdown if a client (in our case a contract
resolver) attempted to schedule a sweep of an input after the
ChainNotifier had been shut down. This would cause the `collector`
goroutine to exit, and not handle incoming requests, causing a deadlock
(since the ChainArbitrator is being stopped before the Sweeper in the
server).

To fix this we could change the order these subsystems are stopped, but
this doesn't ensure there aren't other clients that could end up in the
same deadlock scenario. So instead we keep handling the incoming
requests even after the collector has exited (immediatly returning an
error), until the sweeper is signalled to shutdown.
2020-12-10 13:19:59 +01:00
Johan T. Halseth de66d35a5b Merge pull request #4847 from carlaKC/4800-peerfeaturedowngrade
peer: do not require static remote for peers with legacy channels
2020-12-10 12:14:07 +01:00
Johan T. Halseth 0532c21e33 peer: remove static remote required for peers with legacy channels
This commit unsets option static remote key required for peers that
we have existing legacy channels with. This ensures that we can still
connect to peers that do not recognize this feature bit that we have
existing channels with.
2020-12-09 16:18:09 +02:00
Johan T. Halseth f98a3c9dac Merge pull request #4848 from halseth/htlcswitch-log-infof
[trivial] htlcswitch: log with format
2020-12-08 14:20:25 +01:00
Johan T. Halseth e13c97d621 Merge pull request #4841 from cfromknecht/send-coins-log-fix
rpcserver: replace sweep_all in log with send_all to match rpc arg
2020-12-08 13:56:41 +01:00
Johan T. Halseth 1a35c0055b htlcswitch: log with format 2020-12-08 13:54:41 +01:00
Johan T. Halseth 74eb728630 sweep/sweeper_test: add test for reorderd inputs
This add a test for inputs that gets re-ordered because the inputs with
required TxOuts must be added first.

We add a new step to the test that checks that all inputs were signed at
the correct tx input index.

This test would fail without the previous commit.
2020-12-08 10:59:23 +01:00
Johan T. Halseth 84ee6b6b86 sweep/txgenerator: fix input witness ordering
This commit fixes an issue that would arise if inputs without required
TxOuts would be swept together with inputs with required TxOuts. In this
case we would add the required ones first to the transaction, but did
not change the order we signed the inputs, resulting in signing the
wrong input index.
2020-12-08 10:59:23 +01:00
Johan T. Halseth 0a12592b39 htlcswitch/link_test: double timeouts
Double the timeout to allow the htlcswitch tests to finish on slow
systems (darwin...).
2020-12-04 10:50:43 +01:00
Johan T. Halseth 548827fe89 htlcswitch/link_test: use require.Eventually
Intead of sleeping we use require.Eventually in two cases the flake was
flaky.
2020-12-04 10:50:35 +01:00
Johan T. Halseth ef426be351 contractcourt/chainwatcher test: add test cases for future force close
This adds the scenario to the local force close test cases where a node
force closes one of its channels, then lose state (or do recovery)
before the commmitment is confirmed. Without the previous commit this
would go undetected.
2020-12-03 08:01:08 +01:00
Johan T. Halseth 2a7a34ae10 contractcourt+lnwallet: use state num instead of commit height when
outdated local state

This commit fixes a bug that would cause us to not sweep our local
output in case we force closed, then lost state or attempted recovery.
The reason being that we would use or local commit height when deriving
our scripts, which would be incorrect. Instead we use the extracted
state number to derive the correct scripts, allowing us to sweep the
output.

Allthough being an unlikely scenario, we would leave money on chain in
this case without any warning (since we would just end up with an empty
delay script) and forget about the spend.
2020-12-03 08:01:08 +01:00
Johan T. Halseth 5bb8996162 contractcourt/chain_watcher: handleUnknownLocalState
Similar to what we did for other states, we extract handling of acting
on a local future state into its own method.
2020-12-03 08:01:08 +01:00
Johan T. Halseth 93d917d82a contractcourt/chain_watcher: handleUnknownRemoteState
This commit extracts the data loss protect recovery procedure into its
own method.
2020-12-03 08:01:08 +01:00
Johan T. Halseth 743ea7be74 contractcourt/chain_watcher: handleKnownRemoteState
Similar to what we did for the local state handling, we extract handling
all known remote states we can act on (breach, current, pending state)
into its own method.

Since we want to handle the case where we lost state (both in case of
local and remote close) last, we don't rely on the remote state number
to check which commit we are looking at, but match on TXIDs directly.
2020-12-03 08:01:08 +01:00
Johan T. Halseth acc45934f8 contraccourt/chain_watcher: define handleKnownLocalState
We can only rely on the commit set and height being correct for the
current commit, so check that first.
2020-12-03 08:01:08 +01:00
Johan T. Halseth 450da3d2f4 contractcourt/chain_watcher test: do proper state rollback
The tests didn't really roll back the channel state, so we would only
rely on the state number to determine whether we had lost state. Now we
properly roll back the channel to a previous state, in preparation for
upcoming changes.
2020-12-03 08:00:02 +01:00
Johan T. Halseth 18f79e20d5 lnwallet/test_utils: set up asymmetric commits
The remote and local commits are not symmetric, so we correctly set them
up pointing to the correct commitment tx.
2020-12-03 08:00:01 +01:00
Johan T. Halseth 7dd3e18234 Merge pull request #4817 from Roasbeef/remove-codeowners
github: remove CODEOWNERS file
2020-12-02 10:41:26 +01:00
Johan T. Halseth 8ec4697fe3 Merge pull request #4810 from Roasbeef/gossip-throttle-config
multi: add new config option to toggle gossip rate limiting
2020-12-01 13:32:52 +01:00
Johan T. Halseth 42d7fcd2f9 Merge pull request #4806 from guggero/neutrino-tor-fix
Fix Onion v2 support for Neutrino backends
2020-12-01 11:30:39 +01:00
Johan T. Halseth ef503bf14e Merge pull request #4801 from halseth/router-lifecycle-logs
[logging] add more logging for failed payment shards
2020-11-24 20:49:08 +01:00
Johan T. Halseth df049ad755 routing: promote shard logs on resume and terminal failure to Info 2020-11-24 14:59:39 +01:00
Johan T. Halseth f8493a7522 routing: define errShardHandlerExiting 2020-11-24 14:59:39 +01:00
Johan T. Halseth 4d645ef97f htlcswitch: add debug logs for fetching network result 2020-11-24 14:14:49 +01:00
Johan T. Halseth 87cdf3b797 htlcswitch/link: revert borking channels on received Errors
Since it turned out borking channels on every received error could cause
us to bork channels in case of a sync error with C-lightning, we revert
this for now.
2020-11-23 14:42:41 +01:00
Johan T. Halseth ca91d50884 Merge pull request #4750 from halseth/sweeper-required-locktime-txout
Sweeper: support Inputs with required locktimes and txOuts
2020-11-21 11:54:34 +01:00
Johan T. Halseth 8d2e6deade sweeper_test: add txOut sweep test
Add tests that inputs with required TXOuts gets aggregated and swept, while
keeping locktimes satisfied.
2020-11-21 10:17:10 +01:00
Johan T. Halseth 616503de3e sweep: add required TxOuts to sweep tx
Now that inputs might have accompanied outputs to be added to the sweep
tx, we add them to the sweep transaction first, and account for it when
calculating the change amount.
2020-11-20 13:06:54 +01:00
Johan T. Halseth 7f9df26efd sweeper_test: return unique wallet utxos
We also increase the value of the wallet UTXO, as it is needed when we
want to afford fees for larger transactions.
2020-11-20 13:06:54 +01:00
Johan T. Halseth 0cba47dac0 sweep/tx_input_set: account for required outputs in input set
If inputs require outputs to be added at the same time, this will
change the weight and amount calculations, so we must account for that.

We wait to get the weight estimator for the sweep tx until needed,
such that we can easily choose whether to include a change output or not
in the estimate. This is needed for the case where the second level
transactions can pay for their own fee, so no change output is needed.
2020-11-20 13:06:54 +01:00
Johan T. Halseth 985b7838ab sweep+input: add RequiredTxOut to inputs
This is needed to sweep second level HTLC transactions that are signed
using SINGLE|ANYONECANPAY, since the input and ouput must be aligned.
2020-11-20 13:06:54 +01:00
Johan T. Halseth aa8fa9d0cf sweep: pass dustLimit to CreateSweepTx 2020-11-20 13:06:53 +01:00
Johan T. Halseth 3d209059c1 input+sweep: let weightestimator take known TxOut 2020-11-20 13:06:53 +01:00
Johan T. Halseth efd6bc9501 sweep+input: add RequiredLockTime to inputs 2020-11-20 13:06:53 +01:00
Johan T. Halseth fa4fd02cf1 sweep: add mergeClusters 2020-11-20 13:06:53 +01:00
Johan T. Halseth 128087044f sweeper: define method createInputClusters 2020-11-20 13:06:53 +01:00
Johan T. Halseth ef8a61db99 Merge pull request #4423 from breez/enable-encode-invoice-via-rpc
Let invoice.Encode receive a function which hashes itself the message
2020-11-19 14:44:38 +01:00
Johan T. Halseth 2411168233 Merge pull request #4784 from yyforyongyu/autopilot-fix-typo
trivial: typo fix
2020-11-19 14:40:50 +01:00
Johan T. Halseth a8b6966017 Merge pull request #4402 from bhandras/etcd_itest
itests: option to run our integration tests on etcd + boltdb (remote/local)
2020-11-18 19:48:03 +01:00
Johan T. Halseth 4587b6dbab Merge pull request #4772 from halseth/log-levels-global-sub
build/log: support parsing global+subsystem levels
2020-11-18 19:44:12 +01:00
Johan T. Halseth a2f45cb812 config: update debuglevel description + sample conf 2020-11-18 14:19:23 +01:00
Johan T. Halseth c1d423dc07 build/log: support parsing global+subsystem levels
This makes it possible to specify both a global+subsystem loglevels,
like:
--debuglevel=debug,PEER=info,SRVR=trace
2020-11-18 14:17:53 +01:00
Johan T. Halseth fcf2e7f687 build/log_test: add tests for parsing log levels 2020-11-18 14:16:23 +01:00
Johan T. Halseth 953443e10c lnwallet/channel: correct dust calculation on incoming HTLC
Similar to the previous commit, we fix a bug resulting in the wrong
commit weight being calculated when an HTLC just above the remote's
duslimit was added from the remote. This was a result of using the
successFee instead of the timeoutFee when checking whether it was dust,
making us consider it dust when it shouldn't have been.
2020-11-13 12:02:03 +01:00
Johan T. Halseth e0b133297d lnwallet/channel: correct dust calculation on outgoing HTLC
In this commit we fix a bug resulting in the wrong commit weight being
calculated when an HTLC just below the remote's duslimit was added. This
was a result of using the timeoutFee instead of the successFee when
checking whether it was dust, making us consider it non-dust when it
should have been.
2020-11-13 11:58:52 +01:00
Johan T. Halseth 3f9a707531 Merge pull request #4737 from bhandras/itest_clean_state
itest: clean harness state before each icase and better naming for icase logs
2020-11-12 13:03:22 +01:00
Johan T. Halseth fac355c5a0 Merge pull request #4756 from guggero/itest-flakehunt
itest: add parallel flakehunter
2020-11-11 12:57:33 +01:00
Johan T. Halseth b525c04432 Merge pull request #4648 from halseth/option-no-tls
RPC: add --no-rest-tls option
2020-11-11 11:52:23 +01:00
Johan T. Halseth b529d42929 sample-config: add no-rest-tls 2020-11-11 09:41:23 +01:00
Johan T. Halseth 4d0537d4c3 config: enforce safe use of TLS 2020-11-11 09:37:53 +01:00
Johan T. Halsethandnicolas.dorier 5be7e710c7 RPC: Add --notls to disable TLS for RPC endpoints
Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
2020-11-11 09:37:52 +01:00
Johan T. Halseth a2a924e1e5 rpcserver: move TLS listen config to closure 2020-11-11 09:37:52 +01:00
Johan T. Halseth 428ca37301 Merge pull request #2018 from halseth/peer-remove-failed-chans
Mark channels borked in case of remote error
2020-11-10 18:50:47 +01:00
Johan T. Halseth 1c96cc7e10 Merge pull request #4546 from bjarnemagnussen/fix-coinselect-tests
chanfunding: Add/improve tests for CoinSelectSubtractFees
2020-11-05 10:21:30 +01:00
Johan T. Halseth c3397d7e77 htlcswitch/link test: add test for permanent failure 2020-11-04 11:16:22 +01:00
Johan T. Halseth dde6763cef htlcswitch/link: set PermanentFailure in case of remote error 2020-11-04 11:16:22 +01:00
Johan T. Halseth a97182b1e9 peer: mark channel borked in case of PermanentFailure 2020-11-04 11:16:22 +01:00
Johan T. Halseth a6d2263569 htlcswitch: add PermanentFailure to LinkFailureError 2020-11-04 10:50:28 +01:00
Johan T. Halseth ce17c3be96 Merge pull request #4268 from matheusdtech/itest-off-by-one
itest: fix off-by-one mining while waiting for CSV-encumbered outputs
2020-10-30 09:03:38 +01:00
Johan T. Halseth c1705a28da chanfitness/chaneventstore: stop ticker after goroutine
Stop the ticker after the goroutine reading from it has exited, to avoid
triggering the race detector.
2020-10-27 12:29:05 +01:00
Johan T. Halseth d26001a69a Merge pull request #4688 from carlaKC/4686-paymenttimeout
lncli: allow configurable timeout in send payment
2020-10-13 13:06:47 +02:00
Johan T. Halseth 22d7bb138c Merge pull request #3131 from halseth/reliable-payments-switch-gc
[reliable payments] switch result store clean-up
2020-10-08 15:43:34 +02:00
Johan T. Halseth 90a59fe70f router: call CleanStore on startup 2020-10-06 10:46:04 +02:00
Johan T. Halseth b071278f07 htlcswitch: add cleanStore method
That let us clean up handed off payment results, as they will never be
queried again.
2020-10-06 10:46:03 +02:00
Johan T. Halseth d1a118388d payment_control: remove unused Attempts field 2020-10-06 10:41:25 +02:00
Johan T. Halseth 46225e2921 Merge pull request #4666 from halseth/autopilot-mis-totalfunds
[autopilot] Use local channel balance in allocation calculation
2020-10-05 14:56:20 +02:00
Johan T. Halseth dbeafe8832 autopilot: rename to Capacity to Balance, define ChannelInfo()
We rename the field Capacity on local channels to Balance, define a new
method ChannelInfo on the manager config that let us query the database
for our latest channels state. Using this we will use the current local
balance instead of the channel capacity when doing allocation
calculations.
2020-10-05 12:24:07 +02:00
Johan T. Halseth d40cf6b592 autopilot: split channel definition into LocalChannel/ChannelEdge
Since non-local channels won't have a balance field, we split the
definitions in anticipation of adding one.
2020-10-05 12:24:07 +02:00
Johan T. Halseth 3e1755ee99 autopilot: remove unimpleneted SpliceIn/Out methods 2020-10-05 12:16:50 +02:00
Johan T. Halseth 392d6ccc9f autopilot: remove unused channel field FundedAmt 2020-10-05 12:16:50 +02:00
Johan T. Halseth b6c161bcfc Merge pull request #4671 from Roasbeef/health-check-logging
healthcheck: bump logging for failed healthchecks to info
2020-10-05 10:59:09 +02:00
Johan T. Halseth ef0bca7a8e Merge pull request #4660 from yyforyongyu/add-temp-miner-logs
itest: save temp miner's logs
2020-10-02 12:43:22 +02:00
Johan T. Halseth 1a73bc7d74 Merge pull request #4653 from LN-Zap/feat/spend-unconfirmed
Ability to spend unconfirmed coins when making onchain transactions
2020-10-02 08:40:45 +02:00
Johan T. Halseth d560f9eab0 Merge pull request #4662 from Roasbeef/neutrino-dep-update-sept
build: update neutrino to latest version
2020-10-01 14:26:09 +02:00
Johan T. Halseth 74e62e5c5b Merge pull request #4589 from yyforyongyu/itest-proper-cleanup
Itest: proper connect/disconnect miner
2020-09-25 10:31:56 +02:00
Johan T. Halseth 65865030d6 macaroons test: fix formatting 2020-09-24 11:59:08 +02:00
Johan T. Halseth 14960b1fb4 macaroons test: reverse macaroon time caveat check
This commit fixes a go 1.15 vet check.

In doing so it uncovers that the time caveat check is actually reversed.
Since we should check that the caveat is added, we should only fail the
check when the caveat prefix is not equal.
2020-09-24 11:22:20 +02:00
Johan T. Halseth 8ca5342b37 brontide test: fix go 1.15 vet check 2020-09-24 11:20:48 +02:00
Johan T. Halseth df6606d37f txnotifier test: add test for confirmation after cancellation
This test addition would cause the txnotifier to crash prior to the
previous commit.
2020-09-16 11:23:02 +02:00
Johan T. Halseth 2665836fa3 txnotifier: delete ntfn by confirm height always
When we cancel a confirmation request, we should remove the request from
the height map regardless of the current height. Otherwise we end up in
the situation when the height is reached, the notification is attempted
sent which results in a crash.
2020-09-16 11:20:37 +02:00
Johan T. Halseth 3a12b5867f txnotifier test: use Cancel() directly 2020-09-16 11:19:53 +02:00
Johan T. Halseth b8eb41f947 Merge pull request #4591 from hsjoberg/walletloader-unload
lnd: Call loader.UnloadWallet on shutdown
2020-09-15 13:54:46 +02:00
Johan T. Halseth bf18929f0e peer/brontide: fix pubkey log 2020-09-11 11:10:58 +02:00
Johan T. Halseth a48c369250 lnwallet: check coop close fee negative balance
Also modify the test to check for this condition.
2020-09-11 11:10:58 +02:00