Commit graph

5580 commits

Author SHA1 Message Date
Matt Corallo
189c1fbe2c Fail UTXO lookups if the block doesn't have five confirmations
The BOLT spec mandates that channels not be announced until they
have at least six confirmations. This is important to enforce not
because we particularly care about any specific DoS concerns, but
because if we do not we may have to handle reorgs of channel
funding transactions which change their SCID or have conflicting
SCIDs.
2023-08-23 21:48:03 +00:00
Matt Corallo
3482fceeab Add a simple naive block cache in gossip sync lookups 2023-08-23 21:48:03 +00:00
Matt Corallo
b315856e68 Make the P2PGossipSync UtxoLookup exchangable without &mut self
Because a `UtxoLookup` implementation is likely to need a reference
to the `PeerManager` which contains a reference to the
`P2PGossipSync`, it is likely to be impossible to get a mutable
reference to the `P2PGossipSync` by the time we want to add a
`UtxoLookup` without a ton of boilerplate and trait wrapping.

Instead, we simply place the `UtxoLookup` in a `RwLock`, allowing
us to modify it without a mutable self reference.

The lifetime bounds updates in tests required in this commit are
entirely unclear to me, but do allow tests to continue building, so
somehow make rustc happier.
2023-08-23 21:48:03 +00:00
Matt Corallo
01857b51a1 Implement the UtxoSource interface for REST/RPC clients
In LDK, we expect users operating nodes on the public network to
implement the `UtxoSource` interface in order to validate the
gossip they receive from the network.

Sadly, because the DoS attack of flooding a node's gossip store
isn't a common issue, and because we do not provide an
implementation off-the-shelf to make doing so easily, many of our
downstream users do not have a `UtxoSource` implementation.

In order to change that, here we implement an async `UtxoSource`
in the `lightning-block-sync` crate, providing one for users who
sync the chain from Bitcoin Core's RPC or REST interfaces.
2023-08-23 21:48:03 +00:00
Matt Corallo
8164cb9307 Accept RPC responses with a null result
This is actually a valid response in some cases, at least for the
`gettxout` command, where `null` is returned if no corresponding
UTXO was found, but the command otherwise succeeded.
2023-07-28 19:01:34 +00:00
valentinewallace
685f266655
Merge pull request #2446 from TheBlueMatt/2023-07-ci-more-test
Run all tests first before testing more esoteric flags in CI
2023-07-25 11:07:41 -07:00
valentinewallace
c6c684be30
Merge pull request #2448 from TheBlueMatt/2023-07-cm-clone
Impl clone for ChannelMonitor
2023-07-25 10:46:48 -07:00
Matt Corallo
c383f06538
Merge pull request #2370 from valentinewallace/2023-06-send-along-path-args
Update `send_payment_along_path` to take its args as struct
2023-07-24 22:43:58 +00:00
benthecarman
d026259d3e Impl clone for ChannelMonitor
This gives people more freedom with the channel monitors. For Mutiny
this would be nice for us to be able to create copies of them and pass
aorund in memory without having to serialize until we actually want to.

Originally by benthecarman <benthecarman@live.com>
Small bugfix from Matt Corallo <git@bluematt.me>
2023-07-24 22:36:03 +00:00
Matt Corallo
aa3c78658e Run all tests first before testing more esoteric flags in CI
This should at least marginally more aggressively target things
which are more likely to have changed in CI, making `ci-tests.sh`
more useful as a "default" script for developers to run locally.
2023-07-24 22:04:10 +00:00
Matt Corallo
e13ff10c63
Merge pull request #2431 from arik-so/2023-07-public-excess-data 2023-07-24 03:52:27 +00:00
Elias Rohrer
78f59a5345
Merge pull request #2444 from szabgab/https
http => https
2023-07-23 19:28:17 +02:00
Gabor Szabo
1da6fc2ded http => https 2023-07-23 08:58:41 +03:00
Matt Corallo
4938be6ad7
Merge pull request #2427 from TheBlueMatt/2023-07-cut-116
Release 0.0.116
2023-07-21 23:15:05 +00:00
Matt Corallo
983f2c1870 Bump crate versions to 0.0.116 release 2023-07-21 20:42:13 +00:00
Matt Corallo
e9e806bc41 Add a warning on anchors and update 116 changelog for release 2023-07-21 20:42:13 +00:00
Matt Corallo
ae33b093b8 Add lightning-background-processor no-std feature
While this is generally uneccessary as users set the `no-std` or
`std` features on the `lightning` crate directly, having this
allows `lightning-background-processor` to be built by itself
without extra dep lines. Specifically, the bindings are moving to
using the `-Z avoid-dev-deps` option, which now causes
`lightning-background-processor` to fail to build directly.
2023-07-21 20:33:13 +00:00
Jeffrey Czyz
0fadb54d7f
Merge pull request #2436 from tnull/2023-07-improve-router-logging
Improve router logging and update documentation
2023-07-21 15:25:57 -05:00
Matt Corallo
d7e3320c03
Merge pull request #2439 from tnull/2023-05-fix-0conf-sigs-racing-confirms
Avoid panic when 0conf channel's ann. sigs race on-chain confirmation
2023-07-21 19:37:28 +00:00
Elias Rohrer
1db53a9d73
Improve logging for ignored candiate hops
Previously, we barely gave any hints why we excluded certain hops during
pathfinding. Here, we introduce more verbose logging by a) accounting
how much candidates we ignored for which reasons and b) logging any
first/last/blinded hops we end up ignoring.

