Commit Graph
100 Commits
Author SHA1 Message Date
Joost Jager 784c0631f3 rpcserver: expose store final htlc resolutions flag on info call
The storage of final htlc resolutions is a safety-critical feature. By
exposing it through the GetInfo call, connected applications can
ensure that the feature is turned on and avoid relying on the assumption
that lnd was configured correctly.
2023-02-13 11:53:27 +01:00
Joost Jager db5dc4d360 rpcserver: fix line lengths 2023-02-13 11:53:10 +01:00
Joost Jager 7a785c74c4 channeldb: final htlc resolution storage opt-in 2023-01-26 07:02:17 +01:00
Joost Jager 1725e5bcbe kvdb: bump etcd to v3.5.7 2023-01-24 13:52:20 +01:00
Joost Jager b50d59ec2e lnwallet/test: assert final resolution db storage 2023-01-24 13:34:02 +01:00
Joost Jager 3835b903a9 lnwire: limit channel update reader
Fixes a bug where channel update data is read until the end of the stream
rather than stopping after the specified length. This is problematic
when failure message tlv data is present, because this data is interpreted
as channel update tlv data.
2023-01-04 13:32:52 +01:00
Joost Jager 4c8ea29336 lnwire: allow longer failure messages
This fixes an incompatibility where lnd enforces a strict 256 byte
failure message, where as the spec sets this only as the recommended
length.
2022-12-02 14:27:59 +01:00
Joost Jager 5ff5838d74 lnwire: add extra opaque data to FailIncorrectDetails 2022-12-02 09:28:03 +01:00
Joost Jager 5f4465b14f link: ensure minimum failure reason length
This commit modifies the link behavior so that every failure
reason that we pass back is length-compliant (>=256 bytes).
2022-12-02 09:28:02 +01:00
Joost Jager 9730bc1ca0 lnwire: verify failure message length
Adds extra checks to make sure the failure message
is well-formed.
2022-12-02 09:04:59 +01:00
Joost Jager e9440a24a2 htlcswitch/test: more realistic mock encryption
This mock is used in the switch test TestUpdateFailMalformedHTLCErrorConversion.
But because the mock isn't very realistic, it doesn't detect problems
in the handling of malformed failures in the link.
2022-12-02 09:04:59 +01:00
Joost Jager 3a89a84744 rpcserver: add LookupHtlc call 2022-10-27 16:43:09 +02:00
Joost Jager 511fb00777 htlcswitch: add final htlc event to notifier 2022-10-27 16:42:36 +02:00
Joost Jager 28256b7ea8 htlcswitch: keep final htlc outcome 2022-10-27 16:42:36 +02:00
Joost Jager b85cda2a1d routerrpc: add htlc notifier subscribed event 2022-10-27 16:42:35 +02:00
Joost Jager 6e073cb213 rpcserver: expose graph tlv data 2022-10-25 18:17:35 +02:00
Joost Jager 0663a92bff rpcserver: extract marshalNode 2022-10-25 18:17:34 +02:00
Joost Jager 01e7f09dfb rpcserver: extract marshalDBRoutingPolicy 2022-10-25 15:24:48 +02:00
Joost Jager a0a50fa844 htlcswitch: auto-fail held htlcs
Make the interceptable switch aware of htlc expiry and fail back htlcs in-time
to prevent the counterparty from force-closing the channel.
2022-10-18 18:06:49 +02:00
Joost Jager 74eeb95e8c htlcswitch: add error return value to NewInterceptableSwitch
Prepares for parameter validation.
2022-10-18 18:04:34 +02:00
Joost Jager 93a7cab46e htlcswitch/test: create interceptableSwitchTestContext
Refactor to prepare for adding more tests.
2022-10-18 18:04:34 +02:00
Joost Jager 9c063db698 htlcswitch: add heldHtlcSet
Isolation of the set logic so that it will be easier to add watchdog functionality later.
2022-10-18 18:04:33 +02:00
Joost Jager a6df9567ba htlcswitch: add dedicated block subscription to interceptable switch
Preparation for making the interceptable switch aware of expiring htlcs.
2022-10-18 18:04:33 +02:00
Joost Jager 4a3e90f4d0 htlcswitch: add InterceptableSwitchConfig
Preparation for adding more config options.
2022-10-18 18:04:33 +02:00
Joost Jager fe8a1f2f36 lncli: fix sendpayment arg parsing 2022-08-25 13:24:19 +02:00
Joost Jager caf11d2607 rpcserver: expose interceptor required flag on info call 2022-04-25 11:05:18 +02:00
Joost Jager 3ad9a42e65 rpcserver: remove unnecessary conversion 2022-04-25 11:05:04 +02:00
Joost Jager 62ae0387ff htlcswitch+invoices: log payment metadata 2022-04-13 22:55:42 +02:00
Joost Jager 9195f29e61 routing+channeldb: send payment metadata from invoice 2022-04-13 22:55:40 +02:00
Joost Jager 135e27ddd3 zpay32: add payment metadata field 2022-04-13 22:55:38 +02:00
Joost Jager ba5abdc090 routing: add time_pref parameter to queryroutes and sendpayment 2022-04-13 20:26:46 +02:00
Joost Jager 269a8e74d3 routing: refactor reliability penalty calculation
Base the calculation on the actual float64 overflow point rather than an
indirect limit on probability.

