Commit graph

7158 commits

Author SHA1 Message Date
Jeffrey Czyz
fe114efa8b
Fix typos 2024-04-15 11:00:28 -05:00
Jeffrey Czyz
b7f73fa188
Resolve blinded path when creating onion message
Add a version of the create_onion_message utility function that attempts
to resolved the introduction node of the destination's BlindedPath using
a ReadOnlyNetworkGraph`. Otherwise, if given a path using the compact
representation, using create_onion_message would fail. Keep the current
version for use internally and for external uses where the blinded path
is known to be resolved.
2024-04-15 10:59:03 -05:00
Jeffrey Czyz
3f90d77122
Cache introduction_node_id lookup in get_route 2024-04-15 10:58:31 -05:00
Jeffrey Czyz
9f1ffab24c
Look up node id from scid in OnionMessenger
When forwarding onion messages, the next node may be represented by a
short channel id instead of a node id. Parameterize OnionMessenger with
a NodeIdLookUp trait to find which node is the next hop. Implement the
trait for ChannelManager for forwarding to channel counterparties.

Also use this trait when advancing a blinded path one hop when the
sender is the introduction node.
2024-04-15 10:58:30 -05:00
Jeffrey Czyz
32a5139eb5
Resolve IntroductionNode::DirectedShortChannelId
When OnionMessenger creates an OnionMessage to a Destination, the latter
may contain an IntroductionNode::DirectedShortChannelId inside a
BlindedPath. Resolve these in DefaultMessageRouter and handle unresolved
ones in OnionMessenger.
2024-04-15 10:58:30 -05:00
Jeffrey Czyz
7002180261
Generalize BlindedPath::introduction_node_id field
Allow using either a node id or a directed short channel id in blinded
paths. This allows for a more compact representation of blinded paths,
which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the directed short channel id
case in OnionMessenger as it requires resolving the introduction node in
MessageRouter.
2024-04-15 10:58:30 -05:00
Jeffrey Czyz
e0bc6fa8b2
Add source reference to BlindedPathCandidate hop
Blinded paths currently contain a node id for the introduction node.
However, a compact representation will allow a directed short channel id
instead. Update BlindedPathCandidate and OneHopBlindedPathCandidate to
store a NodeId reference from either the NetworkGraph or from the user-
provided first hops.

This approach avoids looking up the introduction node id on demand,
which may not be resolvable. Thus, that would require returning an
Option from CandidateRouteHop::source and handle None accordingly.
2024-04-15 10:58:23 -05:00
valentinewallace
322e1f3a98
Merge pull request #2987 from TheBlueMatt/2024-04-test-ser-bug
Add test coverage for cc78b77c71
2024-04-15 11:23:09 -04:00
Matt Corallo
bc4a5eae32
Merge pull request #2971 from jbesraa/review-club/2815
Fix comparison in `get_dust_buffer_feerate`
2024-04-13 19:59:05 +00:00
jbesraa
c01745eec7
Fix cmp::max execution in ChannelContext::get_dust_buffer_feerate
The current `cmp::max` doesnt align with the function comment, ie its
  comparing 2530 and `feerate_plus_quarter` instead of `feerate_per_kw
  + 2530` and `feerate_plus_quarter` which is fixed in this commit
2024-04-12 23:41:14 +03:00
Wilmer Paulino
b835e4f67a
Fix race between handshake_complete and timer_tick_occurred
The initial noise handshake on connection establishment must complete
within a single timer tick. This timeout is enforced via
`awaiting_pong_timer_tick_intervals` whenever a timer tick fires while
our handshake has yet to complete. Currently, on an inbound connection,
if a timer tick fires after we've sent act two of the noise handshake
along with our init message and before receiving the counterparty's init
message, we begin enforcing such timeout. Even if we immediately
continue to process the counterparty's init message to complete to
handshake, the timeout enforcement is not cleared. With the handshake
complete, `awaiting_pong_timer_tick_intervals` is now tracked to enforce
a pong timeout, except a ping was never actually sent. If a single timer
tick fires again without having received a message from the peer, or
enough timer ticks fire to trigger the
`MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` logic, we'll end up
disconnecting the peer due to a timeout for a pong we'll never receive.

We fix this by always resetting `awaiting_pong_timer_tick_intervals`
upon processing our counterparty's init message.
2024-04-12 10:57:34 -07:00
Matt Corallo
10480f009e Log pending in-flight updates when we are missing a monitor
If we are missing a `ChannelMonitor` for which the `ChannelManager`
has pending updates, it may be useful to print what the updates we
have actually are, at least useful in identifying the bug(s).
2024-04-11 15:20:08 +00:00
Jeffrey Czyz
63ebaccca3
Add BlindedPath::introduction_node_id method
Blinded paths use a pubkey to identify the introduction node, but it
will soon allow using a directed short channel id instead. Add an
introduction_node_id method to BlindedPath to facilitate lookup in the
latter case.
2024-04-10 19:11:20 -05:00
Jeffrey Czyz
b783736356
Add IndexedMap::get_key_value
Useful for applying Option::map when needing both the key and value for
when needing a reference to the key with a longer lifetime.
2024-04-10 19:11:19 -05:00
Jeffrey Czyz
d85e0d619a
Generalize onion message ForwardTlvs::next_node_id
Allow either using a node id or a short channel id when forwarding an
onion message. This allows for a more compact representation of blinded
paths, which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the short channel id case as
it requires looking up the destination node id.
2024-04-10 19:11:19 -05:00
Matt Corallo
1d2a27d119
Merge pull request #2910 from tnull/2024-02-rustfmt-sign-mod
`rustfmt`:  Format `sign` module
2024-04-10 20:50:46 +00:00
Valentine Wallace
38b78eccb5 Add test coverage for cc78b77c71
cc78b77c71 fixed an important
downgrade bug, but neglected to add test coverage. Here we recitfy
that by adding a few simple tests of common cases.

Tests heavily tweaked by Matt Corallo <git@bluematt.me>.
2024-04-09 15:43:57 +00:00
Elias Rohrer
3a199c6987
Remove no-std-check/src/lib.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:09:51 +02:00
Elias Rohrer
822635716c
Remove msrv-no-dev-deps-check/src/lib.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:09:51 +02:00
Elias Rohrer
039da78ea9
Run rustfmt on msrv-no-dev-deps-check/src/lib.rs 2024-04-09 13:09:51 +02:00
Elias Rohrer
8e6a27c9b3
Remove sign/type_resolver.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:09:51 +02:00
Elias Rohrer
37fbd3a41a
Run rustfmt on sign/type_resolver.rs 2024-04-09 13:09:51 +02:00
Elias Rohrer
b3f8470996
Remove sign/taproot.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:09:51 +02:00
Elias Rohrer
1693e704b4
Run rustfmt on sign/taproot.rs 2024-04-09 13:09:50 +02:00
Elias Rohrer
0c220c1e0c
Remove sign/mod.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:09:50 +02:00
Elias Rohrer
540534b716
Run rustfmt on sign/mod.rs 2024-04-09 13:09:37 +02:00
Elias Rohrer
7442548263
Move input_idx retrieval into closure 2024-04-09 13:08:25 +02:00
Elias Rohrer
c906fac293
Move htlc_basepoint to variable 2024-04-09 13:08:25 +02:00
Elias Rohrer
2690823c9d
Move hash_to_message to variable 2024-04-09 13:08:25 +02:00
Elias Rohrer
b6059e9f39
Move low-R comments into blocks 2024-04-09 13:08:25 +02:00
Elias Rohrer
5cc321594d
Pull anchor check into helper function 2024-04-09 13:08:25 +02:00
Elias Rohrer
113b0f1a0e
Remove sign/ecdsa.rs from rustfmt exclusion list
.. now continously checking its formatting in CI.
2024-04-09 13:08:24 +02:00
Elias Rohrer
93ec3bddba
Run rustfmt on sing/ecdsa.rs 2024-04-09 13:08:24 +02:00
valentinewallace
eaf76f6cce
Merge pull request #2969 from TheBlueMatt/2024-03-fix-upgradable-enum 2024-04-08 16:34:14 +02:00
Matt Corallo
f852d16d92 Allow MaybeReadable to not fully read in upgradable_option
Whils this is generally not supported, issues in our
`MaybeReadable` implementations may occur, and we should try to be
robust against them.
2024-04-07 19:55:56 +00:00
Matt Corallo
d6770d4a74 Ensure we read the full TLV stream length when maybe-reading None
If we are reading an object that is `MaybeReadable` in a TLV stream
using `upgradable_required`, it may return early with `Ok(None)`.
In this case, it will not read any further TLVs from the TLV
stream. This is fine, except that we generally expect
`MaybeReadable` always consume the correct number of bytes for the
full object, even if it doesn't understand it.

This could pose a problem, for example, in cases where we're
reading a TLV-stream `MaybeReadable` object inside another
TLV-stream object. In that case, the `MaybeReadable` object may
return `Ok(None)` and not consume all the available bytes, causing
the outer TLV read to fail as the TLV length does not match.
2024-04-07 19:55:56 +00:00
Matt Corallo
cc78b77c71 Fix unknown handling in impl_writeable_tlv_based_enum_upgradable
`impl_writeable_tlv_based_enum_upgradable` professed to supporting
upgrades by returning `None` from `MaybeReadable` when unknown
variants written by newer versions of LDK were read. However, it
generally didn't support this as it didn't discard bytes for
unknown types, resulting in corrupt reading.

This is fixed here for enum variants written as a TLV stream,
however we don't have a length prefix for tuple enum variants, so
the documentation on the macro is updated to mention that
downgrades are not supported for tuple variants.
2024-04-07 19:55:56 +00:00
dunxen
1d9e541c57
Merge pull request #2704 from jkczyz/2023-11-channelmanager-docs
`ChannelManager` documentation refresh
2024-04-07 20:34:57 +02:00
Jeffrey Czyz
998fffb99b
Add BOLT 12 Refunds section to ChannelManager docs 2024-04-06 11:11:30 +02:00
Jeffrey Czyz
761f09b04c
Add BOLT 12 Offers section to ChannelManager docs 2024-04-06 11:11:30 +02:00
Jeffrey Czyz
7cf899bfc9
Add a payments section to ChannelManager docs 2024-04-06 11:11:23 +02:00
Jeffrey Czyz
11d07c6252
Add a channels section to ChannelManager docs 2024-04-05 13:15:03 +02:00
Jeffrey Czyz
f3db184876
Add an operations section to ChannelManager docs 2024-04-05 13:15:03 +02:00
Jeffrey Czyz
c39c398f06
ChannelManager initialization docs with example 2024-04-05 13:14:57 +02:00
Elias Rohrer
3a9fe209e1
Merge pull request #2954 from TheBlueMatt/2024-03-test-ci-beta-fail
Fix new warnings causing CI build failures on rustc beta
2024-04-05 12:53:40 +02:00
Gursharan Singh
3eb61f7e9b
Merge pull request #2967 from tnull/2024-03-refactor-drop-handle-message
Split `PeerManager::handle_message` to avoid explicit `mem::drop`
2024-04-05 12:26:51 +02:00
Matt Corallo
2f734f9755 Fix unused warning for un-accessed enum variant field in net-tokio 2024-04-05 09:05:56 +00:00
Matt Corallo
ef2e739295 Remove a handful of redundant imports
... that newer rustc now warns about.
2024-04-05 09:05:56 +00:00
Matt Corallo
d1d7d8787e Mark several test_utils which are only used in test as cfg(test) 2024-04-05 09:05:56 +00:00
Matt Corallo
d9b9854e87 Drop now-unused methods on Time
We no longer use `Time` during scoring, which makes several of its
methods now useless. We remove those here.
2024-04-05 09:05:56 +00:00