Commit graph

327 commits

Author SHA1 Message Date
Elias Rohrer
d7e2ff6220
Introduce RouteParameters::max_total_routing_fee_msat
Currently, users have no means to upper-bound the total fees accruing
when finding a route. Here, we add a corresponding field to
`RouteParameters` which will be used to limit the candidate set during
path finding in the following commits.
2023-09-26 09:44:04 +02:00
Matt Corallo
36af1f06fa
Merge pull request #2534 from tnull/2023-08-upstream-preflight-probing
Upstream and fix preflight probing
2023-09-18 16:41:57 +00:00
Elias Rohrer
f75ac9addf
Expose AChannelManager trait and use it in lightning-invoice 2023-09-18 15:08:28 +02:00
Elias Rohrer
20c842b496
Add preflight probing capabilities
We add a `ChannelManager::send_preflight_probes` method that can be used
to send pre-flight probes given some [`RouteParameters`]. Additionally,
we add convenience methods in for spontaneous probes and send pre-flight
probes for a given invoice.

As pre-flight probes might take up some of the available liquidity, we
here introduce that channels whose available liquidity is less than the
required amount times
`UserConfig::preflight_probing_liquidity_limit_multiplier` won't be used
to send pre-flight probes.

This commit is a more or less a carbon copy of the pre-flight
probing code recently added to LDK Node.
2023-09-18 15:08:27 +02:00
benthecarman
79b426f49b
Re-export RouteHint and PaymentSecret 2023-09-14 12:41:11 -05:00
Elias Rohrer
1f32ba4616
Remove mention of spontaneous payments from lightning-invoice 2023-09-13 11:52:45 +02:00
Elias Rohrer
266a3aa915
Have get_route take RouteParameters 2023-09-06 19:35:37 +02:00
optout
e99e6ab562
Use new ChannelId type 2023-08-26 01:30:40 +02:00
optout
513c2b4e4b Use Display of PaymentHash; avoid log_bytes macro 2023-08-22 18:16:50 +02:00
Matt Corallo
31049ed961 Delay RAA-after-next processing until PaymentSent is are handled
In 0ad1f4c943 we fixed a nasty bug
where a failure to persist a `ChannelManager` faster than a
`ChannelMonitor` could result in the loss of a `PaymentSent` event,
eventually resulting in a `PaymentFailed` instead!

As noted in that commit, there's still some risk, though its been
substantially reduced - if we receive an `update_fulfill_htlc`
message for an outbound payment, and persist the initial removal
`ChannelMonitorUpdate`, then respond with our own
`commitment_signed` + `revoke_and_ack`, followed by receiving our
peer's final `revoke_and_ack`, and then persist the
`ChannelMonitorUpdate` generated from that, all prior to completing
a `ChannelManager` persistence, we'll still forget the HTLC and
eventually trigger a `PaymentFailed` rather than the correct
`PaymentSent`.

Here we fully fix the issue by delaying the final
`ChannelMonitorUpdate` persistence until the `PaymentSent` event
has been processed and document the fact that a spurious
`PaymentFailed` event can still be generated for a sent payment.

The original fix in 0ad1f4c943 is
still incredibly useful here, allowing us to avoid blocking the
first `ChannelMonitorUpdate` until the event processing completes,
as this would cause us to add event-processing delay in our general
commitment update latency. Instead, we ultimately race the user
handling the `PaymentSent` event with how long it takes our
`revoke_and_ack` + `commitment_signed` to make it to our
counterparty and receive the response `revoke_and_ack`. This should
give the user plenty of time to handle the event before we need to
make progress.

Sadly, because we change our `ChannelMonitorUpdate` semantics, this
change requires a number of test changes, avoiding checking for a
post-RAA `ChannelMonitorUpdate` until after we process a
`PaymentSent` event. Note that this does not apply to payments we
learned the preimage for on-chain - ensuring `PaymentSent` events
from such resolutions will be addressed in a future PR. Thus, tests
which resolve payments on-chain switch to a direct call to the
`expect_payment_sent` function with the claim-expected flag unset.
2023-08-17 22:19:48 +00:00
Alec Chen
039b1c8d10
Allow users to provide custom TLVs through RecipientOnionFields
Custom TLVs allow users to send extra application-specific data with
a payment. These have the additional flexibility compared to
`payment_metadata` that they don't have to reflect recipient generated
data provided in an invoice, in which `payment_metadata` could be
reused.

