Commit Graph
131 Commits
Author SHA1 Message Date
ziggie 5580c40cb0 routerrpc: fix comment in lsp heuristic 2025-12-14 09:25:30 +01:00
ziggie 1c4bcc3b7d routerrpc: fix payment address deep copy
using copy for a slice of size 0 will not copy anything so we need
to first initialize the slice before we do the deep copy.
2025-12-10 09:49:57 +01:00
ziggie 79fe67619b routerrpc: implement LSP heuristic and multi-LSP worst-case probing
This commit implements a comprehensive LSP (Lightning Service Provider)
detection heuristic and updates the payment probing logic to handle
multiple LSPs with worst-case fee estimation.

Key changes:

1. LSP Detection Heuristic (isLSP function):
   Implements three rules to detect LSP setups:
   - Rule 1: If invoice target is public → NOT an LSP (route directly)
   - Rule 2: If at least one destination hop is public → IS an LSP
   - Rule 3: If all destination hops are private → NOT an LSP

2. LSP Route Preparation (prepareLspRouteHints function):
   - Groups route hints by unique public LSP nodes
   - Filters out non-LSP routes based on the heuristic
   - Tracks worst-case fees and CLTV delays for each LSP
   - Returns adjusted route hints with LSP hop stripped

3. Multi-LSP Probing (probePaymentRequest updates):
   - Probes up to 3 unique LSPs maximum (griefing protection)
   - Selects the WORST-CASE (most expensive) route for conservative
     fee estimation
   - Adds comprehensive debug logging for worst-case selection process
   - Properly formats vertex logging using %v (calls Vertex.String())

The worst-case approach ensures users won't be surprised by higher fees
when the actual payment is sent, providing a more conservative and
reliable fee estimate.

This commit also  adds extensive unit test coverage for the LSP detection
heuristic and route preparation logic.

TestIsLsp:
- Edge cases: empty route hints, nil scenarios
- Rule 1: Public invoice target (3 tests)
- Rule 2: All private destination hops (4 tests)
- Rule 3: At least one public destination hop (6 tests)

