Commit Graph
100 Commits
Author SHA1 Message Date
Joost Jager 5bebda8c5d multimutex: add hash mutex 2020-04-08 08:54:05 +02:00
Joost Jager f907fbcadc queue: detect close of incoming channel 2020-04-08 08:54:03 +02:00
Joost JagerandJohan T. Halseth 278915e598 channeldb: return updated payment on attempt update
Similar to what is done for SettleAttempt.

Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2020-04-08 08:54:01 +02:00
Joost Jager 351d8e174c lnrpc: expose payment failure reason 2020-04-08 08:53:59 +02:00
Joost Jager 327634e9f7 routerrpc: move payment marshalling 2020-04-08 08:53:57 +02:00
Joost Jager 5d0a117162 routing: fix log 2020-04-08 08:14:10 +02:00
Joost Jager afaabdae88 Merge pull request #4128 from joostjager/default-routerrpc
routerrpc+lncli: enable subserver by default and switch over lncli sendpayment
2020-03-31 23:30:25 +02:00
Joost Jager 6b649eeb10 lncli: remove unused type chain 2020-03-31 22:05:00 +02:00
Joost Jager 3191b949f5 lnrpc: deprecate SendPayment
There is an alternative in routerrpc now. It doesn't support REST yet,
but the main rpc SendPayment with its bidirectional streaming isn't
usable via REST either.