We ensure provided type numbers are unique, increasing, and within the
experimental range with the `RecipientOnionFields::with_custom_tlvs`
method.

This begins sender-side support for custom TLVs.
2023-08-08 15:55:00 -05:00
Matt Corallo
983f2c1870 Bump crate versions to 0.0.116 release 2023-07-21 20:42:13 +00:00
Matt Corallo
cc5fea84e6 Update version numbers to rc1, from alpha1 2023-07-17 20:07:30 +00:00
Jeffrey Czyz
7ad3f88eba
Qualify the BOLT 11 invoice description type
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:59:33 -05:00
Jeffrey Czyz
a28c90a1b3
Qualify the BOLT 11 invoice signature type
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:53:07 -05:00
Jeffrey Czyz
8c4a85b357
Qualify the BOLT 11 invoice features type
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:49:00 -05:00
Jeffrey Czyz
62ca48f979
Qualify the BOLT 11 semantic error type
A previous commit qualified the BOLT 12 semantic error type. Qualify the
BOLT 11 semantic error type for consistency.
2023-07-14 15:06:17 -05:00
Jeffrey Czyz
6fb34d30b3
Qualify the BOLT 11 parse error type
A previous commit qualified the BOLT 12 parse error type. Qualify the
BOLT 11 parse error type for consistency.
2023-07-14 15:06:17 -05:00
Jeffrey Czyz
4c383a39a8
Qualify the BOLT 11 raw invoice types
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:06:10 -05:00
Jeffrey Czyz
93ead4aec5
Qualify the BOLT 11 invoice type
A previous commit qualified the BOLT 12 invoice type. Qualify the BOLT
11 invoice type for consistency.
2023-07-14 15:05:11 -05:00
Jeffrey Czyz
3e50011e22
Fix grammar in docs 2023-07-14 15:04:30 -05:00
Wilmer Paulino
81722ca833
Handle new event processing logic when enqueuing forward event
This was a regression resulting from f2453b7 since we now process events
in a loop until there aren't any left. Processing events is done in
batches and they are not removed until we're done processing each batch.
Since handling a `PendingHTLCsForwardable` event will call back into the
`ChannelManager`, we'll still see the original forwarding event not
removed. Phantom payments will need an additional forwarding event
before being claimed to make them look real by taking more time.
2023-07-10 09:49:31 -07:00
Matt Corallo
bd12067777
Merge pull request #2372 from wpaulino/channelmanager-new-highest-seen-timestamp
Require best block timestamp within ChannelManager::new
2023-06-29 04:15:46 +00:00
Wilmer Paulino
82e0df5e4d
Require best block timestamp within ChannelManager::new
This ensures freshly initialized nodes can proceed to create unexpired
invoices without a call to `best_block_updated`, since an invoice's
expiration delta is applied to `highest_seen_timestamp`.
2023-06-27 13:43:14 -07:00
Matt Corallo
23e9fc79fd Bump versions to LDK 116-alpha1 and invoice 24.0-alpha1 2023-06-23 19:43:26 +00:00
valentinewallace
9cafede23c
Merge pull request #2340 from TheBlueMatt/2023-06-fix-docs
Remove spurious docs which imply you cannot retry a failed payment
2023-06-06 16:41:22 +02:00
Matt Corallo
60ce627b23 Remove spurious double comma in documentation 2023-06-06 00:44:06 +00:00
Matt Corallo
632c0d22b5 Remove spurious docs which imply you cannot retry a failed payment
If a payment (fully) fails, users are free to retry it, its only
once a payment succeeds that a user must never retry it.
2023-06-05 23:53:45 +00:00
Jeffrey Czyz
486c16a26d
Merge pull request #2290 from upjohnc/2240_replace_vectors_with_iterators
Set return type to Iterator for functions in file: `lightning-invoice/src/utils.rs` : issue #2240
2023-06-05 13:43:46 -05:00
Chad Upjohn
ec67ee7020 Refactor lightning-invoice/src/utils.rs to yield iterators
- two functions refatored: `select_phantom_hints`, `sort_and_filter_channels`
2023-06-01 14:45:38 -05:00
Chad Upjohn
31807bc2f6 Adding rotate_through_iterators for select_phantom_hints refactor
- adding function to allow for select_phantom_hints to yield an iterator
2023-05-31 11:46:08 -05:00
benthecarman
3003f7d719
Derive a PartialEq and Eq for PaymentError
This lets users compare error types more easily without needing a match
statement.
2023-05-24 17:40:48 -05:00
Wilmer Paulino
7b64527b16
Merge pull request #2279 from benthecarman/ord-invoice
Impl PartialOrd and Ord for Invoice
2023-05-10 11:24:00 -07:00
benthecarman
2ddce64ba6
Impl PartialOrd and Ord for Invoice 2023-05-09 12:39:17 -05:00
Matt Corallo
0ecb4b093a
Merge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2
Prefactor `PaymentParameters` for blinded recipients
2023-05-08 23:17:42 +00:00
Valentine Wallace
6d62b62cec
Error if BOLT 11 features are provided for blinded payment params 2023-05-08 18:01:43 -04:00
Valentine Wallace
cea78f585a
Error if clear hints are provided for blinded PaymentParams 2023-05-04 10:50:53 -04:00
Martin Habovstiak
6964299fc5 Remove unneeded allocation
`<E as serde:🇩🇪:Error>::custom()` accepts any `T: Display`, not just
`String`. Therefore it accepts `Arguments<'_>` too so we can use
`format_args!()` instead of `format!()`.