Fixes #1646.
2023-07-21 20:28:47 +02:00
Elias Rohrer
543c5bfe13
Update outdated router.rs docs
As `RouteParameters` are not included anymore in
`Event::PaymentPathFailed` since 0.0.115, and we don't give value/payee
as immediate arguments to `find_route` anymore.
2023-07-21 20:28:47 +02:00
Matt Corallo
a61746246c
Merge pull request #2434 from TheBlueMatt/2023-07-116-bindings-part-2
0.0.116 Bindings Changes
2023-07-21 16:39:19 +00:00
Elias Rohrer
adcac97ebc
Avoid unwraping in get_announcement_sigs
While this is currently not reachable, it's still cleaner to
avoid the `unwrap` and return `None` if `short_channel_id` hasn't been
set yet.
2023-07-21 09:54:28 +02:00
Elias Rohrer
82fdf0f62d
Avoid panic when 0conf channel's ann. sigs race on-chain confirmation
A channel's `short_channel_id` is currently only set when the funding
transaction is confirmed via `transactions_confirmed`, which might be
well after the channel initally becomes usable, e.g., in the 0conf case.

Previously we would panic due to a reachable `unwrap` when receiving a
counterparty's `announcement_signatures` message for a 0conf channel
pending confirmation on-chain.

Here we fix this bug by avoiding unsafe `unwrap`s and just erroring out
and ignoring the announcement_signatures message if the `short_channel_id`
hasn't been set yet.
2023-07-21 09:54:28 +02:00
Matt Corallo
27bf1d053d Add relevant derives for BigSize as its a simple integer 2023-07-20 21:43:52 +00:00
Matt Corallo
8cffeb6dba Add relevant trait derives for bump_transaction structs
Notably including `Hash`/`Eq`/`Ord` for structs which may be used
in maps.
2023-07-20 21:43:52 +00:00
Matt Corallo
5f120b1b65 Make OffersMessage and offers errors Cloneable 2023-07-20 21:43:52 +00:00
Matt Corallo
8c61d9d0dc Make requires_unknown_bits_from param type bindings compatible
While bindings should probably be able to figure out that this is
the same type as `Self`, for now we simply swap the type to make
the bindings generator have an easier go of it.
2023-07-20 21:43:52 +00:00
Matt Corallo
9f9ed591a5 Mark the Duration serialization implementation no-bindings-export
The bindings are being updated to consider all traits even if the
trait itself is no-export, which causes issues generating code
around the `Duration` impl here.
2023-07-20 21:43:52 +00:00
Matt Corallo
6d62d5d021 No-export un-exportable types in BOLT12 module
We missed one method that now cannot be bindings exported - the
`payment_paths` method, as it returns a slice of objects, which
cannot be supported in bindings.
2023-07-20 21:43:52 +00:00
Matt Corallo
a8acbe710e No-export APeerManager in bindings
`APeerManager` will simply be mapped as `PeerManager` in bindings,
as structs are all concretized into a single form.
2023-07-20 21:43:52 +00:00
Matt Corallo
97a6246b6f Move ClaimId to [u8; 32] in bindings.
This matches what we've done for other `[u8; 32]` newtypes.
2023-07-20 21:43:52 +00:00
Matt Corallo
0b9c5204af Tweak PSBT signing for bindings compatibility
In bindings we can't practically pass a mutable PSBT, and instead
need to pass an owned transaction and have the sign method return a
signed copy. We do this here for all build modes as its not a
material API change for Rust users.
2023-07-20 21:43:52 +00:00
Matt Corallo
a287234366 Add a c_bindings test to check-compiles.sh as it should build 2023-07-20 21:43:52 +00:00
Matt Corallo
e4c44f3c5b
Merge pull request #2430 from TheBlueMatt/2023-07-116-bindings-part-1
Assorted 0.0.116 Bindings updates
2023-07-20 21:42:44 +00:00
Matt Corallo
16311f98b3
Merge pull request #2382 from dunxen/2077-followups
Address outstanding 2077 feedback
2023-07-20 21:40:04 +00:00
Matt Corallo
35dda4e61c Drop c_bindings implementation of scoring on Mutex/RefCell
This code was always effectively dead - we have a special
`MultiThreadedLockableScore` type which wraps a `Mutex` for
bindings users, so there's no need to implement any
bindings-specific scoring logic for them.
2023-07-20 19:49:43 +00:00
Matt Corallo
d2c20ecc2d Pass InFlightHltcs to the scorer by ownership rather than ref
Given we build `InFlightHtlcs` per route-fetch call, there's no
reason to pass them out by reference rather than simply giving the
user the full object. This also allows them to tweak the in-flight
set before fetching a route.
2023-07-20 19:49:43 +00:00
Matt Corallo
0c629ff60a Pass must-spend inputs to users by ownership
We already hold them in a vec, so there's no cost to passing them
by ownership vs making it a slice. Further, this helps bindings as
we can't represent slices to non-pointers in a sensible way.
2023-07-20 19:49:43 +00:00
Matt Corallo
be08b4f6b8 Tweak transaction bumping sign_tx types for bindings
In bindings we can't practically pass a mutable transaction, and
instead need to pass an owned transaction and have the sign method
return a signed copy. We do this here for all build modes as the
API is roughly equivalent also to Rust users.
2023-07-20 19:49:22 +00:00
Arik Sosman
b28769bfd1
Publicize UnsignedChannelAnnouncement's excess_data.
Making the `excess_data` field public significantly
simplifies writing legible unit tests for the
Rapid Gossip Sync Server.
2023-07-20 11:08:27 -07:00
Matt Corallo
8a8f29a8bb
Merge pull request #2423 from wpaulino/2403-fixups
PR #2403 fixups
2023-07-19 17:43:30 +00:00
Duncan Dean
50a6d41d26
Close and remove unfunded inbound/outbound channels that are older than an hour
We introduce a `UnfundedChannelContext` which contains a counter for the
current age of an unfunded channel in timer ticks. This age is incremented
for every `ChannelManager::timer_tick_ocurred` and the unfunded channel
is removed if it exceeds `UNFUNDED_CHANNEL_AGE_LIMIT_TICKS`.