SendPaymentSync still serves REST users and cannot be deprecated yet.
2020-03-31 21:41:34 +02:00
Joost Jager 37849194f4 lncli: add trackpayment command 2020-03-31 21:41:32 +02:00
Joost Jager acefb64207 routerrpc: remove payment-level route field
With multi-part payments, a payment-level route field does not make
sense anymore.
2020-03-31 21:41:30 +02:00
Joost Jager dead6a772a lncli: use routerrpc for payments 2020-03-31 21:41:28 +02:00
Joost Jager f060da3971 lncli: move payment commands to separate file 2020-03-31 21:41:26 +02:00
Joost Jager 767c4f2298 routerrpc: remove reflection-based initialization 2020-03-31 21:41:24 +02:00
Joost Jager ffa7bed7f0 build+routerrpc+lncli: remove routerrpc conditional compilation 2020-03-31 21:41:22 +02:00
Joost Jager e11a3b24d8 lnrpc/routerrpc: rename RoutingConfig file 2020-03-31 21:41:20 +02:00
Joost Jager bc7ee9a7d0 routerrpc: fix empty payment request bug 2020-03-31 21:41:18 +02:00
Joost Jager 7ba5bf69e0 Merge pull request #4129 from joostjager/pending-close-type
lnrpc: expose commitment type on pending open and waiting close channels
2020-03-31 21:40:24 +02:00
Joost Jager baffe156db lnrpc: expose commitment type on pending open and waiting close channels 2020-03-31 19:35:52 +02:00
Joost Jager 41573004a3 lnrpc: extract rpcCommitmentType 2020-03-31 19:35:50 +02:00
Joost Jager a2336005e6 Merge pull request #4113 from joostjager/mc-failure-overwrite
routing: minimum failure relaxation interval
2020-03-28 11:10:26 +01:00
Joost Jager 1a6b28553a routing: stricter mission control state failure updates
This commit puts a mechanism in place to prevent a failure for a low
amount from being overwritten very soon after by a higher amount
failure.
2020-03-28 07:49:23 +01:00
Joost JagerandJohan T. Halseth 8628a989a6 itest: enable anchor commitment for multi-hop test
These tests exercise the different ways of sweeping a commitment, so
we'll cover the modified scripts used for anchor commitments and
spending the anchor itself by both parties.

Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2020-03-27 08:01:52 +01:00
Joost JagerandJohan T. Halseth 23c81949cc itest: enable anchor type for force close test
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2020-03-27 08:01:50 +01:00
Joost JagerandJohan T. Halseth 714166eeb0 itest: enable anchor type for basic funding flow
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2020-03-27 08:01:48 +01:00
Joost Jager 7dbb936791 lntest/itest: use helper functions in calcStaticFee 2020-03-27 08:01:44 +01:00
Joost Jager 0e8eb40625 lntest/itest: add mempool tx utility functions 2020-03-27 07:42:05 +01:00
Joost Jager b3afa0c9ed sweep: log sweep tx id and full list of inputs
To facilitate debugging.
2020-03-27 07:42:03 +01:00
Joost Jager 8b7bde7200 cnct: log txid for force close 2020-03-27 07:42:01 +01:00
Joost Jager 863966bac9 lntest/itest: fix scope bug
Fixes a subtle bug where the outer scope predErr was hidden when the
return value of findForceClosedChannel was stored in a newly
defined variable with the same name.
2020-03-27 07:41:59 +01:00
Joost Jager 6e30dda54f Merge pull request #4114 from joostjager/routing-logging
routing+htlcswitch: logging improvements
2020-03-25 12:15:39 +01:00
Joost Jager 36e1b92e0c routing: log reported success amount 2020-03-24 19:02:40 +01:00
Joost Jager 2d07756263 routing: log amount for probability 2020-03-24 19:02:38 +01:00
Joost Jager 6a36ed44f8 routing: extract mission control state
Preparation for unit testing just the state logic.
2020-03-24 16:48:35 +01:00
Joost Jager e2052f7f65 Merge pull request #3758 from joostjager/anchor-output-poc-joost
cnct: anchor output sweeping and fee bumping
2020-03-18 18:59:06 +01:00
Joost Jager fa115b543d lncli: add bumpchannelclose command
This command allows users to easily bump the fee on their unconfirmed
closing transactions.
2020-03-18 12:27:06 +01:00
Joost Jager d60303b092 lnrpc: expose commit hashes for waiting close channels
To make it easier to determine which pending sweep to bump in order to
get your anchor commitment tx confirmed.
2020-03-18 12:27:05 +01:00
Joost Jager ab451f634e cnct+lnrpc: report anchor resolution 2020-03-18 12:27:03 +01:00
Joost Jager ea397c9d6e cnct: resolve anchors post-confirmation
Sweeping anchors and being able to bump the fee was already added in a
previous commit. This commit extends anchor sweeping with an anchor
resolver object that becomes active after the commitment tx confirms.
At that point, the anchors do not serve the purpose of getting the
commitment tranaction confirmed anymore. It is however still possible to
reclaim some of their value if using a low fee rate.
2020-03-18 12:27:01 +01:00
Joost Jager d84b596f55 cnct: do not ignore resolver reports after resolution
Preparation for anchor resolver. The recovered anchor amount should
still be included in the pending channel report even after it has been
resolved.

This also fixes an existing bug that in some cases caused the recovered
amount from an htlc resolver not to be included in the total.
2020-03-18 12:26:59 +01:00
Joost Jager 07a39b1ebf cnct: do not persist stateless resolvers
Preparation for the anchor resolver which does not have persistent
state.
2020-03-18 12:26:57 +01:00
Joost Jager d2b6472843 cnct: pre-confirmation anchor sweep
Start anchor sweep attempts immediately after the commitment transaction
has been published. This makes the anchor known to the sweeper and
allows the user to bump the fee on it to get their commitment
transaction confirmed in case the fee committed too is insufficient for
timely confirmation.
2020-03-18 12:26:55 +01:00
Joost Jager e8e99c6533 cnct: simplify channel arbitrator state logging 2020-03-17 16:25:39 +01:00
Joost Jager 3b517390d8 cnct+sweeper: give contract court access to relay fee
Relay fee is needed later to sweep anchors at the minimum fee rate.
2020-03-17 16:25:37 +01:00
Joost Jager c376cdb733 input: add anchor witness type 2020-03-17 16:25:35 +01:00
Joost Jager dd77d9263e cnct: persist anchor resolutions 2020-03-17 16:25:33 +01:00
Joost Jager 7f3d4e7d49 cnct: create channel interface for arbitrator
Allows unit testing of the channel arbitrator with fewer dependencies.
This is a preparation for the addition of anchor sweeping.
2020-03-17 16:25:31 +01:00
Joost Jager c0b1b3be14 cnct: always set trigger height to close height
Prior to this change, the trigger height for closed channels was set to
the current best block height. As this height is in some cases used as a
height hint, the spend may have been missed.
2020-03-17 16:25:29 +01:00
Joost Jager 29e1489179 sweep: leave exclusive group unchanged on parameter update
Exclusive group is a static property that doesn't need to be updated.
Requiring the exclusive group to be passed into UpdateParams creates a
burden for the caller to make sure they supply the existing group.

