Commit graph

7235 commits

Author SHA1 Message Date
Elias Rohrer
15c709d747
Merge pull request #3089 from TheBlueMatt/2024-06-channel_state-module
Move the public channel state API into a new module
2024-06-04 16:28:39 +02:00
Matt Corallo
2d6d5cc86f Move the public path for channel_state types to their new path 2024-06-04 14:21:08 +00:00
Matt Corallo
41b878e6db Reformat channel_state.rs to match rustfmt requirements 2024-06-04 14:21:08 +00:00
Matt Corallo
1f616c0058 Move the public channel state API into a new module
Our "what is the channel's current state" structs have slowly
grown to be rather nontrivial, and now include eight structs with
many fields. Thus, it makes sense to pull them out of
`ln::channelmanager` and into their own module.

This also makes things easier for the C bindings which don't
support `pub use` from a private module.
2024-06-04 14:21:08 +00:00
Matt Corallo
7f47d67858
Merge pull request #2965 from tnull/2024-03-impl-readable-writeable-offer-invoice-refund
Implement `Readable` for `Offer` and `Refund`
2024-06-04 07:19:42 -07:00
Elias Rohrer
fc14495ac6
Implement Readable for Refund
When storing `Refund`s, it's useful for them to implement LDK's
deserialization trait.
2024-06-04 09:44:19 +02:00
Elias Rohrer
c13b6d814b
Implement Readable for Offer
When storing `Offer`s, it's useful for them to implement LDK's
deserialization trait.
2024-06-04 09:44:18 +02:00
Arik
993cd1e525
Merge pull request #2889 from Sharmalm/2840
Allow for user-specified error message during force close channel
2024-06-03 14:48:52 -07:00
Matt Corallo
73263348ba
Merge pull request #3057 from G8XSU/2024-05-08-claimable-persist-3049
Minimize reads to counterparty_claimable_outpoints
2024-06-03 09:24:57 -07:00
dunxen
c9de6503dd
Merge pull request #2947 from tnull/2024-03-log-features-if-mismatch 2024-06-03 16:59:15 +02:00
Matt Corallo
bd16a1e409
Merge pull request #2996 from shaavan/issue2882.2
Allow responding asynchronously to OnionMessage
2024-05-31 14:57:11 -07:00
Matt Corallo
bfda1b683b
Merge pull request #3063 from jirijakes/upgrade-bitcoin-031
Upgrade rust-bitcoin dependency to 0.31
2024-05-31 14:18:23 -07:00
Elias Rohrer
c57b94aeee
Merge pull request #2931 from TheBlueMatt/2024-03-log-outbound-channels
Log available liquidity on each channel when starting routefinding
2024-05-31 12:31:21 +02:00
Matt Corallo
7d2d04798d
Merge pull request #3084 from jkczyz/2024-05-onion-fields
Include `RecipientOnionFields` in `Event::PaymentClaimed`
2024-05-30 13:01:40 -07:00
G8XSU
1690c66396
Minimize reads to counterparty_claimable_outpoints
Reads related to current/previous commitment_tx should be explicit
and reads related to older commitment_txs should be minimized.
2024-05-30 09:49:26 -07:00
Matt Corallo
136e89ebe6 Log available liquidity on each channel when starting routefinding
One of the most common first-steps in troubleshooting routefinding
issues is we ask for the local channel state to determine what the
available HTLC bounds are. While we log first-hop channel details
when we decline to use them, this doesn't tell us if we have
missing channels, and thus here we log all first-hop channels at
the start.

We also take this opportunity to log the limits that were violated
any time we log that we're not using a channel, rather than only
when its a first-hop.
2024-05-30 15:11:07 +00:00
Jiri Jakes
a8bd4c097f
Upgrade rust-bitcoin to 0.31 2024-05-30 18:35:29 +08:00
shaavan
d8adbb0a5b Introduce new tests for ResponseInstruction::WithReplyPath
- The new tests check both successful and unsuccessful `reply_path`
  creation conditions.
