Commit graph

256 commits

Author SHA1 Message Date
Allan Douglas R. de Oliveira
963d6c4a51 Docs improvements 2023-03-21 14:11:13 +00:00
Matt Corallo
ccac926671
Merge pull request #2049 from douglaz/run-clippy-fix
Run clippy fix
2023-03-06 21:28:38 +00:00
Allan Douglas R. de Oliveira
57017dfc0b Run clippy --fix and cleanup code 2023-03-06 19:26:48 +00:00
Matt Corallo
a361be3544 Update crate versions to 0.0.114/invoice 0.22 2023-03-04 00:06:46 +00:00
Matt Corallo
f03b7cd448 Remove the final_cltv_expiry_delta in RouteParameters entirely
fbc08477e8 purported to "move" the
`final_cltv_expiry_delta` field to `PaymentParamters` from
`RouteParameters`. However, for naive backwards-compatibility
reasons it left the existing on in place and only added a new,
redundant field in `PaymentParameters`.

It turns out there's really no reason for this - if we take a more
critical eye towards backwards compatibility we can figure out the
correct value in every `PaymentParameters` while deserializing.

We do this here - making `PaymentParameters` a `ReadableArgs`
taking a "default" `cltv_expiry_delta` when it goes to read. This
allows existing `RouteParameters` objects to pass the read
`final_cltv_expiry_delta` field in to be used if the new field
wasn't present.
2023-02-27 22:33:21 +00:00
Matt Corallo
46fd7035b3
Merge pull request #2014 from valentinewallace/2023-02-rework-partial-pmt-fail
Rework auto-retry send errors
2023-02-23 21:54:16 +00:00
Valentine Wallace
d471d9746c
Rework auto retry send errors
Prior to this, we returned PaymentSendFailure from auto retry send payment
methods. This implied that we might return a PartialFailure from them, which
has never been the case. So it makes sense to rework the errors to be a better
fit for the methods.

We're taking error handling in a totally different direction now to make it
more asynchronous, see send_payment_internal for more information.
2023-02-23 15:50:23 -05:00
Matt Corallo
be6f263825 Remove the peer_disconnected no_connection_possible flag
Long ago, we used the `no_connection_possible` to signal that a
peer has some unknown feature set or some other condition prevents
us from ever connecting to the given peer. In that case we'd
automatically force-close all channels with the given peer. This
was somewhat surprising to users so we removed the automatic
force-close, leaving the flag serving no LDK-internal purpose.

Distilling the concept of "can we connect to this peer again in the
future" to a simple flag turns out to be ripe with edge cases, so
users actually using the flag to force-close channels would likely
cause surprising behavior.

Thus, there's really not a lot of reason to keep the flag,
especially given its untested and likely to be broken in subtle
ways anyway.
2023-02-21 19:17:06 +00:00
Valentine Wallace
aa4b429eb2
test_utils: parameterize TestRouter by TestScorer
This allows us set scoring expectations and ensure in-flight htlcs are factored
into scoring
2023-02-14 14:20:48 -05:00
Valentine Wallace
b28bfd382b
Remove InvoicePayer and replace with util methods 2023-02-06 16:28:23 -05:00
Matt Corallo
2a72f4f98c
Merge pull request #1994 from TheBlueMatt/2023-01-1916-followups
1916 Followups Part 1
2023-02-02 23:05:07 +00:00
Matt Corallo
fbc08477e8 Move the final CLTV delta to PaymentParameters from RouteParams
`PaymentParams` is all about the parameters for a payment, i.e. the
parameters which are static across all the paths of a paymet.
`RouteParameters` is about the information specific to a given
`Route` (i.e. a set of paths, among multiple potential sets of
paths for a payment). The CLTV delta thus doesn't belong in
`RouterParameters` but instead in `PaymentParameters`.

Worse, because `RouteParameters` is built from the information in
the last hops of a `Route`, when we deliberately inflate the CLTV
delta in path-finding, retries of the payment will have the final
CLTV delta double-inflated as it inflates starting from the final
CLTV delta used in the last attempt.

