Commit Graph

20 Commits

Author SHA1 Message Date
Joost Jager
d416ed59ea
multi: add explicit hodl invoice flag to invoice
Previously it wasn't possible to store a preimage in the invoice
database and signal that a payment should not be settled right away. The
only way to hold a payment was to insert the magic UnknownPreimage value
in the invoice database. This commit introduces a distinct flag to
signal that an invoice is a hold invoice and thereby allows the preimage
to be present in the database already.

Preparation for (key send) hodl invoices for which we already know the
preimage.
2020-06-02 07:34:23 +02:00
Conner Fromknecht
cbf71b5452
channeldb+invoices: use payment addr as primary index 2020-05-26 18:55:27 -07:00
Conner Fromknecht
3522f09a08
channeldb+invoices: track invoices by InvoiceRef 2020-05-26 18:55:27 -07:00
carla
8cbed23f26
invoices: split resolution result into settle, fail and accept enums
This commit splits the resolution result enum into results divided
by outcome (settled, failed or accepted). This allows us to more
strictly control which resolution results can be used with which
HtlcResolution structs, to prevent the combination of a settle
resolution result with a failure resolution result, for example.
2020-02-06 19:41:39 +02:00
carla
2569b4d08a
multi: replace htlcResolution with an interface
This commit repalces the htlcResolution struct with an interface.
This interface is implemeted by failure, settle and accept resolution
structs. Only settles and fails are exported because the existing
code that handles htlc resolutions uses a nil resolution to indicate
that a htlc was accepted. The accept resolution is used internally
to report on the resolution result of the accepted htlc, but a nil
resolution is surfaced. Further refactoring of all the functions
that call NotifyExitHopHtlc to handle a htlc accept case (rather than
having a nil check) is required.
2020-02-06 19:41:36 +02: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
c7208ffb2c
invoices: add missing String() cases 2020-01-21 16:52:13 +01:00
Conner Fromknecht
51dbdd3b38
multi: rename key_send, key-send and key send to keysend 2020-01-16 18:37:16 -08:00
Joost Jager
1d5844c196
invoices: jit insert key send invoices
This commit adds handling code for the key send custom record. If this
record is present and its hash matches the payment hash, invoice
registry will insert a new invoice into the database "just in time". The
subsequent settle flow is unchanged. The newly inserted invoice is
picked up and settled. Notifications will be broadcast as usual.
2019-12-23 21:51:19 +01:00
carla
d2e395d5f2
multi: replace errInvoiceNotFound with resolution result
This commit moves handling of invoice not found
errors into NotifyExitHopHtlc and exposes a
resolution result to the calling functions. The
intention of this change is to make calling
functions as naive of the invoice registry's
mechanics as possible.

When NotifyExitHopHtlc is called and an invoice
is not found, calling functions can take action
based on the HtlcResolution's InvoiceNotFound
outcome rather than having to add a special error
check on every call to handle the error.
2019-12-20 13:01:15 +02:00
carla
7b5dda0417
invoices: add resolution result to htlcResolution
This commit adds the resolution result obtained
while updating an invoice in the registry to
htlcResolution. The field can be used by calling
functions to determine the outcome of the
update and act appropriately.
2019-12-20 13:00:53 +02:00
carla
db85c51b77
invoices: export and rename update result
This commit exports UpdateResult so that
calling functions can interpret the outcome
of an invoice update. This is useful for
determining the wire failure required
(fail invalid details or mpp_timeout once
implemented) and for notifying specific
htlc failure details. The enum is renamed
to ResolutionResult.
2019-12-20 12:25:07 +02:00
Joost Jager
8b5bb0ac63
record: move CustomRecordSet 2019-12-12 00:12:19 +01:00
Joost Jager
b2f43858c3
invoices: accept mpp payments 2019-12-11 16:14:49 +01:00
Joost Jager
5f4bd136cd
invoices: store custom records in invoice database 2019-12-10 06:54:24 +01:00
Joost Jager
970187ace4
invoices: remove unnecessary invoice value check 2019-12-04 14:51:48 +01:00
Joost Jager
00d93ed87b
channeldb: stricter validation of invoice updates 2019-12-04 14:51:42 +01:00
Joost Jager
a4a3c41924
channeldb: split cancel and add htlc updates
Previously the cancel and add actions were combined in a single map.
Nil values implictly signaled cancel actions. This wasn't very obvious.
Furthermore this split prepares for processing the adds and cancels
separately, which is more efficient if there are already two maps.
2019-12-04 14:51:40 +01:00
Joost Jager
c45891ecf7
invoices: move update logic into separate file 2019-12-04 14:51:38 +01:00