This change will be beneficial for users that bump anchor sweeps that
have exclusive groups set.
2020-03-17 14:19:39 +01:00
Joost Jager 1c93e9e03d sweep: isolate min fee rate bucket 2020-03-17 14:19:37 +01:00
Joost Jager 30fc03d84d lnwallet/test: pass in test channel type 2020-03-17 14:19:33 +01:00
Joost Jager c0cb05d7b4 lnrpc: expose raw htlc failure
Adds a new rpc field to the payment htlc proto message and populates it
with data that is now stored in the db.
2020-03-09 18:31:41 +01:00
Joost Jager 866623e84b channeldb/migration13: migrate to mpp structure
This commit migrates the payments in the database to a new structure
that allows for multiple htlcs per payments. The migration introduces a
new sub-bucket that contains a list of htlcs and moves the old single
htlc into that.
2020-03-09 18:31:39 +01:00
Joost Jager 4cea2d5213 channeldb/migtest: add migration test tools
This commit adds test helper code to dump, restore and verify the
low-level bbolt database structure.
2020-03-09 18:31:37 +01:00
Joost Jager f86e68a1a2 channeldb+routing: store full htlc failure reason
This commit extends the htlc fail info with the full failure reason that
was received over the wire. In a later commit, this info will also be
exposed on the rpc interface. Furthermore it serves as a building block
to make SendToRoute reliable across restarts.
2020-03-09 18:31:35 +01:00
Joost JagerandJohan T. Halseth 48c0e42c26 channeldb+routing: store all payment htlcs
This commit converts the database structure of a payment so that it can
not just store the last htlc attempt, but all attempts that have been
made. This is a preparation for mpp sending.

In addition to that, we now also persist the fail time of an htlc. In a
later commit, the full failure reason will be added as well.

