Commit Graph
100 Commits
Author SHA1 Message Date
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
Johan T. Halseth 09a126b29f lnwallet: add anchor size back to balance on coop close
To be spec compliant, we require the initiator to not pay the anchor
values into fees on coop close. We extract the balance calculation into
commitment.go, and add back the value of the anchors to the initiator's
balance.
2020-09-11 11:10:58 +02:00
Johan T. Halseth 07a57ae778 lnwallet: extract coop close balance calc into method 2020-09-11 11:10:58 +02:00
Johan T. Halseth 724f439b0b lnwire: update anchor bit to spec 2020-09-11 11:10:58 +02:00
Johan T. Halseth 517fcd691a channeldb: correct anchor comment 2020-09-11 11:10:58 +02:00
Johan T. Halseth 85b53c357f htlcswitch: use kvdb.View for loading fwdpkgs
Not necessary to open a write tx.
2020-08-13 14:36:48 +02:00
Johan T. Halseth 09b8bee865 mobile: remember walletunlocker.proto 2020-08-04 14:43:08 +02:00
Johan T. Halseth e64e71d86d Merge pull request #4482 from guggero/travis-github-split
github+travis: split CI tasks between Travis and GitHub
2020-07-24 09:42:14 +02:00
Johan T. Halseth 0fab14502d Merge pull request #4467 from cfromknecht/hh-cache-followup
chainntfns: disable height-hint cache followups
2020-07-17 09:57:37 +02:00
Johan T. Halseth 9d147c55d7 Merge pull request #4469 from halseth/mobile-global-config
mobile+make: restore mobile compilation
2020-07-17 09:55:35 +02:00
Johan T. Halseth 935fa7f12d make+mobile: pass expected falafel version to build script 2020-07-17 08:49:03 +02:00
Johan T. Halseth 39241dcdc7 mobile: use single brackets for bash if check
Double brackets are sh specific.
2020-07-17 08:49:03 +02:00
Johan T. Halseth d41ca81aad make: add goimports dep
Required by mobile bindings generate script.
2020-07-17 08:49:02 +02:00
Johan T. Halseth b55b7025b0 travis: sanity check mobile build compilation 2020-07-17 08:49:02 +02:00
Johan T. Halseth fd8e6c98b9 make: fetch falafel dependency for mobile-rpc 2020-07-17 08:49:02 +02:00
Johan T. Halseth 7a30332619 mobile: use single "mobile" build tag instead of "ios" and "android"
Since the "android" build tag conflicts with a go compiler build tag, we instead use a single "mobile" tag for both platforms.
2020-07-17 08:49:02 +02:00
Johan T. Halseth f360ec71bf mobile: restore config parsing for mobile bindings
A recent commit moved the config parsing out of lnd's Main method. This
commit makes the mobile bindings compile with this change.
2020-07-17 08:49:02 +02:00
Johan T. Halseth 5e72a4b77c routing: exit on unexpected RequestRoute error
We whitelist a set of "expected" errors that can be returned from
RequestRoute, by converting them into a new type noRouteError. For any
other error returned by RequestRoute, we'll now exit immediately.
2020-04-02 19:31:24 +02:00
Johan T. HalsethandJoost Jager fee5fd0093 itest: add testSendToRouteMultiPath
testSendToRouteMultiPath tests that we are able to successfully route a
payment using multiple shards across different paths, by using SendToRoute.

Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-04-02 19:31:23 +02:00
Johan T. Halseth 95c5a123c8 routing/router_test: add TestSendToRouteMultiShardSend 2020-04-02 19:31:23 +02:00
Johan T. Halseth 864e64e725 channeldb: validate MPP options when registering attempts
We add validation making sure we are not trying to register MPP shards
for non-MPP payments, and vice versa. We also add validtion of total
sent amount against payment value, and matching MPP options.

We also add methods for copying Route/Hop, since it is useful to use
for modifying the route amount in the test.
2020-04-02 19:31:23 +02:00
Johan T. Halseth 9a1ec950bd channeldb/payments: extract common info fetch into fetchCreationInfo 2020-04-02 19:29:15 +02:00
Johan T. Halseth 36a80b4d51 routing/router: enable MPP sends for SendToRoute
This commit enables MPP sends for SendToRoute, by allowing launching
another payment attempt if the hash is already registered with the
ControlTower.

We also set the total payment amount of of the payment from mpp record,
to indicate that the shard value might be different from the total
payment value.

We only mark non-MPP payments as failed in the database after
encountering a failure, since we might want to try more shards for MPP.
For now this means that MPP sendToRoute payments will be failed
only after a restart has happened.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 431372c0cf routing/payment_lifecycle_test: add MPP test cases 2020-04-02 19:29:15 +02:00
Johan T. Halseth 7b318a4be7 routing/payment_lifecycle+channeldb: enable multi shard send
This commit finally enables MP payments within the payment lifecycle
(used for SendPayment). This is done by letting the loop launch shards
as long as there is value remaining to send, inspecting the outcomes for
the sent shards when the full payment amount has been filled.

