Commit Graph

16769 Commits

Author SHA1 Message Date
Elle Mouton
c20d759d41
refactor: create FetchLightningNode with no tx param
In preparation for adding a clean Graph DB interface, we create a
version of FetchLightningNode that doesnt allow a caller to provide in a
transaction.
2024-07-15 15:13:57 +02:00
Elle Mouton
71e93526d6
multi+refactor: let FetchChanInfos not take tx
In preparation for having a clean graph DB interface, refactor
FetchChanInfos so that no transaction can be provided.
2024-07-15 15:13:57 +02:00
Elle Mouton
cf3de72503
routing: let SelfNode be passed via config
Instead of querying it from the graph since this will be removed in a
future commit.
2024-07-15 15:13:57 +02:00
Elle Mouton
8c0df98439
multi: add abstraction for Router and SessionSource graph access
In this commit, we completely remove the Router's dependence on a Graph
source that requires a `kvdb.RTx`. In so doing, we are more prepared for
a future where the Graph source is backed by different DB structure such
as pure SQL.

The two areas affected here are: the ChannelRouter's graph access that
it uses for pathfinding. And the SessionSource's graph access that it
uses for payments.

The ChannelRouter gets given a Graph and the SessionSource is given a
GraphSessionFactory which it can use to create a new session. Behind the
scenes, this will acquire a kvdb.RTx that will be used for calls to the
Graph's `ForEachNodeChannel` method.
2024-07-15 15:13:57 +02:00
Elle Mouton
90d6b863a8
routing+refactor: remove the need to give CachedGraph source node access
In preparation for the next commit.
2024-07-15 13:10:24 +02:00
Elle Mouton
3f121cbe81
routing: rename and export routingGraph
In preparation for structs outside of the `routing` package implementing
this interface, export `routingGraph` and rename it to `Graph` so as to
avoid stuttering.
2024-07-15 13:10:24 +02:00
Elle Mouton
5a903c270f
routing: remove sourceNode from routingGraph interface
In this commit, we further reduce the routingGraph interface and this
time we make it more node-agnostic so that it can be backed by any graph
and not one with a concept of "sourceNode".
2024-07-15 13:10:24 +02:00
Elle Mouton
5c18b5a042
routing: remove un-used method from routingGraph interface
We really want to narrow down the interface we provide the router, so
let's start here.
2024-07-15 13:10:23 +02:00
Olaoluwa Osuntokun
09b38aaa01
Merge pull request #8653 from ProofOfKeags/fn-prim
DynComms [0/n]: `fn` package additions
2024-07-12 17:30:15 -07:00
Olaoluwa Osuntokun
f464dac1cd
Merge pull request #8752 from ellemouton/rb-receives-setup
[1/4] Route Blinding Receives: Groundwork
2024-07-10 18:27:11 -07:00
Keagan McClelland
eaa5e4a039
fn: remove redundant Reduce function
This commit removes Reduce since we already have both Foldl and Foldr.
2024-07-10 17:06:09 -07:00
Keagan McClelland
fa2e25d5f4
fn: remove lru dependency 2024-07-10 17:06:04 -07:00
Keagan McClelland
364d79e552
fn: add generic version of List 2024-07-10 16:55:29 -07:00
Keagan McClelland
fb1437cb6d
fn: add Elem function for set membership 2024-07-10 15:37:27 -07:00
Keagan McClelland
9c30bce10c
fn: add curried (in)equality functions 2024-07-10 15:37:27 -07:00
Keagan McClelland
c4df2f1dce
fn: reimplement internals of either, add tests 2024-07-10 15:37:27 -07:00
Keagan McClelland
1dd56f1b2a
fn: fix and finish the either API 2024-07-10 15:37:27 -07:00
Keagan McClelland
c3603ccf96
fn: add FindIdx function 2024-07-10 15:34:57 -07:00
Keagan McClelland
5902aa5159
fn: add concurrent map operation for slices 2024-07-10 15:29:16 -07:00
Keagan McClelland
94acbe90a8
fn: add fundamental functional primitives 2024-07-10 14:42:11 -07:00
Oliver Gugger
f2759dcb1a
Merge pull request #8759 from largemouth/master
chore: fix some function names
2024-07-10 12:16:49 -06:00
Elle Mouton
85ddffb17d
docs: update release notes 2024-07-10 17:51:56 +02:00
Elle Mouton
cd3da40fb9
routing: dont include final hop cltv in blinded path
Only include the final hop's cltv delta in the total timelock
calculation if the route does not include a blinded path. This is
because in a blinded path, the final hops final cltv delta will be
included in the blinded path's accumlated cltv delta value.

