Commit graph

174 commits

Author SHA1 Message Date
Matt Corallo
c57bb42204 Rename rejected_by_dest -> payment_failed_permanently
The `rejected_by_dest` field of the `PaymentPathFailed` event has
always been a bit of a misnomer, as its really more about retry
than where a payment failed. Now is as good a time as any to
rename it.
2022-09-07 20:58:05 +00:00
Jeffrey Czyz
00f08c910f
Merge pull request #1643 from jurvis/jurvis/2022-07-inflights-htlcs-across-payments
Track in-flight HTLCs across payments when routing
2022-09-01 15:01:30 -05:00
jurvis
80daf942b2
Make payment tests more realistic
Made sure that every hop has a unique receipient. When we simulate
calling `channel_penalty_msat` in `TestRouter`’s find route, use
actual previous node ids instead of just using the payer’s.
2022-08-31 18:50:03 -07:00
jurvis
c70bd1fd55
Keep track of inflight HTLCs across payments
Added two methods, `process_path_inflight_htlcs` and
`remove_path_inflight_htlcs`, that updates that `payment_cache` map with
path information that may have failed, succeeded, or have been given up
on.

Introduced `AccountForInflightHtlcs`, which will wrap our user-provided
scorer. We move the `S:Score` type parameterization from the `Router` to
`find_route`, so we can use our newly introduced
`AccountForInflightHtlcs`.

`AccountForInflightHtlcs` keeps track of a map of inflight HTLCs by
their short channel id, direction, and give us the value that is being
used up.