The method channeldb.MPPayment.SentAmt() is added to easily look up how
much value we have sent for the payment.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 0fd71cd596 routing/payment_lifecycle_test: add step for terminal failure
And modify the MissionControl mock to return a non-nil failure reason in
this case.
2020-04-02 19:29:15 +02:00
Johan T. Halseth 2e63b518b7 routing/payment_lifecycle_test+mock: set up listener for FailAttempt
Also rename Success to SettleAttempt in the tests.
2020-04-02 19:29:15 +02:00
Johan T. Halseth aa9c971dc0 routing/payment_lifecycle_test: extract route creation into method
This also fixes a test bug that the manually created route didn't match
the actual payment amount in the test cases, and adds some fees to the
route.
2020-04-02 19:29:14 +02:00
Johan T. Halseth 4d343bbb46 routing tests: move TestRouterPaymentStateMachine to own file
(almost) PURE CODE MOVE
The only code change is to change a few select cases from

case _ <- channel:
to
case <- channel:

to please the linter.

The test is testing the payment lifecycle, so move it to
payment_lifecycle_test.go
2020-04-02 19:29:14 +02:00
Johan T. Halseth 3610824abd channeldb/payment_control_test: add TestPaymentControlMultiShard 2020-04-02 19:29:14 +02:00
Johan T. Halseth 70202be580 channeldb: make database logic MPP compatible
This commit redefines how the control tower handles shard and payment
level settles and failures. We now consider the payment in flight as
long it has active shards, or it has no active shards but has not
reached a terminal condition (settle of one of the shards, or a payment
level failure has been encountered).

We also make it possible to settle/fail shards regardless of the payment
level status (since we must allow late shards recording their status
even though we have already settled/failed the payment).

Finally, we make it possible to Fail the payment when it is already
failed. This is to allow multiple concurrent shards that reach terminal
errors to mark the payment failed, without havinng to synchronize.
2020-04-02 19:29:14 +02:00
Johan T. Halseth f6c97daf0c channeldb/payment_control_test: simplify HTLC status assertion 2020-04-02 10:24:36 +02:00
Johan T. Halseth 5adfc968df routing/payment_lifecycle: return recorded errors
In preparation for MPP we return the terminal errors recorded with the
control tower. The reason is that we cannot return immediately when a
shard fails for MPP, since there might be more shards in flight that we
must wait for. For that reason we instead mark the payment failed in the
control tower, then return this error when we inspect the payment,
seeing it has been failed and there are no shards in flight.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 7b5c10814b routing/payment_lifecycle+channeldb: collect existing outcome first
To move towards how we will handle existing attempt in case of MPP
(collecting their outcome will be done in separate goroutines separate
from the payment loop), we move to collect their outcome first.

To easily fetch HTLCs that are still not resolved, we add the utility
method InFlightHTLCs to channeldb.MPPayment.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 49efbefb43 routing/payment_session: remove prebuilt payment session
Since we no longer use payment sessions for send to route, we remove the
prebuilt one.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 4509c4f3a9 routing: move ErrMaxRouteHopsExceeded check
Now that SendToRoute is no longer using the payment lifecycle, we move
the max hop check out of the payment shard's launch() method, and return
the error directly, such that it can be handled in SendToRoute.
2020-04-02 10:24:35 +02:00
Johan T. Halseth a979b91b27 routing: remove errNoRoute and lastError
Now that SendToRoute is no longer using the payment lifecycle, we
remove the error structs and vars used to cache the last encountered
error. For SendToRoute this will now be returned directly after a shard
has failed.

For SendPayment this means that the last error encountered durinng
pathfinding no longer will be returned. All errors encounterd can
instead be inspected from the HTLC list.
2020-04-02 10:24:35 +02:00
Johan T. Halseth 6cc162e0b0 router: make sendToRoute omit payment lifecycle
Instead of having SendToRoute pull routes from the payment session in
the payment lifecycle, we utilize the new methods on the paymentShard to
launch and collect the result for this single route.

This also let us remove the check for noRouteError, as we will always
have the result from the tried attempt returned. A result of this is
that we can finally remove lastError from the payment lifecycle (see
next commits).
2020-04-02 10:24:35 +02:00
Johan T. Halseth 2c01e79eb5 routing/payment_lifecycle: extract result collection into collectResult
Fetching the final shard result will also be done for calls to
SendToRoute, so we extract this code into a new method.

We move the call to the ControlTower to set the payment level failure
out into the payment loop, as this must be handled differently when
multiple shards are in flight, and for SendToRoute.
2020-04-02 10:24:34 +02:00
Johan T. Halseth 9712dd1a7f routing/payment_lifecycle: extract attempt sending logic
Define shardHandler which is a struct holding what is needed to send
attempts along given routes. The reason we define the logic on this
struct instead of the paymentLifecycle is that we later will make
SendToRoute calls not go through the payment lifecycle, but only using
this struct.

The launch shard is responsible for registering the attempt with the
control tower, failing it if the launch fails. Note that it is NOT
responsible for marking the _payment_ failed in case a terminal error is
encountered. This is important since we will later reuse this method for
SendToRoute, where whether to fail the payment cannot be decided on the
shard level.
2020-04-02 10:24:34 +02:00
Johan T. Halseth bcca1ab821 routing/payment_lifeycle: remove payment level attempt and circuit
We replace the cached attempt, and instead use the control tower
(database) to fetch any in-flight attempt. This is done as a
preparation for having multiple attempts in flight.

In addition we remove the cached circuit, as it won't be applicable when
multiple shards are in flight.

Instead of tracking the attemp we consult the database on every
iteration, and pick up any existing attempt. This also let us avoid
having to pass in the existing attempts from the payment loop, as we
just fetch them direclty.
2020-04-02 10:24:34 +02:00