By moving the CLTV delta to `PaymentParameters` we avoid this
issue, leaving only the sought amount in the `RouteParameters`.
2023-02-01 17:50:24 +00:00
Kurtsley
342741a2ae Clean up documentation in the create_phantom_invoice functions 2023-01-30 21:09:17 -06:00
Kurtsley
afa0480487 Remove std::SystemTime from create_phantom_invoice, ref #1978
Replace current_timestamp call with no-std duration_from_epoch
2023-01-27 00:02:41 -06:00
Duncan Dean
5b53670172
Add new payment type and metadata bytes
Adds two new payment `Method`s for identifying payments with custom
`min_final_cltv_expiry_delta` as payments with LDK or user payment
hashes.

The `min_final_cltv_expiry_delta` value is packed into the first 2
bytes of the expiry timestamp in the payment secret metadata.
2023-01-24 21:01:27 +02:00
Duncan Dean
1d72e87e78
Add min_final_cltv_expiry parameter to invoice utils
All utility functions for invoice construction will now also accept an
Option<>al `min_final_cltv_expiry_delta` which is useful for things like
swaps etc. The `min_final_cltv_expiry_delta` will default back to
`MIN_FINAL_CLTV_EXPIRY_DELTA` if `None` is provided.
2023-01-24 13:07:46 +02:00
Duncan Dean
fb10fc9590
Add _delta suffix to min_final_cltv_expiry
This matches the spec and helps avoid any confusion around
naming. We're also then consistent with `cltv_expiry` in an HTLC being
the actual block height value for the CLTV and not a delta.
2023-01-24 13:07:23 +02:00
Matt Corallo
e1b58a810f
Merge pull request #1960 from tnull/2023-01-deref-router-in-invoicepayer
Make `InvoicePayer`'s `Router` `Deref`
2023-01-17 23:21:22 +00:00
Elias Rohrer
bc8e1e51e9
Make InvoicePayer's Router Deref
As of HEAD the `ChannelManager` is parametrized by a `Router`, while
`InvoicePayer` also owns a `Router`. In order to allow for a single
object being reused, we make the `InvoicePayer` side `Deref`.
2023-01-16 16:54:53 -06:00
Daniel Granhão
bcf174034a
Stop passing InitFeatures in msg handlers 2023-01-16 21:18:53 +00:00
Matt Corallo
ce6bcf68a1
Merge pull request #1950 from tnull/2023-01-fix-doc-warnings-and-nits
Fix doc warnings and doc cleanup in `msgs.rs`/`ser.rs`
2023-01-15 07:03:14 +00:00
Wilmer Paulino
abf4e79dcd
Use UserConfig to determine advertised InitFeatures by ChannelManager
This is purely a refactor that does not change the InitFeatures
advertised by a ChannelManager. This allows users to configure which
features should be advertised based on the values of `UserConfig`. While
there aren't any existing features currently leveraging this behavior,
it will be used by the upcoming anchors_zero_fee_htlc_tx feature.