2024-05-30 12:36:58 +05:30
shaavan
b95cfed7bb Refactor TestCustomMessageHandler
- Introduce a new struct for keeping expectations organized.
- Add a boolean field to track whether a response is expected,
  and hence whether a `reply_path` should be included with the response.
- Update Ping and Pong roles for bidirectional communication.
- Introduce panic for when there is no responder and we were expecting
  to include a `reply_path`.
- Refactor `handle_custom_message` code.
2024-05-30 12:36:58 +05:30
shaavan
7d5dd6b299 Refactor: Rename Request & Response to Ping & Pong
1. These two variants will be modified in an upcoming commit
   to be each other's response.
2. The names are updated to better fit their new roles.
2024-05-30 12:36:58 +05:30
shaavan
6904786ed4 Introduce ResponseInstruction::WithReplyPath variant.
And expand handle_onion_message_response return Type

1. Introduce a new function in OnionMessenger to create blinded paths.
2. Use it in handle_onion_message_response to create a reply_path for
   the right variant and use it in onion_message.
3. Expand the return type of handle_onion_message_response to handle three cases:
	1. Ok(None) in case of no response to be sent.
	2. Ok(Some(SendSuccess) and Err(SendError) in case of successful and
   	unsuccessful queueing up of response messages respectively.

This allows the user to get access to the Success/Failure status of the sending
of response and handle it accordingly.
2024-05-30 12:36:56 +05:30
shaavan
ca5b6b51d1 Convert handle_onion_message_response to a public function and add test coverage
This commit modifies handle_onion_message_response to be accessible
publicly as handle_onion_message, enabling users to respond
asynchronously. Additionally, a new test is introduced to validate this
functionality.
2024-05-30 12:36:24 +05:30
Matt Corallo
df0120809f
Merge pull request #3011 from jkczyz/2024-04-compact-blinded-path-creation
Compact blinded path creation
2024-05-28 18:43:20 -07:00
Jeffrey Czyz
e4661fe4c4
Add missing copyright statement 2024-05-28 16:35:56 -05:00
Jeffrey Czyz
e8354b212b
Compact introduction node test vector 2024-05-28 16:35:56 -05:00
Jeffrey Czyz
0a6886ee38
Compact a BlindedPath's introduction node
Add a method to BlindedPath that given a network graph will compact the
IntroductionNode as the DirectedShortChannelId variant. Call this method
from DefaultMessageRouter so that Offer paths use the compact
representation (along with reply paths). This leaves payment paths in
Bolt12Invoice using the NodeId variant, as the compact representation
isn't as useful there.
2024-05-28 16:35:56 -05:00
Jeffrey Czyz
4956ade170
Unwrap reply_path in extract_invoice_request 2024-05-28 16:35:55 -05:00
Jeffrey Czyz
e553a71b6f
Pass ForwardNode when creating BlindedPath
Instead of passing Vec<PublicKey> to MessageRouter::crate_blinded_path,
pass Vec<ForwardNode>. This way callers can include a short_channel_id
for a more compact BlindedPath encoding.
2024-05-28 16:35:55 -05:00
Jeffrey Czyz
d792afb08c
Support NextHop::ShortChannelId in BlindedPath
When sending an onion message to a blinded path, the short channel id
between hops isn't need in each hop's encrypted_payload since it is not
a payment. However, using the short channel id instead of the node id
gives a more compact representation. Update BlindedPath::new_for_message
to allow for this.
2024-05-28 16:35:41 -05:00
valentinewallace
2c71923a5a
Merge pull request #3006 from arik-so/arik/trampoline/2024-04-trampoline-onion-deserialization
Trampoline Onion Deserialization
2024-05-28 16:55:17 -04:00
Matt Corallo
5d9f3b4fc2
Merge pull request #3051 from TheBlueMatt/2024-04-2982-123-fix
Don't attempt to resume channels if we already exchanged funding
2024-05-28 10:47:23 -07:00
Matt Corallo
53cd31a2ec Don't attempt to resume channels if we already exchanged funding
ddf75afd16 introduced the ability to re-exchange our `ChannelOpen`
after a peer disconnects if we didn't complete funding on our end.
It did not implement nor consider what would happen if we
re-connected after we created our own funding transactions, and
currently it panics (and even if it did not it would replay the
`FundingTransactionGenerated` event to users).

While we'd very much like to replay the `open_channel` flow even
if we have already received an `accept_channel` and funded the
channel, we cannot as the peer will likely provide different key
material in their `accept_channel`, causing us to need a different
funding transaction.

Thus, here, we simply close channels which have been funded but not
yet signed when our peer disconnects.
2024-05-28 15:34:46 +00:00
Jeffrey Czyz
8499214bcc
Check custom_tlvs in Event::PaymentClaimed 2024-05-24 16:52:08 -05:00
Jeffrey Czyz
ac15105162
Pass ClaimAlongRouteArgs to claim_payment_along_route 2024-05-24 16:52:08 -05:00
Jeffrey Czyz
b6ff46daab
Pass ClaimAlongRouteArgs to do_claim_payment_along_route 2024-05-24 16:52:08 -05:00
Jeffrey Czyz
b745047fe4
Include RecipientOnionFields in PaymentClaimed
RecipientOnionFields are included in Event::PaymentClaimable, so
naturally they should be included in Event::PaymentClaimed, too.
2024-05-24 16:51:09 -05:00
Jeffrey Czyz
a4a34f9ae9
Add RecipientOnionFields to ClaimingPayment
This will be used to include the same field in Event::PaymentClaimed.
2024-05-24 11:44:11 -05:00
Jeffrey Czyz
3ab45d82d1
Use HashMap::entry instead of HashMap::insert
This allows for obtaining the value without needing to re-look it up. An
upcoming commit will include RecipientOnionFields in the inserted value.
Having it available afterwards prevents needing to clone it.
2024-05-24 11:31:30 -05:00
Jeffrey Czyz
101af71515
Format HashMap::insert call 2024-05-24 11:30:55 -05:00
Elias Rohrer
1d421d3362
Merge pull request #3079 from jkczyz/2024-05-expects-quantity
Add missing `Offer::expects_quantity` to tests
2024-05-23 13:01:06 +02:00
Jeffrey Czyz
7ceb709530
Add missing Offer::expects_quantity to tests 2024-05-22 14:20:43 -05:00
valentinewallace
a95338a8f6
Merge pull request #3038 from TheBlueMatt/2024-05-no-dir-with-on-side-offline
Ignore partially-pruned channels during routing
2024-05-21 11:05:30 -04:00
Matt Corallo
37bf61c49b
Merge pull request #3026 from valentinewallace/2024-04-limit-path-len
Limit payment path length based on `payment_metadata`, custom TLVs, etc.
2024-05-21 07:19:37 -07:00
Matt Corallo
511d7e3f5f
Merge pull request #3073 from tnull/2024-05-bump-nits
Fix minor nits in `BumpTransactionEventHandler`
2024-05-21 06:08:35 -07:00
Elias Rohrer
c84c2b6030
Merge pull request #3068 from toxeus/main
Re-export bitcoin crate
2024-05-21 12:18:53 +02:00
Arik Sosman
98a926f07d
Test Trampoline onion (de)serialization round trip. 2024-05-20 17:32:21 -07:00
Arik Sosman
c9fb4a3760
Make Trampoline onion deserializable. 2024-05-20 17:32:21 -07:00
Valentine Wallace
3cc673bec2
Add public util on RouteParameters for setting max path length. 2024-05-20 18:57:18 -04:00
Valentine Wallace
c07245f129
Test routing payment parameters' max path length setting and usage. 2024-05-20 18:57:18 -04:00
Valentine Wallace
f0b5c58201
outbound_payment: set max path length in PaymentParameters.
So the router knows how long the maximum payment path can be.
2024-05-20 18:57:13 -04:00