A key change is made to the control tower interface. Previously the
control tower wasn't aware of individual htlc outcomes. The payment
remained in-flight with the latest attempt recorded, but an outcome was
only set when the payment finished. With this commit, the outcome of
every htlc is expected by the control tower and recorded in the
database.

Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2020-03-09 18:31:33 +01:00
Joost Jager 8558534417 routing: add clock to router config 2020-03-09 11:43:44 +01:00
Joost Jager c357511051 channeldb/migtest: remove channeldb dependency
Removes this unnecessary dependency allowing migration code to use
utility functions from channeldb/migtest.
2020-03-09 11:43:42 +01:00
Joost Jager 4c74c0817e channeldb/test: extend payment control test with failed attempt 2020-03-09 11:43:40 +01:00
Joost Jager fa3a762a2c channeldb: add error return value to fetchPaymentStatus
Preparation for when we need to return errors in a next commit.
2020-03-09 11:43:38 +01:00
Joost Jager e6e9e44e6f routerrpc: extract wire error marshalling
Preparation for marshalling wire errors as part of rpc payment lookups.
2020-03-09 11:43:36 +01:00
Joost Jager 3f5ba35dea routerrpc: move marshall functions out of conditionally compiled file
These functions will (indirectly) be called by the main rpc server and
can no longer stay conditionally compiled.
2020-03-09 11:43:34 +01:00
Joost Jager 6aab6c0bac routerrpc+lnrpc: move htlc failure messages
In a later commit, htlc raw failure messages will be exposed through the
main rpc. This is a preparation for that.
2020-03-09 11:43:32 +01:00
Joost Jager cc5e18c487 channeldb: isolate duplicate payments
Duplicate payments is legacy that we keep alive for accounting purposes.
This commit isolates the deserialization logic for duplicate payments in
its own file, so that regular payment logic and db structure can evolve
without needing to handle/migrate the legacy data.
2020-03-09 11:43:30 +01:00
Joost Jager c29b74168f channeldb/test: refactor payment control test
Previously this was tested as a white box. Database access methods were
duplicated as test code and compared to the return value of the code
under test. This approaches leads to brittle test because it relies
heavily on implementation details. This commit changes this and prepares
for additional test coverage being added in later commits.
2020-03-09 11:43:28 +01:00
Joost Jager 967b4b2dc3 channeldb: remove redundant MPPaymentCreationInfo struct
MPPaymentCreationInfo and PaymentCreationInfo are identical except for
the naming of CreationTime/CreationDate.
2020-03-09 11:43:24 +01:00
Joost Jager b75259a3e2 Merge pull request #3951 from joostjager/exclusive-group-sweeper
sweep: add exclusive groups
2020-02-14 12:30:53 +01:00
Joost Jager 9dc349488b sweep: add exclusive groups
Allows certain sweep inputs to be kept in separate transactions at all
times. This is a preparation for anchor outputs. Before the commitment
tx confirms, there are three potential anchors that can be cpfp'ed. We
want to cpfp them all, but if done in the same transaction, the
transaction would guaranteed to be invalid. Exponential backoff would
eventually get the txes published, but having exclusive groups makes the
process faster.
2020-02-13 09:52:21 +01:00
Joost Jager 69a6107d06 sweep: log full parameter struct 2020-02-12 09:59:43 +01:00
Joost Jager 2c08a8b9a8 Merge pull request #3992 from joostjager/restore-update-fix
lnwallet: fix invalid value use in restoreUpdate
2020-02-11 18:26:51 +01:00
Joost Jager 0a27361a77 Merge pull request #3964 from joostjager/routing-multi-unit-test
routing/test: integrated routing test
2020-02-11 16:12:54 +01:00
Joost Jager 29476ec6a3 routing/test: test probability extrapolation
Adds an integrated routing test of probability extrapolation for untried
channels. The larger part of this commit is mock code to simulate the
Lightning Network.

The difference between this test and the existing pathfinding tests, is that
this test focuses on the feedback loop from result interpretation via
mission control updates and probability estimation back to pathfinding.
Improvements like probability extrapolation were previously only
validated by reasoning, while this setup makes it possible to assert the
improvement in a test and guard it for the future.
2020-02-11 14:19:13 +01:00
Joost Jager 06bdeb56e2 routing: add graph interface 2020-02-11 13:35:38 +01:00
Joost Jager a8ed1b342a routing: remove pathfinding db tx
Pathfinding is never used with an externally supplied bbolt transaction.
2020-02-10 19:55:40 +01:00
Joost Jager 88eae6eafe lnwallet: fix invalid value use in restoreUpdate
Updates were always restored with the same log index. This could cause a
crash when the logs were compacted and possibly other problems
elsewhere.

