Commit Graph

235 Commits

Author SHA1 Message Date
George Tsagkarelis
4b1bb102bf
invoices: cancel htlc on HtlcModify signal 2024-10-24 12:59:29 +02:00
George Tsagkarelis
1c17356fdc
lnrpc+invoices: add cancelSet to HtlcModifier interface 2024-10-24 12:59:28 +02:00
Elle Mouton
23602e017e
multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
ziggie
027de0a82c
invoices: add proper startup for the interceptor
During testing of this PR I figured out the the htlc interceptor
was not shutdown and started properly in terms of closing the
quit channel but also in terms of the relevant logs.
2024-10-18 13:03:30 +02:00
ziggie
4402137fb4
multi: bump btcd version.
The new SignCompact return values had to be adopted across the
code base.
2024-10-03 21:56:21 +02:00
Elle Mouton
0bd76ffe32
invoices: init quit channel of modifier
Also add atomic start and stop vars to prevent close of a closed
channel.
2024-09-25 14:32:29 +09:00
ffranr
bbae7148aa
multi: pass UpdateAddHtlc message custom records to invoice modifier 2024-09-19 09:21:38 +02:00
ffranr
c58b6a25a2
invoices: integrate settlement interceptor with invoice registry
This commit updates the invoice registry to utilize the settlement
interceptor during the invoice settlement routine. It allows the
interceptor to capture the invoice, providing interception clients an
opportunity to determine the settlement outcome.
2024-09-19 09:21:37 +02:00
ffranr
b8c8774b5d
invoices: add invoice htlc interceptor service
This commit introduces a new invoice htlc interceptor service
that intercepts invoice HTLCs during their settlement phase. It forwards
HTLCs to a subscribed client to determine their settlement outcomes.

This commit also introduces an interface to facilitate integrating the
interceptor with other packages.
2024-09-19 09:21:36 +02:00
ffranr
abca4b8234
htlcswitch: add resume modified HTLC action to switch
Introduce `ResumeModified` action to resume standard behavior of a p2p
message with optional modifications as specified by the client during
interception.
2024-09-05 11:18:15 +02:00
Andras Banki-Horvath
06d4267a76
sqldb: fix end date filter when querying invoices
Previously, the SQL implementation of the invoice query simply
converted the start and end timestamps to time and used them
in SQL queries to check for inclusivity. However, this logic
failed when the start and end timestamps were equal.

This commit addresses and corrects this issue.
2024-09-03 19:40:47 +02:00
Andras Banki-Horvath
b57910ee3a
sqldb+invoices: synchronize SQL invoice updater behavior with KV version
Previously SQL invoice updater ignored the set ID hint when updating an
AMP invoice resulting in update subscriptions returning all of the AMP
state as well as all AMP HTLCs. This commit synchornizes behavior with
the KV implementation such that we now only return relevant AMP state
and HTLCs when updating an AMP invoice.
2024-09-03 19:40:46 +02:00
Alex Akselrod
ffbdcc1d5d
invoices: ensure AMP subinvoices are correctly updated w/nativesql 2024-09-03 19:40:46 +02:00
Alex Akselrod
f1b7953465
invoices/sqldb: query by ChanID when updating AMP invoice preimage 2024-09-03 19:40:45 +02:00
Oliver Gugger
e99e6662cf
multi: update linter, fix new issues 2024-08-20 19:14:44 +02:00
Elle Mouton
5e84ba92af
multi: add IsBlinded to lnrpc.Invoice for nicer UX
The BlindedPathConfig struct is nice for invoice creation but when we
use the Invoice message for viewing an invoice, it would be nicer to see
an "is_blinded" field.
2024-08-08 16:46:01 +02:00
ziggie
02c1264c53
multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
ziggie
08b68bbaf7
multi: Add atomic start/stop functions.
Make sure that each subsystem only starts and stop once. This makes
sure we don't close e.g. quit channels twice.
2024-07-31 13:12:19 +02:00
Elle Mouton
b0d3e4dc0d
multi: extract path ID and total amt from received payment
We've covered all the logic for building a blinded path to ourselves and
putting that into an invoice - so now we start preparing to actually be
able to recognise the incoming payment as one from a blinded path we
created.

The incoming update_add_htlc will have an `encrypted_recipient_data`
blob for us that we would have put in the original invoice. From this we
extract the PathID which we wrote. We consider this the payment address
and we use this to derive the associated invoice location.

Blinded path payments will not include MPP records, so the payment
address and total payment amount must be gleaned from the pathID and new
totalAmtMsat onion field respectively.

