Commit graph

6566 commits

Author SHA1 Message Date
Valentine Wallace
32ab7a9e4d
Avoid building routes over previously failed blinded payment paths. 2024-01-17 10:55:39 -05:00
Valentine Wallace
23ef2535d0
Store previously failed blinded paths on outbound payment failure.
Useful so we don't retry over these paths.
2024-01-17 10:44:38 -05:00
Valentine Wallace
5c5d691425
Persist previously failed blinded paths in RouteParameters.
Useful so we don't retry over these paths.
2024-01-17 10:44:33 -05:00
Valentine Wallace
75a1c47b19
Add failed_within_blinded_path to DecodedOnionFailure.
Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.
2024-01-17 10:44:33 -05:00
Valentine Wallace
ae1288d8cc
Add failed_within_blinded_path to onion util internal struct.
Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.
2024-01-17 10:44:33 -05:00
Matt Corallo
0d513fd6e5
Merge pull request #2817 from tnull/2024-01-time-in-electrum
Feature-gate `time` use also in `ElectrumSyncClient`
2024-01-09 16:57:16 +00:00
Elias Rohrer
2bd12137a4
Feature-gate time use also in ElectrumSyncClient
A previous commit introduced the `time` feature to gate the use of
`SystemTime` dependent APIs in `EsploraSyncClient`. It however omitted
doing the same for the Electrum side of things. Here, we address this
oversight.
2024-01-09 09:37:14 +01:00
Matt Corallo
78ac48ca9e
Merge pull request #2802 from TheBlueMatt/2023-12-no-pub-enum
Move `CandidateRouteHop` enum variant fields into structs
2024-01-08 21:33:00 +00:00
Matt Corallo
3fbee852b3
Merge pull request #2808 from TheBlueMatt/2023-12-fuzzing-fixes-1 2024-01-08 20:58:30 +00:00
Matt Corallo
7f24e833fb Fix reachable unwrap on non-channel_type manual channel acceptance
If we receive an `OpenChannel` message without a `channel_type`
with `manually_accept_inbound_channels` set, we will `unwrap()`
`None`.

This is uncommon these days as most nodes support `channel_type`,
but sadly is rather trivial for a peer to hit for those with manual
channel acceptance enabled.

Reported in and fixes #2804. Luckily, the updated
`full_stack_target` has no issue reaching this issue quickly.
2024-01-08 18:20:17 +00:00
Elias Rohrer
3c0420c39e
Merge pull request #2799 from benthecarman/tx-sync-wasm
Don't call system time in no-std
2024-01-08 18:55:07 +01:00
Matt Corallo
3c28767ceb Move CandidateRouteHop enum variant fields into structs
The bindings generator struggles a bit with the references in enum
variant fields in `CandidateRouteHop`. While we could probably fix
this, its much eaiser (and less risky) to inline the enum variant
fields from `CandidateRouteHop` into structs. This also lets us
make some of the fields non-public, which seems better at least for
the opaque `hint_idx` in the blinded paths.
2024-01-02 03:49:06 +00:00
Matt Corallo
3b6a361ae7 Fix dust buffer feerate calculation overflow
If a peer provides a feerate which nears `u32::MAX`, we may
overflow calculating the dust buffer feerate, leading to spuriously
keeping non-anchor channels open when they should be force-closed.
2023-12-29 06:24:18 +00:00
Matt Corallo
5d8cd5a0a2 Fix debug assertion on opening a channel with a disconnected peer
If we try to open a channel with a peer that is disconnected (but
with which we have some other channels), we'll end up with an
unfunded channel which will lead to a panic when the peer
reconnects. Here we drop this debug assertion without bother to add
a new test, given this behavior will change in a PR very soon.
2023-12-29 06:24:18 +00:00
Matt Corallo
c946edb218 Fix REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH for contest delays >0x7fff
When contest delays are >= 0x8000, script pushes require an extra
byte to avoid being interpreted as a negative int. Thus, for
channels with CSV delays longer than ~7.5 months we may generate
transactions with slightly too little fee. This isn't really a huge
deal, but we should prefer to be conservative here, and slightly
too high fee in the general case is better than slightly too little
fee in other cases.
2023-12-29 06:24:18 +00:00
Matt Corallo
ddb54fc2d2 Stop including dust values in feerate affordability checks
When we or our counterparty are updating the fees on the channel,
we currently check that the resulting balance is sufficient not
only to meet the reserve threshold, but also not push it below
dust. This isn't required in the BOLTs and may lead to spurious
force-closures (which would be a bit safer, but reserve should
always exceed the dust threshold).