With this commit, we remove the responsibility of remembering not to set
the `finalHop.cltvDelta` from the caller of `newRoute`. The relevant
test is updated accordingly.
2024-07-10 17:51:56 +02:00
Elle Mouton
93f89512ae
lnrpc+rpcserver: Add blinded payment paths to PayReq
This commit adds a blinded_paths field to the PayReq proto message. A
new helper called `CreateRPCBlindedPayments` is then added to convert
the zpay32 type to the existing `lnrpc.BlindedPaymentPath` type and add
this to the `PayReq` in the `DecodePayReq` rpc method.
2024-07-10 17:51:55 +02:00
Elle Mouton
f6a54c2ede
zpay: encoding and decoding of a BlindedPaymentPath
In this commit, the ability is added to encode blinded payment paths and
add them to a Bolt 11 invoice.
2024-07-10 17:51:55 +02:00
Elle Mouton
9ada4a9068
record: add Padding field to BlindedRouteData
When we start creating blinded paths to ourselves, we will want to be
able to pad the data for each hop so that the `encrypted_recipient_data`
for each hop is the same. We add a `PadBy` method that allows a caller
to add a certain number of bytes to the padding field. Note that adding
n bytes won't always mean that the encoded payload will increase by size
n since there will be overhead for the type and lenght fields for the new
TLV field. This will also be the case when the number of bytes added
results in a BigSize bucket jump for TLV length field. The
responsibility of ensuring that the final payloads are the same size is
left to the caller who may need to call PadBy iteratively to achieve the
goal. I decided to leave this to the caller since doing this at the
actual TLV level will be quite intrusive & I think it is uneccessary to
touch that code for this unique use case.
2024-07-10 09:12:40 +02:00
Elle Mouton
15f3cce27d
record: add PathID to BlindedRouteData
Add the PathID (tlv type 6) field to BlindedRouteData. This will be used
for the final hop of a blinded route. A new constructor is also added
for BlindedRouteData which can specifically be used for the final hop.
2024-07-10 09:12:40 +02:00
Elle Mouton
ad0905f10e
record+htlcswitch: convert BlindedRouteData fields to optional
For the final hop in a blinded route, the SCID and RelayInfo fields will
_not_ be set. So these fields need to be converted to optional records.

The existing BlindedRouteData constructor is also renamed to
`NewNonFinalBlindedRouteData` in preparation for a
`NewFinalBlindedRouteData` constructor which will be used to construct
the blinded data for the final hop which will contain a much smaller set
of data. The SCID and RelayInfo parameters of the constructor are left
as non-pointers in order to force the caller to set them in the case
that the constructor is called for non-final nodes. The other option
would be to create a single constructor where all parameters are
optional but I think this makes it easier for the caller to make a
mistake.
2024-07-10 09:12:39 +02:00
Elle Mouton
925b68c1ed
routing: add BlindedPayment to unifiedEdge
Later on in this series, we will need to know during path finding if an
edge we are traversing was derived from a blinded payment path. In
preparation for that, we add a BlindedPayment member to the
`unifiedEdge` struct.

The reason we will need this later on is because: In the case where we
receive multiple blinded paths from the receipient, we will first swap
out the final hop node of each path with a single unified target node so
that path finding can work as normal. Once we have selected a route
though, we will want to know which path an edge belongs to so that we
can swap the correct destination node back in.
2024-07-10 09:12:39 +02:00
Elle Mouton
1ec2a1be11
routing+refactor: add a constructor for unifiedEdge
Add a constructor for unified edge. In upcoming commits, we will add a
new member to unifiedEdge and a constructor forces us to not forget to
populate a required member.
2024-07-10 09:12:39 +02:00
Elle Mouton
28d1227c04
routing: add BlindedPayment() method to AdditionalEdges
Expand the AdditionalEdges interface with a BlindedPayment method. In
upcoming commits, we will want to know if an AdditionalEdge was derived
from a blinded payment or not and we will also need some information
from the blinded payment it was derived from. So we expand the interface
here to avoid needing to do type casts later on. The new method may
return nil if the edge was not derived from a blinded payment.
2024-07-10 09:12:39 +02:00
Elle Mouton
f7a9aa875e
routing+refactor: let BlindedEdge carry BlindedPayment
This commit is purely a refactor. In it, we let the `BlindedEdge` struct
carry a pointer to the `BlindedPayment` that it was derived from. This
is done now because later on in the PR series, we will need more
information about the `BlindedPayment` that an edge was derived from.