This commit only covers the final hop payload of a hop in a blinded
path. Dummy hops will be handled in the following commit.
2024-07-26 09:54:18 +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
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
Elle Mouton
d4f63662c1
invoices: ensure synchronous access to NewTestSqliteDB
Add a temporary mutex around the calls to sqldb.NewTestSqliteDB to
ensure that only a single thread can access it at a time. This is a
temporary work around that can be removed once this race condition in
the sqlite repo has been resolved:
https://gitlab.com/cznic/sqlite/-/issues/180
2024-05-06 19:10:44 +02:00
djkazic
1542424782
invoices: if there are no invoices make gc noop 2024-04-30 11:58:18 -04:00
Andras Banki-Horvath
043e4aff01
sqldb+invoices: fix ordering bug in FilterInvoices
Previously if the `reverse` named arg was unset (value of NULL), then
SQL would order by NULL instead of ID causing undifined ordering of the
returned rows. To fix that we check for NULL and also make sure to set
the `reverse` arg in the code explicitly as it in the generated code it
is an `interface{}` instead of `bool`.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
478ae1e9b0
sqldb: cleanup scope state reset by adding reset closure to ExecTx
For SQL transactions, we often accumulate results in variables declared
outside the closure's scope. To eliminate the need for manually clearing
these containers, we introduce a reset function to ExecTx, mirroring the
approach already adopted in kvdb.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
7f5c8219ef
sqldb+invoices: move SQL invoice store impl to invoices package 2024-04-09 20:46:11 +02:00
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +08:00
Andras Banki-Horvath
aee1f7f563
invoices: run InvoiceStore and InvoiceRegistry tests on PostgreSQL too 2024-03-01 10:08:09 +01:00
Andras Banki-Horvath
b10ce17cd4
invoices: run InvoiceStore and InvoiceRegistry tests on SQLite too 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
734d3a9d66
invoices: small test fixes 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
39211d25ed
invoices: make test HTLC circuit keys unique 2024-03-01 10:08:08 +01:00
Andras Banki-Horvath
7d56d5385d
invoices: parametrize invoice(registry) tests with InvoiceDB constructor
This commit extracts the InvoiceDB construction from all invoice and
registry tests such that we can later on run subtests with multiple
backends without needing to use tags.
2024-02-19 20:47:25 +01:00
Andras Banki-Horvath
0e2b39ed44
invoices: fix linter issues after the move 2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
5e746b4d2c
invoices: move InvoiceDB tests unrelated to kvdb to invoices package 2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
6b0931af82
invoices: move UpdateInvoice implementation to the invoices package
With the introducation of the `InvoiceUpdater` interface we are now
able to move the non-kv parts of `UpdateInvoice` completely under
the invoices package. This is a preprequisite for being able to use
the same code-base for the sql InvoiceDB implementation of
UpdateInvoice.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
ecbfc46312
invoices+channeldb: add InvoiceUpdater interface and the KV impl
This commit introduces the InvoiceUpdater interface which is meant
to abstract and assist the in-memory invoice update procedure with
the accompanying database updates. These abstract updater steps will
enable further refactoring later while also ensuring that a full
SQL implementation of the InvoiceDB interface will be possible.
2024-02-19 20:47:24 +01:00
yyforyongyu
18333e8c7d
multi: fix timestamp filters for invoice query
This commit fixes the timestamp precision to always compare the dates
using unix seconds for invoices.
2024-02-05 15:26:43 +08:00
Keagan McClelland
239103c2b3 multi: make tlv onion compulsory 2024-01-11 09:43:31 -08:00
bitcoin-lightning
b72fc9529e docs: fix typos 2023-12-21 15:21:35 +00:00
yyforyongyu
2caa7d2b2b
invoices: add verbose errors to catch flakes in
`TestInvoiceExpiryWithRegistry`
2023-10-31 16:31:44 +08:00
Andras Banki-Horvath
8bf7503aa4
invoices: remove the now unused ScanInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
d7d385f78f
invoices: refactor initial invoice scan when the registry starts
In this commit we change how we select invoices to follow or delete when
starting the InvoiceRegistry to instead of using the deperecated scan
func from channeldb, use specific functions to gather pending and delete
canceled invoices.
2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
8ab267ad90
channeldb: add k/v implementation for InvoiceDB.DeleteCanceledInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
1f8065de35
channeldb: add k/v implementation for InvoiceDB.FetchPendingInvoices 2023-10-18 16:15:57 +02:00
András Bánki-Horváth
ad5cd9c8bb
multi: extend InvoiceDB methods with a context argument (#8066)
* multi: extend InvoiceDB methods with a context argument

This commit adds a context to InvoiceDB's methods. Along this refactor
we also extend InvoiceRegistry methods with contexts where it makes
sense. This change is essential to be able to provide kvdb and sqldb
implementations for InvoiceDB.

* channeldb: restrict invoice tests to only use an InvoiceDB instance

* docs: update release notes for 0.18.0
2023-10-11 13:42:59 +02:00
yyforyongyu
66b8700c0b multi: add debug logs to catch slow shutdown 2023-10-06 16:34:47 -07:00
Carla Kirk-Cohen
4645fdfb0a
invoice/test: make all tests parallel
When we have tests using global variables and a mix of parallel and
non-parallel tests, odd races can appear when we run them.
2023-07-24 10:54:03 -04:00
Carla Kirk-Cohen
94e434d2f1
invoices/test: move payment address required global into test using it 2023-07-24 10:54:02 -04:00
Carla Kirk-Cohen
d080d07a22
invoices/test: remove duplicate test invoice amount global
We have testInvoiceAmt and testInvoiceAmount with the same value.
2023-07-24 10:54:01 -04:00