Extended unit test to cover the crash scenario.
2020-02-10 13:56:33 +01:00
Joost Jager 0042a1ffeb invoices: fix htlc timer deadlock 2020-02-04 15:22:08 +01:00
Joost Jager 51324ac7ae invoices: move log into update context 2020-02-04 15:22:06 +01:00
Joost Jager a339065fdc invoices: add hash to update context 2020-02-04 15:22:04 +01:00
Joost Jager da6b33f0b9 Merge pull request #3979 from carlaKC/lnd-fixlinter
lnd: fix gosimple linter failure
2020-02-04 10:16:34 +01:00
Joost Jager 1413995ab7 Merge pull request #3872 from joostjager/invalid-sig-fix
htlcswitch+lnwallet+channeldb: invalid sig fix
2020-01-23 21:08:07 +01:00
Joost Jager b573a5e61a Merge pull request #3797 from joostjager/explicit-now-dependency-channeldb
channeldb: inject clock into database
2020-01-23 14:27:02 +01:00
Joost Jager 1851dfdcf7 Merge pull request #3947 from joostjager/missing-result-strings
invoices: add missing String() cases
2020-01-23 11:47:06 +01:00
Joost Jager ae9c6faebf Merge pull request #3809 from joostjager/anchor-sweeper
sweep: allow force sweeping of negatively yielding inputs
2020-01-23 11:46:46 +01:00
Joost Jager c7208ffb2c invoices: add missing String() cases 2020-01-21 16:52:13 +01:00
Joost Jager ef28d2aaed routing: penalize node-level failures harder
Previously we only penalized the outgoing connections of a failing node.
This turned out not to be sufficient, because the next route sometimes
went into the same failing node again to try a different outgoing
connection that wasn't yet known to mission control and therefore not
penalized before.
2020-01-21 09:06:42 +01:00
Joost Jager b600ecda86 channeldb: inject clock into database
Use our standard clock mock for database time queries.
2020-01-20 11:08:30 +01:00
Joost Jager 3aba0f1eaf Merge pull request #3918 from joostjager/fix-qr-hints
routing: remove path finding shortcut
2020-01-15 23:06:05 +01:00
Joost Jager e9b7e80848 routing: remove path finding shortcut
This shortcut does not work when the destination is a private node. We
also don't have this shortcut for regular payments. This commit
aligns the behavior between SendPayment and QueryRoutes.
2020-01-15 20:32:45 +01:00
Joost Jager b0aae13d70 sweep: allow force sweeps 2020-01-15 16:56:44 +01:00
Joost Jager 14237f5fd4 sweep: create add constraints
This refactor prepares for the addition of specific constraints for
force sweep inputs.
2020-01-15 16:56:42 +01:00
Joost Jager 16832cefa3 sweep: allow updating all sweep parameters
This is a preparation for adding additional parameters besides the fee
preference.
2020-01-15 16:56:40 +01:00
Joost Jager 27139b8c28 Merge pull request #3917 from cfromknecht/send-coin-bech32
lncli: fix sendcoins docs, allow base58 or bech32 addrs
2020-01-15 16:19:14 +01:00
Joost Jager 82579400b3 lnwallet: restore unsigned acked remote updates
This commit updates the channel state machine to
persistently store remote updates that we have received a
signature for, but that we haven't yet included in a commit
signature of our own.

Previously those updates were only stored in memory and
dropped across restarts. This lead to the production of
an invalid signature and channel force closure. The remote
party expects us to include those updates.
2020-01-15 13:09:35 +01:00
Joost Jager ed8fa35ed4 lnwallet: extract pending local updates restore method
Extract method in preparation for restoring dangling remote updates. We
need to get rid of the early return.
2020-01-15 12:37:26 +01:00
Joost Jager 2d37d341a1 channeldb: extract log update serialization
Extract functionality to methods as a preparation for serializing remote
log updates.
2020-01-15 12:37:24 +01:00
Joost Jager ea892fce17 channeldb: update UpdateCommitment description
This method is only used to update the local commitment transaction.
Updated comment accordingly.
2020-01-15 12:37:22 +01:00
Joost Jager 6a866890a8 lnwallet/test: test remote update after restart
This test asserts that remote updates that are locked-in on the local
commitment, but haven't been signed for on the remote commitment, are
properly restored after a restart.
2020-01-15 12:37:20 +01:00
Joost Jager 5de308c4b5 routerrpc: update final cltv delta default
The default was increased for the main sendpayment RPC in commit
d3fa9767a9. This commit sets the
same default for QueryRoutes, routerrpc.SendPayment and
router.EstimateRouteFee.
2020-01-14 21:03:24 +01:00
Joost Jager d978b55701 lncli: add custom data payment flag 2020-01-14 13:01:45 +01:00
Joost Jager 81bf6e15b3 routing+lnrpc: add missing query routes parameters 2020-01-14 11:21:31 +01:00