Since we now pass in the whole BlindedPayment, we swap out the
`cipherText` member for a `hopIndex` member so that we dont carry around
two sources of truth in the same struct.
2024-07-10 09:12:39 +02:00
Oliver Gugger
a9655357ca
Merge pull request #8855 from bhandras/invoice-expiry-migration
sqldb+invoices: fix incorrectly stored invoice expiries when using native SQL
2024-07-09 02:06:28 -06:00
Andras Banki-Horvath
053faa6229
docs: update release notes for 0.18.3-beta 2024-07-09 08:39:58 +02:00
Andras Banki-Horvath
d0c1cec8c1
sqldb: switch away from pq to pgx for Postgres
Completely switch to the better maintained pgx driver.
2024-07-09 08:39:58 +02:00
Andras Banki-Horvath
95b99420fa
sqldb: add unit test for the invoice expiry migration 2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
ed36598504
sqldb: add helpers to create test DBs migrated up to a select version 2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
5292c76e10
sqldb: extract migration into method
Based on: https://github.com/lightninglabs/taproot-assets/pull/707
2024-07-09 08:39:57 +02:00
Andras Banki-Horvath
323af946e0
sqldb+invoices: add migration to fix incorrectly stored invoice expiries
Previously, when using the native schema, invoice expiries were incorrectly
stored as 64-bit values (expiry in nanoseconds instead of seconds), causing
overflow issues. Since we cannot determine the original values, we will set
the expiries for existing invoices to 1 hour with this migration.
2024-07-09 08:39:57 +02:00
Yong
3526f82b5d
Merge pull request #8887 from yyforyongyu/fix-err-match
multi: fix `lnwallet.ErrDoubleSpend`
2024-07-08 14:09:07 +08:00
yyforyongyu
e27a656c07
docs: add release notes for 0.18.3 2024-07-06 14:01:40 +08:00
yyforyongyu
26a365eb32
docs: update release notes 2024-07-06 13:59:28 +08:00
yyforyongyu
8f4bcd0b3a
lnwallet: fix ErrDoubleSpend 2024-07-06 13:59:28 +08:00
yyforyongyu
ddf46f435c
multi: update RPC error import path
These errors are now defined in `btcwallet/chain` instead of
`btcd/rpcclient`.
2024-07-06 13:59:28 +08:00
yyforyongyu
e0a506ab26
multi: use chain.MapRPCErr instead of rpcclient.MapRPCErr 2024-07-06 13:59:25 +08:00
yyforyongyu
1d40c55550
gomod: update btcwallet to include RPC errors 2024-07-06 13:55:12 +08:00
Elle
d7e0f69f34
Merge pull request #8854 from bhandras/invoices-limit-offset-fixup
invoices: fix SQL invoice query pagination
2024-07-04 21:26:56 +02:00
Andras Banki-Horvath
b35f0606ba
docs: update release notes for 0.18.2-beta 2024-07-04 17:32:12 +02:00
Andras Banki-Horvath
892561f8f0
sqldb: bump modernc.org/sqlite to 1.29.10 which fixes init data race
Tracking issue: https://gitlab.com/cznic/sqlite/-/issues/180
2024-07-04 17:32:12 +02:00
Andras Banki-Horvath
e45ed86263
invoices: fix and correctly cover paginated queries
Previously paginated queries offseted the add_index_get, add_index_let,
settle_index_get and settle_index_let parameters with the paginators
current page offset, however this was incorrect as we can just use
SQL's LIMIT/OFFSET to paginate. This commit fixes this issue and adds an
optional parameter to the constructor of the invoice SQL store to set
page size. This is useful when testing as we can now cover pagination
correctly with our existing unit tests.
2024-07-04 17:32:11 +02:00