See https://github.com/lightningdevkit/rust-lightning/pull/2187#discussion_r1168781355
2023-05-04 11:21:04 +02:00
Arik Sosman
6cb9919f0c
Move keysinterface.rs to a directory-level module called sign. 2023-05-02 21:48:08 -07:00
Matt Corallo
c3de782a2b
Merge pull request #2044 from freddiekrugerrand/1782-limitchannelhints
Limit route hints to three channels
2023-04-27 22:02:16 +00:00
Matt Corallo
53c48c1c8f Add a bindings constructor for lightning-invoice's Sha256 wrapper 2023-04-25 22:51:18 +00:00
Fred Walker
905cd8bc65
Limit phantom invoice hints to 3 2023-04-25 15:46:20 -04:00
Fred Walker
3e65e625be
Move phantom route hint selection into its own function 2023-04-25 15:46:03 -04:00
Matt Corallo
fb424009e3 Bump crate versions to 0.0.115/invoice 0.23 2023-04-24 22:40:17 +00:00
Matt Corallo
2e15df730f
Merge pull request #2127 from TheBlueMatt/2023-03-payment-metadata
Support sending `PaymentMetadata` in HTLCs
2023-04-19 17:17:49 +00:00
Matt Corallo
ef8e3770a9 Fix variable name typo 2023-04-19 14:55:48 +00:00
Matt Corallo
a41d75fb08 Add some tests of payment metadata being sent and received 2023-04-19 14:55:48 +00:00
Matt Corallo
ee9afd315d Add a payment_metadata field to RecipientOnionFields
This adds the new `payment_metadata` to `RecipientOnionFields`,
passing the metadata from BOLT11 invoices through the send pipeline
and finally copying them info the onion when sending HTLCs.

This completes send-side support for the new payment metadata
feature.
2023-04-19 02:57:19 +00:00
Matt Corallo
8ed6e64913 Support setting the new payment metadata field in invoices
This adds support for setting the new payment metadata field in
BOLT11 invoices, using a new type flag on the builder to enforce
transition correctness.

We allow users to set the payment metadata as either optional or
required, defaulting to optional so that invoice parsing does not
fail if the sender does not support payment metadata fields.
2023-04-19 02:57:19 +00:00
Matt Corallo
928c9b806e Support reading the new payment_metadata field in invoices
This adds support for reading the new `PaymentMetadata` BOLT11
invoice field, giving us access to the `Vec<u8>` storing arbitrary
bytes we have to send to the recipient.
2023-04-19 02:57:19 +00:00