Commit graph

4379 commits

Author SHA1 Message Date
Elias Rohrer
a85d5b1444
Add blanket Persist/Persister impls for dyn KVStore + Send + Sync
Previously, we only had blanket impls for `KVStore`. However, in order
to enable the use of `dyn KVStore + Send + Sync` instead of a `KVStore`
generic, we here also add the corresponding blanket implementations for
said type signature.
2024-02-07 12:56:06 +01:00
Matt Corallo
a9d73c2889
Merge pull request #2873 from tnull/2024-02-expose-channel-details-in-bte
Expose `channel_id` / `counterparty_node_id` in `BumpTransaction` event
2024-02-07 00:57:01 +00:00
Elias Rohrer
5b5c87464a
Expose channel_id / counterparty_node_id in BumpTransaction event
A client node might choose not to handle `Event::BumptTransaction`
events and leave bumping / Anchor output spending to a trusted
counterparty.

However, `Event::BumptTransaction` currently doesn't offer any clear
indication what channel and/or counterparty it is referring to. In order
to allow filtering these events, we here expose the `channel_id` and
`counterparty_node_id` fields.
2024-02-06 21:02:33 +01:00
Matt Corallo
d1c2e143fe Note when new HTLC state can be None 2024-02-06 18:53:56 +00:00
Matt Corallo
8296515871 Fix comment spelling 2024-02-06 18:53:04 +00:00
Matt Corallo
4a7ba675d4
Merge pull request #2442 from wvanlint/list_pending_htlcs
Include pending HTLC's in ChannelDetails
2024-02-06 18:45:36 +00:00
Elias Rohrer
a0917e50e8
Merge pull request #2876 from TheBlueMatt/2024-02-2863-doc-nits
Minor doc nits on the new coop close reason variants
2024-02-06 11:44:32 +01:00
Willem Van Lint
67e788eaa7 Include pending HTLCs in ChannelDetails
This exposes details around pending HTLCs in ChannelDetails.  The state
of the HTLC in the state machine is also included, so it can be
determined which protocol message the HTLC is waiting for to advance.
2024-02-05 17:35:54 -08:00
Matt Corallo
e64342afab
Merge pull request #2810 from TheBlueMatt/2023-12-arbitrary-fuzz-config
Update `full_stack_target` to take an arbitrary config object
2024-02-05 23:53:06 +00:00
Matt Corallo
e594021052
Merge pull request #2847 from TheBlueMatt/2024-01-bindings-upstream
Misc Tweaks for bindings
2024-02-05 23:49:19 +00:00
Matt Corallo
bad2efb73c Minor doc nits on the new coop close reason variants 2024-02-05 23:47:36 +00:00
Matt Corallo
8d9d099bf8
Merge pull request #2725 from shaavan/issue2096
Ensure successful message propagation in case of disconnection mid-handshake
2024-02-05 23:44:36 +00:00
Matt Corallo
f70c113fd8
Merge pull request #2863 from benthecarman/breakup-coop-close
Breakup CooperativeClosure into Local/Remote initiated
2024-02-05 23:43:26 +00:00
Elias Rohrer
2e61d92044
Expose channel_type in Event::ChannelPending
It is useful to immediately know what kind of channel is being opened,
and not having to wait until `ChannelReady`.
2024-02-05 14:32:33 +01:00
benthecarman
efcb5d9d0f
Rename old CooperativeClosure to LegacyCooperativeClosure 2024-02-04 16:33:28 +00:00
benthecarman
58f7942e11
Breakup CooperativeClosure into Local/Remote initiated 2024-02-04 16:33:27 +00:00
Matt Corallo
c9e4410a05 Fix test variable typos 2024-02-02 18:05:09 +00:00
Matt Corallo
dedc8306f6 Bump hashbrown dependency to 0.13
While this isn't expected to materially improve performance, it
does get us ahash 0.8, which allows us to reduce fuzzing
randomness, making our fuzzers much happier.