The value will not be persisted as unfunded channels themselves are not
persisted.
2023-07-19 19:12:10 +02:00
Duncan Dean
b4d082b833
Remove redundant 'outbound' wording from methods 2023-07-19 19:10:32 +02:00
Duncan Dean
bd297fe39d
Force close pending channels in internal_shutdown 2023-07-19 19:10:30 +02:00
Duncan Dean
a70b1f74ce
Consider all channel maps in update_partial_channel_config 2023-07-19 19:10:29 +02:00
Duncan Dean
c2851ea5d8
Fallback close_channel_internal to force close unfunded channels 2023-07-19 19:10:28 +02:00
Duncan Dean
f27515dbb2
Add missing unfunded channel maps checks in ChannelManager
One of a series of follow-up commits to address some issues found
in PR 2077, where we split channels up into different maps and structs
depending on phase in their life.
2023-07-19 19:10:27 +02:00
Duncan Dean
e9001aa004
Refer to channels busy with funding tx negotiation as "unfunded"
We had some inconsistencies so far in referring to channels such as
`OutboundV1Channel` and `InboundV1Channel` as pending and unfunded.
From here we refer to these kinds of channels only as "unfunded".

This is a slight conflation with the term "unfunded" in the contexts
of denial of service mitigation. There, "unfunded" actually refers to
non-0conf, inbound channels that have not had their funding transaction
confirmed. This might warrant changing that usage to "unconfirmed inbound".
2023-07-19 19:10:26 +02:00
Wilmer Paulino
2e86a5958a
Merge pull request #2426 from TheBlueMatt/2023-07-proc-macro2-msrv 2023-07-19 09:11:43 -07:00