This is a preparation for an infinite attempt cost.
2022-04-13 20:26:08 +02:00
Joost Jager 721fb4ee88 contractcourt: add onchain interception 2022-04-13 11:31:33 +02:00
Joost Jager c392e003aa beacon: add witness cache interface 2022-04-13 11:31:31 +02:00
Joost Jager 7265a5e42b beacon: add constructor 2022-04-13 11:31:29 +02:00
Joost Jager 57e08dfa54 htlcswitch: refactor interceptForward
Preparation for adding on-chain interception.
2022-04-13 10:14:42 +02:00
Joost Jager 13dff2fb3e htlcswitch: interceptor expiry check 2022-04-12 08:27:06 +02:00
Joost Jager bae0b6bdf9 htlcswitch/test: isolate test packets
Decouple the tests somewhat and fix a bug along the way where the test
passed because of a left-over package from a prior test.
2022-04-12 08:27:04 +02:00
Joost JagerandJuan Pablo Civile ae314ec794 htlcswitch: add an always on mode to interceptable switch
Co-authored-by: Juan Pablo Civile <elementohb@gmail.com>
2022-03-17 17:39:37 +01:00
Joost Jager 169f0c0bf4 routerrpc+htlcswitch: move intercepted htlc tracking to switch
In this commit we move the tracking of the outstanding intercepted htlcs
to InterceptableSwitch. This is a preparation for making the htlc
interceptor required.