This map will in turn be populated prior to calling `find_route`, where
we’ll use `create_inflight_map`, to generate a current map of all
inflight HTLCs based on what was stored in `payment_cache`.
2022-08-31 18:50:02 -07:00
Matt Corallo
7223f70616 Drop honggfuzz arbitrary dependency to meet MSRV 2022-08-30 15:15:00 +00:00
jurvis
706b638196
Change payment_cache to accept PaymentInfo
Introduces a new `PaymentInfo` struct that contains both the previous
`attempts` count that was tracked as well as the paths that are also
currently inflight.
2022-08-29 22:51:43 -07:00
Matt Corallo
ea5b62fff6
Merge pull request #1677 from ok300/ok300-patch-1
Bump bitcoin_hashes to v0.11
2022-08-19 22:18:59 +00:00
NicolaLS
e263d904a1 derive Hash for Invoice 2022-08-19 16:40:54 +02:00
ok300
1cc2bc5145
Bump bitcoin_hashes to v0.11 2022-08-19 16:40:19 +02:00
Matt Corallo
b414c0641b
Merge pull request #1658 from lightning-signer/2022-08-bitcoin-0-29
Update bitcoin crate to 0.29.0
2022-08-12 23:51:06 +00:00
Devrandom
7e05623bef Update bitcoin crate to 0.29.0 2022-08-11 00:21:26 +02:00
Valentine Wallace
c242003dd3
Fix CI to error on doc links to private items
Somehow we weren't doing this.
2022-08-07 13:49:12 -04:00
Matt Corallo
6b1ec5c738
Merge pull request #1632 from TheBlueMatt/2022-07-warnings
Fix compilation warnings
2022-07-27 16:29:09 +00:00
Matt Corallo
e10dfe4fd0 Bump crate versions to 0.0.110/invoice 0.18 2022-07-26 22:01:09 +00:00
Matt Corallo
4da6f23cff Drop unused test code in lightning-invoice::payment 2022-07-26 20:31:17 +00:00
Elias Rohrer
eb8bce0d16 Add send_probe and introduce probing cookies
When we send payment probes, we generate the [`PaymentHash`] based on a
probing cookie secret and a random [`PaymentId`]. This allows us to
discern probes from real payments, without keeping additional state.
2022-07-07 09:02:29 +02:00
Matt Corallo
156cc77753 Bump crate versions to 0.0.109/invoice 0.17 2022-07-01 16:05:33 +00:00
Matt Corallo
87a6e013f7 Have find_route take a NetworkGraph instead of a ReadOnly one
Because downstream languages are often garbage-collected, having
the user directly allocate a `ReadOnlyNetworkGraph` and pass a
reference to it to `find_route` often results in holding a read
lock long in excess of the `find_route` call. Worse, some languages
(like JavaScript) tend to only garbage collect when other code is
not running, possibly leading to deadlocks.
2022-06-29 17:45:49 +00:00
NicolaLS
6c15de1399 add optional dependency on serde to implement serialize/deserialize for invoice 2022-06-20 11:49:30 +02:00
Wilmer Paulino
44fa3acae8
Rename UserConfig and LegacyChannelConfig fields
The current names aren't very clear to what each field represents, this
commit aims to improve that.
2022-06-13 13:57:00 -07:00
Matt Corallo
5421e1a6e7
Merge pull request #1529 from wpaulino/move-channel-config-static-fields
Move ChannelConfig static fields to ChannelHandshakeConfig
2022-06-13 04:04:23 -07:00
Matt Corallo
deac430f17 Update crate versions to 0.0.108/invoice 0.16 2022-06-10 14:53:23 +00:00
Wilmer Paulino
850ca13fbc
Move announced_channel to ChannelHandshakeConfig
In the near future, we plan to allow users to update their
`ChannelConfig` after the initial channel handshake. In order to reuse
the same struct and expose it to users, we opt to move out all static
fields that cannot be updated after the initial channel handshake.
2022-06-09 16:11:15 -07:00
Jeffrey Czyz
b2e635f619
Bump crate versions to 0.0.107/invoice 0.15 2022-06-08 18:16:48 -05:00
Jeffrey Czyz
67736b7480
Parameterize NetworkGraph with Logger
P2PGossipSync logs before delegating to NetworkGraph in its
EventHandler. In order to share this handling with RapidGossipSync,
NetworkGraph needs to take a logger so that it can implement
EventHandler instead.
2022-06-06 13:02:43 -05:00
Jeffrey Czyz
574870e9f8
Move network_graph.rs to gossip.rs
The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.
2022-06-02 15:15:30 -07:00
Justin Moon
7b8f6843f5 Add 'repository' to lightning-invoice's Cargo.toml 2022-06-01 13:17:16 -05:00
Elias Rohrer
e98f68aee6 Rename FundingLocked to ChannelReady. 2022-05-30 17:07:09 -07:00
Jeffrey Czyz
75ca50f5c0
Merge pull request #1490 from arik-so/rust_beta_doc_fix
Fix rust beta docs for lightning-invoice crate.
2022-05-23 00:16:04 -05:00
Arik Sosman
46e58ae025
Merge pull request #1492 from tnull/2022-05-fix-bolts-url
Docs: Update to 'new' spec repository URL.
2022-05-20 11:20:55 -07:00
Arik Sosman
71d89d2c98
Fix rust beta docs lightning-invoice crate. 2022-05-20 08:31:56 -07:00
Elias Rohrer
ba7935d1f3 Use new spec repository URL. 2022-05-20 17:17:29 +02:00
Jeffrey Czyz
197cbc4d28
Pass effective capacity to scorer
Scorers could benefit from having the channel's EffectiveCapacity rather
than a u64 msat value. For instance, ProbabilisticScorer can give a more
accurate penalty when given the ExactLiquidity variant. Pass a struct
wrapping the effective capacity, the proposed amount, and any in-flight
HTLC value.
2022-05-19 14:25:22 -05:00
KaFai Choi
b7d6d0dc8e
add timeout retry strategy to outbound payment 2022-05-17 13:27:22 +07:00
Duncan Dean
ea016cd824
Address post-ACK formatting nits from #1474 2022-05-11 10:57:38 +02:00
Duncan Dean
3369b2962d
Add expiry to non-phantom invoice utils 2022-05-10 20:22:01 +02:00
Duncan Dean
15a840147a
Actually add expiry to phantom invoice utils 2022-05-10 20:18:06 +02:00
Devrandom
28d33ff9e0 bitcoin crate 0.28.1 2022-05-05 18:04:42 +02:00
Viktor Tigerström
3c67687066 Add htlc min/max to create invoice functions 2022-04-21 12:27:51 +02:00
Duncan Dean
8f047ca23f
Add expiry to inbound payment util functions 2022-04-16 22:49:28 +02:00
Matt Corallo
03f655003d
Merge pull request #1384 from valentinewallace/2022-03-chanmanless-phantom-invoices 2022-04-13 14:51:35 +00:00
Valentine Wallace
204dd42a7d
Expose methods for ChannelManager-less phantom invoice generation 2022-04-11 18:43:48 -04:00
Matt Corallo
ce5a9f528a Move lightning-invoice deser errors to lib.rs instead of pub use
Having public types in a private module is somewhat awkward from a
readability standpoint, but, more importantly, the bindings logic
has a relatively rough go of converting them - it doesn't implement
`pub use` as its "implement this function" logic is all within the
context of a module. We'd need to keep a set of re-exported things
to implement them when parsing modules...or we could just move two
enums from `de.rs` to `lib.rs` here, which is substantially less
work.
2022-04-04 13:19:41 +00:00
Jeffrey Czyz
de8bb8d261
Bump crate versions to 0.0.106/invoice 0.14 2022-04-03 08:05:08 -05:00
Luiz Parreira
7714393cf0
Create normal/phantom invoice with description hash 2022-03-18 15:08:00 -03:00
Viktor Tigerström
ff792e05bb Add phantom invoice route hints filtering tests 2022-03-16 11:24:12 +01:00
Viktor Tigerström
43cc81c893 Filter route hints for phantom invoices
Filter the route hints in `create_phantom_invoice` based on the
following criteria:

* Only one channel for every counterparty node per phantom
payment-receiving node in the invoice
* Always select the channel with the highest inbound capacity
* For each payment-receiving node, filter out channels with a lower
inbound capacity than the invoice amount, if any channel exists with
enough capacity to cover the invoice amount
* If any public channels exists for a payment-receiving node, push a
single RouteHintHop with the phantom route and let the sender find the
path to the payment-receiving node through the public channels.
2022-03-16 11:24:12 +01:00
Viktor Tigerström
eae5086b8d Add tests for create invoice route hints filtering 2022-03-16 11:24:12 +01:00
Viktor Tigerström
fe49fbd7b8 Filter route hints for create invoice
Filter the route hints in `create_invoice_from_channelmanager` based on
the following criteria:

* Only one channel per counterparty node
* Always select the channel with the highest inbound capacity
* Filter out channels with a lower inbound capacity than the invoice
amount, if any channel exists with enough capacity to cover the invoice
amount
* If any public channel exists, the invoice route_hints should be empty,
and the sender will need to find the path to the payment-receiving node
by looking at the public channels instead
2022-03-16 11:24:12 +01:00
Jeffrey Czyz
ca163c3fae
Merge pull request #1331 from TheBlueMatt/2022-02-no-copy-invoice-fields
Use &mut self in invoice updaters, not take-self-return-Self
2022-03-11 14:26:02 -06:00