Sadly, by default `ahash` no longer tries to autodetect a
randomness source, so we cannot simply rely on `hashbrown` to do
randomization for us, but rather have to also explicitly depend on
`ahash`.
2024-02-02 18:05:08 +00:00
Matt Corallo
efbaa41fae Stop relying on Hash{Set,Map}::from_iter directly
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for `FromIterator`
constructors instead of calling the tables directly to make the
version bump changeset smaller.
2024-02-02 18:04:51 +00:00
Matt Corallo
3e0d55bd2b Use utility methods to construct HashMaps and HashSets
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for constructors
instead of calling the tables directly to make the version bump
changeset smaller.
2024-02-02 18:04:51 +00:00
Matt Corallo
f62a96ea93 Use arbitrary config object in full_stack_target fuzzer
As we've added more and more configuration parameters which change
our behavior, we're increasingly missing coverage in the general
`full_stack_target` fuzzer. Sadly, a reachable `unwrap` slipped in
uncaught that should have been stopped by the `full_stack_target`.

Here, we update the `full_stack_target` fuzzer to read a full
config object to substantially increase coverage.
2024-02-02 18:04:51 +00:00
Matt Corallo
248e2f5be5 Disable fuzzing-reachable debug assertions in ChannelMonitors 2024-02-02 18:04:51 +00:00
Matt Corallo
c7258426cd Disable fuzzing-reachable debug assertion
Because of txid conflicts, a txid can match both a local and remote
commitment transaction when fuzzing. Thus, we disable this
assertion when fuzzing.
2024-02-02 18:04:51 +00:00
Jeffrey Czyz
7c9463668a
Merge pull request #2868 from orbitalturtle/export-send-onion-path
export send_onion_message_using_path for testing
2024-02-02 11:18:24 -06:00
Matt Corallo
4d993c06b4
Merge pull request #2870 from benthecarman/pub-source-target
Make DirectedChannelInfo `source` and `target` public
2024-02-02 17:08:52 +00:00
benthecarman
a931decbbb
Make DirectedChannelInfo source and target public
We use these params for our HubPreferentialScorer and without these
utility functions then we have to manually do this and calculate which
is the source and which is the target node.
2024-02-02 14:14:51 +00:00
Orbital
06f9dd7e83
export send_onion_message_using_path for testing 2024-02-01 20:22:53 -06:00
valentinewallace
3751398518
Merge pull request #2858 from tnull/2024-01-expose-skimmed-fee-msat
Expose withheld amount for underpaying HTLCs in `PaymentForwarded`
2024-02-01 09:42:22 -05:00
Elias Rohrer
96445880f6
Expose skimmed_fee_msat in PaymentForwarded
We generally allow routing nodes to forward less than the expected HTLC
amount, if the receiver knowingly accepts this and claims the
underpaying HTLC (see `ChannelConfig::accept_underpaying_htlcs`). This
use case is in particular useful for the LSPS2/JIT channel setting where
the intial underpaying HTLC pays for the channel open.

While we previously exposed the withheld amount as
`PaymentClaimable::counterparty_skimmed_fee_msat` on the receiver side,
we did not individually provide it on the forwarding node's side.
Here, we therefore expose this additionally withheld amount via
`PaymentForwarded::skimmed_fee_msat`.
2024-02-01 09:21:15 +01:00
shaavan
a6a6b48102 Add tests to check the introduced behaviour
- The first test make sure that the OutboundV1Channel is not
immediately removed when peers disconnect, but is removed after N timer
ticks.
- The second test makes sure that the SendOpenChannel is rebroadcasted
for the OutboundV1Channel if peer reconnects within time.
2024-01-31 18:00:03 +05:30
shaavan
ddf75afd16 Do not remove Outbound Channel immediately when peer disconnects
- Do not remove channel immediately when peer_disconnect, instead
  removed it after some time if peer doesn't reconnect soon (handled in
previous commit).
- Do not mark per ok_to_remove if we have some OutboundV1Channels too.
- Rebroadcast SendOpenChannel for outboundV1Channel when peer
  reconnects.
- Update the relevant tests to account for the behavior change.
- Repurpose the test_disconnect_in_funding_batch to test that all
  channels in the batch close when one them closes.