Required interception involves tracking outstanding htlcs across
multiple grpc client sessions. The per-session routerrpc
forwardInterceptor object is therefore no longer the best place for
that.
2022-03-15 08:44:57 +01:00
Joost Jager e2b56f212f htlcswitch: accept failure reason for intercepted htlcs 2022-02-01 17:18:59 +01:00
Joost Jager 352008a0c2 channeldb: speed up graph cache loading
Use the optimized ForEachChannel method to reduce the graph cache
loading time.
2022-01-14 14:57:29 +01:00
Joost Jager 2e2229a2e7 channeldb: reallocate node in ForEachNodeCacheable
Allows cacheableNode to be used outside of the callback. This is a
preparation for optimization of the graph cache population.
2022-01-14 14:57:27 +01:00
Joost Jager cb4703638f channeldb: optimize ForEachChannel
In this commit, we modify the implementation of ForEachChannel to
utilize the new kvdb method ForAll. This greatly reduces the number of
round-trips to the database needed to iterate over all channels
in the graph.
2022-01-14 14:57:25 +01:00
Joost Jager 54324d554a channeldb: extract deserializeChanEdgePolicyRaw
Allows for pure deserialization without depending on a database connection.
2022-01-12 19:11:56 +01:00
Joost Jager aff9685a61 channeldb: extract AddNodeFeatures
Preparation for efficient graph cache loading where we don't iterate
over the channels of each node in the network individually.
2022-01-12 19:11:54 +01:00
Joost Jager b8408a1484 kvdb: add ForAll
A new method to allow efficient range queries for backends that support
it.
2022-01-12 19:11:53 +01:00
Joost Jager 102a1cbaaa routing: remove unused ForEachChannel 2022-01-12 13:38:58 +01:00
Joost Jager 99566b768e kvdb/postgres: use readonly db transaction if possible 2022-01-12 13:38:56 +01:00
Joost Jager 7cd7cef6c6 htlcswitch: fix duplicate close
The decayed log database opening and closing is managed at a higher
level in config_builder.go.
2022-01-10 08:42:32 +01:00
Joost Jager 2009aec59d itest: increase pg database connection limit 2022-01-04 08:29:22 +01:00
Joost Jager f99b472bbb lncli: add lockid parameter to releaseoutput 2022-01-03 18:21:12 +01:00
Joost Jager 0b2388bd4b lncli: add leaseoutput command 2022-01-03 18:21:10 +01:00
Joost Jager 0cae55c162 kvdb/postgres: fix context cancellation 2021-12-22 14:54:43 +01:00
Joost Jager 62a2f3c809 kvdb/postgres: fix tests 2021-12-22 14:54:41 +01:00
Joost Jager 274faff980 postgres: add connection limit 2021-11-17 11:08:43 +01:00
Joost Jager d997bbf6b3 channeldb/test: test with postgres 2021-10-29 10:54:44 +02:00
Joost Jager 7c048efa21 kvdb/postgres/test: single instance embedded postgres database
Prepare for parallel tests that use a postgres backend. We don't want a
high number of embedded postgres instances running simultaneously.
2021-10-29 10:54:42 +02:00
Joost Jager bd291286f7 kvdb/postgres: convert all types of panic data to error
Previously the assumption existed that panic data was already an error.
If that wasn't the case for example because panic("string") was used,
the transaction wasn't unlocked.
2021-10-29 10:54:40 +02:00
Joost Jager ade50d0b2c lnrpc: receive custom message 2021-10-15 17:08:55 +02:00
Joost Jager ae959b16ae lnrpc: send custom message 2021-10-15 17:08:53 +02:00
Joost Jager 369c09be61 channeldb+routing: add in-memory graph
Adds an in-memory channel graph cache for faster pathfinding.

Original PoC by: Joost Jager
Co-Authored by: Oliver Gugger
2021-09-29 17:00:04 +02:00
Joost Jager daeb96fe0a postgres: add itest 2021-09-21 10:44:23 +02:00
Joost Jager ae6cf72b46 lncfg: add postgres 2021-09-21 10:44:20 +02:00
Joost Jager 3eb80cac97 kvdb: add postgres 2021-09-21 10:44:18 +02:00
Joost Jager 3827d15ca6 lntest/itest: fix SendPaymentAMP test 2021-09-14 18:53:17 +02:00
Joost Jager bd07b5f49e routing/localchans: fix nested db tx
This commit fixes a bug where a db tx is opened within another db tx.
2021-08-24 13:43:26 +02:00
Joost Jager 3f775778c3 channeldb+routing: add tx parameter
Adds an optional tx parameter to ForAllOutgoingChannels and FetchChannel
so that data can be queried within the context of an existing database
transaction.
2021-08-24 13:43:24 +02:00
Joost Jager 925229f9df walletrpc+lncli: allow zero output psbt funding
To support the cpfp fee bump use case where no external outputs are
required.
2021-08-16 08:41:50 +02:00
Joost Jager 09386213be htlcswitch: log link message with channel point
In lnd, log messages about channels are generally logged with a
reference to their channel point rather than the short channel id.
Channel point is reorg-resistant and also easier to look up in for
example a block explorer.

In the link however, all log messages are accompanied by short channel
id. This makes it difficult to grep a log for all channel activity. The
PEER message for example which are often crucial to analyse, are logged
with channel points.