Worse, the current logic is broken - it compares the output value
in *billionths of satoshis* to the dust limit in satoshis. Thus,
the code is borderline dead anyway, but can overflow for channels
with several million Bitcoin, causing the fuzzer to get mad (and
lead to spurious force-closures for few-billion-dollar channels).
2023-12-29 06:24:18 +00:00
Matt Corallo
df1f981627 Fix Feature eq + hash to ignore excess zero bytes
If we get a `Feature` object which has excess zero bytes, we
shouldn't consider it a different `Feature` from another with the
same bits set, but no excess zero bytes. Here we fix both the
`Hash` and `PartialEq` implementation for `Features` to ignore
excess zero bytes.
2023-12-24 17:34:11 +00:00
Matt Corallo
15b7f667b0
Merge pull request #2788 from tnull/2023-12-enforce-no-warnings-ci
Deny warnings in CI
2023-12-20 19:54:59 +00:00
benthecarman
f836794e98
Don't call system time in unless feature enabled 2023-12-19 13:22:17 -06:00
Elias Rohrer
2d6464cd71
Allow unused_variables for one _test_vectors method 2023-12-18 08:53:28 +01:00
Elias Rohrer
15e14166da
Allow unused imports in lightning-invoice prelude 2023-12-18 08:53:28 +01:00
Elias Rohrer
5933af1f2d
Drop unused windows imports in FilesystemStore tests 2023-12-18 08:53:28 +01:00
Elias Rohrer
befde89fae
Drop unenforced bound in trait alias
... to fix:
```
  error: bounds on generic parameters are not enforced in type aliases
   --> lightning/src/onion_message/messenger.rs:267:33
```
2023-12-18 08:53:28 +01:00
Elias Rohrer
3b6e83c0fc
Fix unused import warnings in c_bindings 2023-12-18 08:53:28 +01:00
Elias Rohrer
be574f5c27
Fix unused imports in lightning-invoice no-std tests 2023-12-18 08:53:27 +01:00
Elias Rohrer
d8eababd8b
Drop unused sync module from lightning-invoice 2023-12-18 08:53:27 +01:00
Elias Rohrer
c80d9a74b5
Fix unused (import) warnings in no-std builds 2023-12-18 08:53:27 +01:00
Elias Rohrer
e76ad1a245
Fix redundant import warning in BP's futures 2023-12-18 08:53:27 +01:00
Elias Rohrer
b923e1a6f5
Feature-gate GetUtxosResponse in lightning-block-sync
.. as it's only used by the REST client.
2023-12-18 08:53:27 +01:00
Elias Rohrer
8471644a2d
Deny warnings in CI
Since we recently got rid of our last build/test/doc warnings, we now
deny warnings via `-D warnings` in CI, enforcing no new ones are
introduced.
2023-12-18 08:53:27 +01:00
Matt Corallo
4deb2631dc
Merge pull request #2794 from TheBlueMatt/2023-12-cut-119
Cut 0.0.119
2023-12-16 02:57:20 +00:00
Matt Corallo
c6e4debee9 Bump versions to 0.0.119/lightning-invoice 0.27 2023-12-15 23:53:40 +00:00
Matt Corallo
d6c16aa1ae Add CHANGELOG entries for 0.0.119 2023-12-15 23:53:40 +00:00
Matt Corallo
ef2156ae8b
Merge pull request #2798 from TheBlueMatt/2023-12-119-bindings-upstream
Small API cleanups pre-0.0.119
2023-12-15 23:40:57 +00:00
Wilmer Paulino
f5e87d8441
Merge pull request #2795 from TheBlueMatt/2023-11-robuster-chan-to-peer
Move channel -> peer tracking to OutPoints from Channel IDs
2023-12-15 15:36:52 -08:00
Matt Corallo
2aecfa45ba Fix dev MSRV build of lightning-transaction-sync
...due to a transitive dependency of the `bitcoind` crate.
2023-12-15 22:39:57 +00:00
Matt Corallo
642240e867 Use correct default value when comparing to htlc_maximum_msat
62f8669654 added two
`htlc_maximum_msat.unwrap_or`s, but used a default value of 0,
spuriously causing all HTLCs to fail if we don't have an htlc
maximum value. This should be mostly harmless, but we should fix it
anyway.
2023-12-15 22:32:24 +00:00
Matt Corallo
bb0ddad00d Make FinalOnionHopData public
In 4b5db8c3ce, `channelmanager::PendingHTLCRouting` was made
public, exposing a `FinalOnionHopData` field to the world. However,
`FinalOnionHopData` was left crate-private, making the enum
impossible to construct.