TestPrepareLspRouteHints:
- LSP grouping and filtering logic
- Worst-case fee selection across route hints
- Worst-case CLTV delta tracking
- Adjusted route hints validation (LSP hop stripped)
- Multi-LSP scenarios with different fees
2025-12-01 18:07:56 +01:00
George Tsagkarelis f14190c02d lnrpc: add XFindBaseLocalChanAlias rpc
Add the new RPC method that looks up the base scid for a given alias.
Given the previous stepping stones this commit is fairly simple, we just
call into the alias manager and return the lookup result.
2025-09-25 11:15:31 +02:00
George Tsagkarelis 472a2f967e multi: add base lookup option to AddLocalAlias
We add an extra option to the AddLocalAlias method which only controls
whether we store a reverse lookup from the alias back to the base scid
it corresponds to. The previous flag "gossip" is still maintained, and
in a way supercedes the new flag (it will also store the base scid
lookup even if the base lookup flag isn't set). The only call that sets
this option is the XAddLocalChanAlias RPC endpoint, where we want to
make sure that a reverse lookup is stored in the alias manager in order
to later expose it via the new RPC method.
2025-09-25 11:15:27 +02:00
ziggie 2b856f036e multi: fix linter 2025-08-14 19:53:18 +02:00
ziggie 03af9858d2 multi: move payment related code into own package
This commit moves most of the code into its own package. It is
the smallest code move possible without moving import cycles and
keeping the changes to the code base as small as possible during
refactor.
2025-08-14 19:53:15 +02:00
ziggie 18afd4442d multi: introduce new paymentsDB package
We introduce a new package paymentsDB and start by moving the
payment specifc errors from the channeldb package to the
paymentsDB package. We also fix linter issues which showed up
due to changing this code part.
2025-08-11 16:44:14 +02:00
ziggie 43edfeb101 routerrpc: rename var and add more comments 2025-06-25 10:37:06 +02:00
ziggie fd7f6caa4a routerrpc: add log line for probing the invoice request 2025-06-25 10:37:05 +02:00
Slyghtning 35c9eecf4e routerrpc: add nil check for MilliSat 2025-03-24 16:54:05 +01:00
Slyghtning 6399d77c18 routerrpc: fix estimateroutefee for public route hints 2025-02-24 09:56:22 +01:00
Elle Mouton e3b94e4578 routerrpc: only log TrackPayment error if err is not nil 2025-01-24 12:49:45 +02:00
Nishant Bansal b577ad4661 routerrpc: default timeout_seconds to 60 in SendPaymentV2
If timeout_seconds is not set or is 0, the default value
of 60 seconds will be used.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
2025-01-15 19:45:44 +05:30
Mohamed Awnallah e636c76300 chore: change register to registered [skip ci] 2024-12-28 23:06:07 +02:00
Keagan McClelland ed2989ae33 multi: update to fn v2 2024-12-04 13:19:00 -07:00
Elle Mouton ab7aae0708 multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton 7dc86acb8c multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if
it is a pointer.
2024-09-25 11:14:35 +09:00
George Tsagkarelis 42e358e3d3 lnrpc: add wire records fields to payment+interceptor RPCs 2024-09-05 11:18:16 +02:00
George Tsagkarelis 70f82bc4ff routerrpc: add XAddLocalChanAliases & XDeleteLocalChanAliases 2024-09-05 10:29:42 +02:00
Oliver Gugger 61edb36283 routing+lnrpc: fix log statements 2024-08-23 10:58:14 +02:00
ffranr 7df093b3b1 multi: improve comment grammar 2024-08-22 18:33:24 +02:00
bitromortac b0e1a722c6 routerrpc: add check for empty hops 2024-08-07 14:24:59 +02:00
bitromortac 452db01ad7 lnrpc+routing: convert amt pointer to fn.Option 2024-08-07 14:24:56 +02:00
Slyghtning bba01cf634 routing+routerrpc: cancelable context in SendPaymentV2
In this commit we set up the payment loop context
according to user-provided parameters. The
`cancelable` parameter indicates whether the user
is able to interrupt the payment loop by cancelling
the server stream context. We'll additionally wrap
the context in a deadline if the user provided a
payment timeout.
We remove the timeout channel of the payment_lifecycle.go
and in favor of the deadline context.
2024-06-17 09:32:26 +02:00
Slyghtning 06bff6f81a routing: fix typos and wrap errors 2024-06-17 09:32:25 +02:00
Bufo 4a3af519b8 chore: allow 0 failure amount on import mission control 2024-06-03 11:28:26 +02:00
erik 789c6bac8c multi: replace ioutil.WriteFile 2024-04-25 11:23:31 +02:00
Oliver Gugger 648fb22f63 multi: wrap all errors 2024-04-11 15:04:03 +02:00
Slyghtning 7d9589ecbf routerrpc+zpay32: EstimateRouteFee overhaul
In this commit the mission control based fee estimation
is supplemented with a payment probe estimation which can
lead to more accurate estimation results. The probing
utilizes a hop-hint heurisic to detect routes through LSPs
in order to manually estimate fees to destinations behind
an LSP that would otherwise block the payment probe.
2024-03-05 09:24:27 +01:00
ziggie 79fb45074b routerrpc: use cltv delta default for buildroute.
This commit uses the default timelock delta (cltv delta) when
no value is provided for the buildroute rpc cmd.
Moreover it enhances the docs.
2024-01-16 14:08:51 +01:00
yyforyongyu 6de21b2a02 routerrpc: add verbose log and ignore context canceled error 2024-01-05 22:18:25 +08:00
yyforyongyu 58677569b5 routing+routerrpc: remove redudant error check
Since `SendPaymentAsync` now never returns an error, there's no need to
catch it and check it in `SendPaymentV2`.
2024-01-05 18:11:04 +08:00
yyforyongyu 99354313d5 routerrpc+itest: make sure TrackPayments is compatible
This commit adds an itest case to make sure when the flag
`routerrpc.usestatusinitiated` is not set, the new status is not sent.
2023-11-15 20:18:21 +08:00
yyforyongyu 922130c80e routerrpc: skip initiated payment in trackPaymentStream 2023-11-14 17:46:20 +08:00
Carla Kirk-Cohen c9609b8214 multi: add blinded route to route requests expressed as hints
Add the option to include a blinded route in a route request (exclusive
to including hop hints, because it's incongruous to include both), and
express the route as a chain of hop hints.

Using a chain of hints over a single hint to represent the whole path
allows us to re-use our route construction to fill in a lot of the
path on our behalf.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 48e36d93d4 multi/refactor: add RouteRequest to hold FindRoute parameters
This commit introduces a single struct to hold all of the parameters
that are passed to FindRoute. This cleans up an already overloaded
function signature and prepares us for handling requests with blinded
routes where we need to perform some additional processing on our
para (such as extracting the target node from the blinded path).
2023-10-06 16:38:33 -07:00
yyforyongyu 36f9d7b8db routerrpc: make sure error is transformed into grpc error code 2023-10-06 16:34:47 -07:00
yyforyongyu 30fd29371c channeldb: add new payment status StatusInitiated
This commit adds a new payment status, `StatusInitiated`, to properly
represent the state where a payment is newly created without attempting
any HTLCs. Since the `PaymentStatus` is a memory representation of a
given payment's status, the enum used for the statuses are directly
updated.
2023-10-06 16:34:47 -07:00
yyforyongyu de01e412d6 routing+lnrpc: subscribe payment stream before sending it
This commit moves the subscription of a given payment before it's been
sent so we won't miss any events.
2023-05-23 21:26:09 +08:00
bitromortac fce88e8b5d lncli+routerrpc: dynamic capacity fraction config
Enable setting and getting of the apriori capacity fraction in lncli and
in the router rpc.
2023-02-24 15:28:55 +01:00
bitromortac 2ccdfb1151 lncli+routerrpc: adapt mc api to dynamic estimator
The active probability estimator can be switched dynamically using the
`Set/GetMissionControl` API, maintaining backward compatibility. The
lncli commands `setmccfg` and `getmccfg` are updated around this
functionality. Note that deprecated configuration parameters were
removed from the commands.
2023-02-14 13:34:25 +01:00
bitromortac 16986ee5c7 lnd+routing+rpc: switch mc to (external) estimator
We use a more general `Estimator` interface for probability estimation
in missioncontrol.

The estimator is created outside of `NewMissionControl`, passed in as a
`MissionControlConfig` field, to facilitate usage of externally supplied
estimators.
2023-02-14 13:34:25 +01:00
bitromortac b0a998af8d routing: rename apriori estimator
* we rename the current probability estimator to be the "apriori"
  probability estimator to distinguish from a different implementation
  later
* the AprioriEstimator is exported to later be able to type switch
* getLocalPairProbability -> LocalPairProbabiltiy (later part of an
  exported interface)
* getPairProbability -> getPairProbabiltiy (later part of an exported
  interface)
2023-02-07 16:18:38 +01:00
bitromortac 2d7fda2a41 routerrpc: mark QueryProbability deprecated
We deprecate `QueryProbability`, as it displays the same information as
`QueryMissionControl` less the probability. `QueryRoutes` still contains
the total probability of a route.
2022-12-12 13:23:31 +01:00
bitromortac 454c115b6e routing+routerrpc: add capacity in rpcs
FetchPairCapacity is used by the following endpoints to introduce the
capacity for probability calculations:

* QueryProbability
* QueryRoutes
2022-12-12 13:22:29 +01:00
bitromortac 66ffc64776 router: return probability from findPath
The returned probability can then be used in QueryRoutes to not having
to reconstruct the probability.
2022-12-12 13:22:29 +01:00
bitromortac 516e3a8cca routing: use capacity in pathfinding
Extends the pathfinder with a capacity argument for later usage.

In tests, the inserted testCapacity has no effect, but will be used
later to estimate reduced probabilities from it.
2022-12-12 13:22:28 +01:00
Joost Jager b85cda2a1d routerrpc: add htlc notifier subscribed event 2022-10-27 16:42:35 +02:00
Jesse de Wit 0266ab77ab routing+routerrpc: test stream cancellation
Test stream cancellation of the TrackPayments rpc call. In order to achieve
this, ControlTowerSubscriber is converted to an interface, to avoid trying to
close a null channel when closing the subscription. By returning a mock
implementation of the ControlTowerSubscriber in the test that problem is
avoided.
2022-09-10 21:53:01 +02:00