This commit modifies the link logging to also use channel points.
2021-08-16 08:24:35 +02:00
Joost Jager e9cba1a526 kvdb/test: add bolt test 2021-07-12 11:31:11 +02:00
Joost Jager f592375d1b kvdb/test: fix cursor tests to match bbolt semantics
From bbolt docs:
// Seek positions the cursor at the passed seek key. If the key does not exist,
// the cursor is moved to the next key after seek. Returns the new pair.
2021-07-12 11:31:09 +02:00
Joost Jager 84490466be kvdb/test: remove invalid operations
Accessing buckets that have been removed is not an allowed operation.
2021-07-12 11:31:07 +02:00
Joost Jager 3c6d35ec41 kvdb/test: generalize etcd tests 2021-07-12 11:31:05 +02:00
Joost Jager 3026e5a826 build: bump btcwallet 2021-07-08 14:34:16 +02:00
Joost Jager 98e75b486d itest: add db backend flag 2021-07-05 10:10:02 +02:00
Joost Jager 387f1ef274 lntest: abstract db backup and restore 2021-07-05 09:20:19 +02:00
Joost Jager 9b1b92bf98 lncli: fix psbt fund parameter parsing
The sat_per_vbyte parameter was ignored because of a default value for
conf_target.
2021-06-28 11:23:13 +02:00
Joost Jager dddf0bc887 htlcswitch: concurrent onion decoding 2021-05-24 20:12:57 +02:00
Joost Jager 94b6f8af5b htlcswitch: extract onion decode function 2021-05-24 20:12:57 +02:00
Joost Jager 42f4afef75 multi: add random coin selection 2021-05-24 20:09:56 +02:00
Joost Jager 2749b805b0 lnrpc: deprecate route hop channel capacity field 2021-05-16 11:58:23 +02:00
Joost Jager cdddaaca75 routing: no backend call to fetch best block 2021-04-27 19:05:55 +02:00
Joost Jager ffd346e2e1 config: add channel commit batch size parameter 2021-04-09 15:10:43 +02:00
Joost Jager a181d26287 config: add channel commit interval parameter 2021-04-09 15:10:42 +02:00
Joost Jager 56238ebc60 routing: remove unnecessary lock in mission control init
The init code is part of the instantiation, so there is no need for
locking yet.
2021-03-17 12:06:12 +01:00
Joost Jager 89751f869f routing: fix mission control deadlock
This commit fixes the following potential deadlock situation:
* Pathfinding holds a database lock and tries to obtain a mission control lock
via GetProbability
* ReportPaymentSuccess/ReportPaymentFail holds a mission control lock
and tries to obtain a database lock to store the payment result.
2021-03-17 12:03:32 +01:00
Joost Jager 9398220568 walletrpc: add ListLeases 2021-03-13 08:45:52 +01:00
Joost Jager b8e54fffbf walletrpc: extract leases marshall function 2021-03-13 08:45:52 +01:00
Joost Jager 37331a5ab2 walletrpc: use locked utxo struct from wtxmgr 2021-03-13 08:45:52 +01:00
Joost Jager 927f17be32 walletrpc: parameterize output lease duration 2021-03-13 08:45:52 +01:00
Joost Jager 5ba0f8e355 lnwallet: bump btcwallet 2021-03-13 08:45:52 +01:00
Joost Jager 0ef0264d28 lnrpc: add htlc attempt id 2021-01-25 17:21:58 +01:00
Joost Jager 626983b352 rpcserver: use NotFound http status code in GetNodeInfo 2021-01-14 13:59:56 +01:00
Joost Jager 49df2d6f8b lnrpc: expose forwarding channel for htlcs in ListChannels 2020-10-16 09:03:24 +02:00
Joost Jager d13b813dbb lnrpc: add htlc index to ListChannels pending htlcs 2020-10-14 17:44:22 +02:00
Joost Jager 856abade3d routerrpc: map errors to grpc status code
The 'payment already exists' case is common in restart scenarios. With
this commit it is no longer necessary to string-match on the error
message. Implementation is identical to SendPaymentV2.
2020-10-14 16:15:08 +02:00
Joost Jager 2236813c95 htlcswitch: randomize non-strict forwarding 2020-09-29 11:05:53 +02:00
Joost Jager 6ae05c6bac Merge pull request #4592 from joostjager/sweep-deadline
cnct+sweep: cpfp-aware anchor sweeping
2020-09-18 20:15:03 +02:00
Joost Jager 29602e88e8 cnct: cpfp-sweep anchors
For unconfirmed commit tx anchors, supply the sweeper with cpfp info and
a confirmation target fee estimate.

The sweeper will try to pay for the parent commit tx as long as the
current fee estimate exceeds the pre-signed commit tx fee rate.
2020-09-17 12:30:41 +02:00