There isn't a strong reason for this (even though the
`FinalOnionHopData` API is somewhat confusing, being separated from
the rest of the onion structs), so we expose it here.
2023-12-15 22:31:51 +00:00
Matt Corallo
83e76d78b7 Drop explicit bitcoin_hashes dependency in lightning-invoice
Since `lightning-invoice` now depends on the `bitcoin` crate
directly, also depending on the `bitcoin_hashes` crate is redundant
and just means we confuse users by setting the `std` flag only on
`bitcoin`. Thus, we drop the explicit dependency here and replace
it with `bitcoin::hashes`.
2023-12-15 22:31:51 +00:00
Matt Corallo
90cc9930b7 Un-export the PrivateRoute inner field as there are invariants
When we make the `PrivateRoute` inner `RouteHint` `pub`, we failed
to note that the `PrivateRoute::new` constructor actually verifies
a length invariant. Thus, we un-export the inner field and force
users to go back through the `new` fn.
2023-12-15 22:31:51 +00:00
Matt Corallo
b9797ebdd9
Merge pull request #2781 from jkczyz/2023-09-multihop-paths
Multi-hop `BlindedPath` creation interface
2023-12-15 22:30:43 +00:00
Jeffrey Czyz
37319a6193
Fix build warning 2023-12-15 15:40:10 -06:00
Jeffrey Czyz
164c8553e5
Use one-hop blinded paths only for announced nodes
To avoid exposing a node's identity in a blinded path, only create
one-hop blinded paths if the node has been announced, and thus has
public channels. Otherwise, there is no way to route a payment to the
node, exposing its identity needlessly.
2023-12-15 15:40:10 -06:00
Jeffrey Czyz
16ee24086c
DRY up OffersMessage::InvoiceRequest handling 2023-12-15 15:40:10 -06:00
Jeffrey Czyz
827833c933
Multi-hop blinded payment paths in ChannelManager
When constructing blinded payment paths for Bolt12Invoice, delegate to
Router::create_blinded_payment_paths which may produce multi-hop blinded
paths. Fallback to one-hop blinded paths if the Router fails or returns
no paths.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
62f8669654
Add create_blinded_payment_paths to Router
The Router trait is used to find a Route for paying a node. Expand the
interface with a create_blinded_payment paths method for creating such
paths to a recipient node.

Provide an implementation for DefaultRouter that creates two-hop
blinded paths where the recipient's peers serve as the introduction
nodes.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
edb5892030
CounterpartyForwardingInfo to PaymentRelay mapping 2023-12-15 15:40:09 -06:00
Jeffrey Czyz
4da08623a6
Fix broken doc link in create_refund_builder 2023-12-15 15:40:09 -06:00
Jeffrey Czyz
606304aa32
Multi-hop blinded paths in ChannelManager
When constructing blinded paths for Offer and Refund, delegate to
MessageRouter::create_blinded_paths which may produce multi-hop blinded
paths. Fallback to one-hop blinded paths if the MessageRouter fails or
returns no paths.

Likewise, do the same for InvoiceRequest and Bolt12Invoice reply paths.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
dcd8d58346
Use CLTV_FAR_FAR_AWAY in PaymentConstraints
When finding a route through a blinded path, a random CLTV offset may be
added to the path in order to preserve privacy. This needs to be
accounted for in the blinded path's PaymentConstraints. Add
CLTV_FAR_FAR_AWAY to the max_cltv_expiry constraint to allow for such
offsets.
2023-12-15 15:37:18 -06:00