2024-01-31 17:59:50 +05:30
Elias Rohrer
8e472669a1
Rename PaymentForwarded::fee_earned_msat to total_fee_earned_msat 2024-01-31 13:22:20 +01:00
Valentine Wallace
2616f02016
Track min HTLC overpay separately from skimmed fees in test utils 2024-01-31 13:22:19 +01:00
Valentine Wallace
42490efa2c
Struct-ify claim_along_route args.
Lays groundwork to make claim_payment* test utils easier to adapt without
changing a million callsites.
2024-01-31 13:22:19 +01:00
Duncan Dean
361079d842
Fix followups to PR2797 2024-01-31 07:58:56 +02:00
Matt Corallo
fb693ecbf8 [bindings] Move additional score params from &() to Default
In 26c1639ab6 (and later in
50c55dcf32) we switched to using
`Default::default()` to initialize `()` for scoring parameters in
tests. A number of `()`s slipped back in recently, which we replace
here.
2024-01-30 23:56:12 +00:00
Matt Corallo
5d5c8187b4 Store EntropySource in DefaultRouter instead of passing it
...as an arg to `Router`. Passing an `EntropySource` around all
the time is a bit strange as the `Router` may or may not actually
use it, and the `DefaultRouter` can just as easily store it.
2024-01-30 23:56:12 +00:00
Matt Corallo
3716227359 Fix three_hop_blinded_path_success with different randomization
In `three_hop_blinded_path_success`, the nodes in the test ended up
at radically different block heights after channel opening. At that
point, if the CLTV randomization is done slightly different the
test payment may fail, which we fix here by ensuring all nodes are
at the same height before we go to send a payment.
2024-01-30 23:56:12 +00:00
Matt Corallo
a634fd1dad
Merge pull request #2780 from wpaulino/2691-follow-ups
2691 follow-ups
2024-01-30 23:21:42 +00:00
Duncan Dean
cf2c27800a
Remove Outpoint::to_channel_id method
To avoid confusion and for accuracy going forward, we remove this method
as it is inconsistent with channel IDs generated during V2 channel
establishment. If one wants to create a V1, funding outpoint-based
channel ID, then `ChannelId::v1_from_funding_outpoint` should be used
instead.

A large portion of the library has always made the assumption that having
the funding outpoint will always allow us to generate the channel ID.
This will not be the case anymore and we need to pass the channel ID along
where appropriate. All channels that could have been persisted up to this
point could only have used V1 establishment, so if some structures don't
store a channel ID for them they can safely fall back to the funding
outpoint-based version.
2024-01-30 12:30:26 +02:00
Wilmer Paulino
25ec63f70e
Enforce compile-time check for flag getters and setters
This ensures that we cannot define or use flag getters/setters on
`ChannelState` variants in which said flag is not valid.
2024-01-29 14:00:06 -08:00
Wilmer Paulino
9ab7a48ff1
Use clear helper on flags copy to mask off bits 2024-01-29 13:57:19 -08:00
Matt Corallo
51d9ee35e5
Merge pull request #2694 from Evanfeenstra/public-scid-utils
public scid utils
2024-01-25 01:52:13 +00:00
Matt Corallo
a5ba3391f8 [bindings] No-export RouteHopCandidate lifetime'd fields
The bindings cannot express lifetimes, so exposing any field which
is a reference (and not `clone`-able, at least for garbage
collected language bindings) is unsafe for those expecting a
high-level interface.

Thus, we simply no-export the `RouteHopCandidate` inner struct
fields which are references (there are relevant accessors for them
anyway).
2024-01-24 23:19:11 +00:00
Matt Corallo
4764fa3985 [bindings] Mark WithContext log wrapper with no-export
There's not a lot of reason for downstream users to use the
`WithContext` wrapper, it mostly exists for our own downstream
crates anyway, and dealing with lifetimes in bindings isn't super
practical, so simply no-export it.
2024-01-24 23:19:11 +00:00
Matt Corallo
e5c0c62c17 [bindings] Drop the lifetime bound on Record for bindings builds
Because log `Record`s are now being passed by ownership to `log`,
the bindings get quite annoyed that there's a lifetime hanging
around. We already don't use this lifetime in bindings (the
`FormatArgs` is converted to a string and stored on the heap), so
we can just drop the lifetime, even though it requires some
macro'ing of the struct definition to do so.
2024-01-24 23:17:43 +00:00
Matt Corallo
76fff953bd
Merge pull request #2697 from jkczyz/2023-10-offer-functional-tests
Functional tests for BOLT 12 Offers payment flow
2024-01-24 23:14:01 +00:00
Matt Corallo
7b31b303c6 Bump versions to LDK 0.0.121/invoice 0.29 2024-01-22 22:32:30 +00:00
Matt Corallo
15c9f5bd7c
Merge pull request #2841 from TheBlueMatt/2024-01-batch-deadlock
Fix deadlock when handling bad calls to `batch_funding.._generated`
2024-01-22 22:30:59 +00:00
Jeffrey Czyz
7b8d018f1f
Remove unnecessary unwraps 2024-01-22 16:26:54 -06:00