The UserConfig dependency on provided_init_features caused most
callsites of the main test methods responsible for opening channels to
be updated. This commit foregos that completely by no longer requiring
the InitFeatures of each side to be provided to these methods. The
methods already require a reference to each node's ChannelManager to
open the channel, so we use that same reference to obtain their
InitFeatures. A way to override such features was required for some
tests, so a new `override_init_features` config option now exists on
the test harness.
2023-01-13 23:54:51 -08:00
Elias Rohrer
defa2f6811
Fix misc. warnings from --document-private-items 2023-01-13 18:26:09 -06:00
Elias Rohrer
d78d06ceba
Fix misc doc warnings. 2023-01-13 18:03:28 -06:00
Arik Sosman
72183bd932
Split up generic parameters that used to comprise KeysInterface. 2023-01-12 16:10:35 -08:00
Arik Sosman
5824e226ca
Remove KeysInterface trait. 2023-01-12 09:18:08 -08:00
Valentine Wallace
3a1982c741
Take in-flight HTLCs by reference in Router::find_route
Useful in upcoming work when for payment retries.
2023-01-05 11:24:56 -05:00
Valentine Wallace
2e06efe2ff
Parameterize ChannelManager by a Router trait
This will be used in upcoming work to fetch routes on-the-fly for payment
retries, which will no longer be the responsibility of InvoicePayer.
2023-01-03 15:34:14 -05:00
Matt Corallo
9449d042b9 Store an owned Score in ScorerAccountingForInFlightHtlcs
`ScorerAccountingForInFlightHtlcs` generally stores a `Score`
reference generated by calling `LockableScore::lock`, which
actually returns an arbitrary `Score`. Given `Score` is implemented
directly on lock types, it makes sense to simply hold a fully owned
`Score` in `ScorerAccountingForInFlightHtlcs` rather than a mutable
reference to one.
2022-12-25 00:58:19 +00:00
Arik Sosman
9d7bb73b59
Split out KeysInterface into EntropySource, NodeSigner, and SignerProvider. 2022-12-20 10:09:11 -08:00
Matt Corallo
f96ac1d341 Bump crate versions to 0.0.113/invoice 0.21 2022-12-15 22:15:55 +00:00
Matt Corallo
769f590d51 Remove unused fetch in lightning_invoice tests. 2022-12-13 01:03:18 +00:00
Matt Corallo
5e14c24a11
Merge pull request #1894 from ssbright/2022-12-custom_payment_hash
Add invoice constructor with custom payment hash
2022-12-13 00:00:32 +00:00
ssbright
5f71fe9849 Add invoice constructor with custom payment hash 2022-12-12 13:08:38 -08:00
Elias Rohrer
22d74bf28b
Rename PaymentReceived to PaymentClaimable 2022-12-01 09:39:33 +01:00
Matt Corallo
5e577cb94a
Merge pull request #1862 from valentinewallace/2022-11-chanman-retries-prep
Prepare for Payment Retries in `ChannelManager`
2022-12-01 04:24:10 +00:00
Valentine Wallace
8a51a792aa
Move DefaultRouter to router module 2022-11-30 16:29:57 -05:00
Valentine Wallace
3f9868f235
Move ScorerAccountingForInFlightHtlcs to router + make public
We move it to router instead of scoring because it pairs with the InFlightHtlcs
struct in router and is useful for custom Router trait implementations
2022-11-30 16:20:31 -05:00
Valentine Wallace
5f49011c44
Fix typo in ScorerAccountingForInFlightHtlcs 2022-11-29 12:52:29 -05:00
Valentine Wallace
685b370694
Move ScoringRouter methods to Router
This helps us prepare to move all payment retries into ChannelManager, which is
needed for trampoline payments.
2022-11-29 12:52:25 -05:00
Tee8z
babde3a3c5
adds 'receiver_node_id' to 'Event::Payment{Received,Claimed}' 2022-11-28 08:36:02 -05:00
jurvis
2e818131c4
Remove paths from PaymentInfo in payment_cache
In c70bd1f, we implemented tracking HTLCs by adding path information
for pending HTLCs to `InvoicePayer`’s `payment_cache` when receiving
specific events.

Since we can now track inflight HTLCs entirely within ChannelManager,
there is no longer a need for this to exist.
2022-11-19 11:19:25 -08:00
jurvis
89f162c168
Compute InflightHtlcs from available information in ChannelManager 2022-11-19 11:19:23 -08:00
jurvis
05290c2860
Unparameterize HashMap from InFlightHtlcs initializer 2022-11-16 17:49:29 -08:00
Matt Corallo
d6aa1bc85a
Merge pull request #1826 from TheBlueMatt/2022-10-idempotency-err
Add a separate PaymentSendFailure for idempotency violation
2022-11-16 17:42:23 +00:00
Matt Corallo
49c9f1885d
Merge pull request #1806 from arik-so/2022-10-background-processor-deparametrization
Remove generic `Signer` parameter where it can be inferred from `KeysInterface`
2022-11-11 06:08:51 +00:00
Wilmer Paulino
05cb467234
Consume events by value in EventHandler's handle_event 2022-11-10 10:57:09 -08:00
Wilmer Paulino
f0059f5083
Use BaseEventHandler to expose async event handling on InvoicePayer
We introduce a new sealed trait BaseEventHandler that has a blanket
implementation for any T. Since the trait cannot be implemented outside
of the crate, this allow us to expose specific implementations of
InvoicePayer that allow for synchronous and asynchronous event handling.
2022-11-10 10:57:06 -08:00
Arik Sosman
1c8a06cf61
Remove generic Signer parameter where it can be inferred from KeysInterface 2022-11-09 16:15:11 -08:00
Matt Corallo
fcf73f0f45 Add a separate PaymentSendFailure for idempotency violation
When a user attempts to send a payment but it fails due to
idempotency key violation, they need to know that this was the
reason as they need to handle the error programmatically
differently from other errors.

Here we simply add a new `PaymentSendFailure` enum variant for
`DuplicatePayment` to allow for that.
2022-11-09 18:44:27 +00:00