Commit graph

4342 commits

Author SHA1 Message Date
Jeffrey Czyz
9277166a8b
Drop error type parameter from SignError
SignError allows implementors of SignFunction to return a custom error
type. Drop this as an unconstrained type causes problems with bindings
and isn't useful unless the caller can take some sort of action based on
different errors.
2024-03-08 10:39:23 -06:00
Jeffrey Czyz
6b7050e8dc
Fix unused import warning 2024-03-08 10:39:23 -06:00
Jeffrey Czyz
407762446c
Support BOLT 12 signing in c_bindings
Replace the Fn trait bound on signing methods with a dedicated trait
since Fn is not supported in bindings. Implement the trait for Fn so
that closures can still be used in Rust.
2024-03-08 10:39:22 -06:00
Jeffrey Czyz
3bd00b943a
Add c_bindings version of InvoiceBuilder
Use the macros introduced in the previous commit to define two builders
for each type parameterization of InvoiceBuilder
- InvoiceWithExplicitSigningPubkeyBuilder
- InvoiceWithDerivedSigningPubkeyBuilder

The difference between these and InvoiceBuilder is that these have
methods that take `self` by mutable reference instead of by value and
don't return anything instead returning the modified builder. This is
required because bindings don't support move semantics nor impl blocks
specific to a certain type parameterization. Because of this, the
builder's contents must be cloned when building a Bolt12Invoice.

Keeps InvoiceBuilder defined so that it can be used internally in
ChannelManager's OffersMessageHandler even when compiled for c_bindings.
2024-03-08 10:39:22 -06:00
Jeffrey Czyz
07d628e0fa
Macro-ize InvoiceBuilder
InvoiceBuilder is not exported to bindings because it has methods that
take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.
2024-03-06 09:25:27 -06:00
Jeffrey Czyz
3a92c7b08a
Merge similar InvoiceBuilder impl blocks
This avoids needing to create additional macros when adding c_bindings
support.
2024-03-06 09:25:27 -06:00
Jeffrey Czyz
af318b6efb
Add c_bindings version of InvoiceRequestBuilder
Use the macros introduced in the previous commit to define two builders
for each type parameterization of InvoiceRequestBuilder
- InvoiceRequestWithExplicitPayerIdBuilder
- InvoiceRequestWithDerivedPayerIdBuilder

The difference between these and InvoiceRequestBuilder is that these
have methods that take `self` by mutable reference instead of by value
and don't return anything instead returning the modified builder. This
is required because bindings don't support move semantics nor impl
blocks specific to a certain type parameterization. Because of this, the
builder's contents must be cloned when building an InvoiceRequest.

Keeps InvoiceRequestBuilder defined so that it can be used internally in
ChannelManager::pay_for_offer even when compiled for c_bindings.
2024-03-06 09:25:27 -06:00
Jeffrey Czyz
c7b877efdd
Macro-ize InvoiceRequestBuilder
InvoiceRequestBuilder is not exported to bindings because it has methods
that take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.
2024-03-06 09:25:26 -06:00
Jeffrey Czyz
702a003270
Merge similar InvoiceRequestBuilder impl blocks
This avoids needing to create additional macros when adding c_bindings
support.
2024-03-06 09:25:26 -06:00
Jeffrey Czyz
b1ad95158e
Add c_bindings version of RefundBuilder
Use the macros introduced in the previous commit to define a builder
called RefundMaybeWithDerivedMetadataBuilder.

The difference between this and RefundBuilder is that this has methods
that take `self` by mutable reference instead of by value and don't
return anything instead returning the modified builder. This is required
because bindings don't support move semantics. Because of this, the
builder's contents must be cloned when building a Refund.

Keeps RefundBuilder defined so that it can be used internally in
ChannelManager::create_refund_builder even when compiled for c_bindings.
2024-03-06 09:25:26 -06:00
Jeffrey Czyz
1af5c409fe
Macro-ize RefundBuilder
RefundBuilder is not exported to bindings because it has methods that
take `self` by value. Define these methods using macros such that
different builders and related methods can be defined for c_bindings.
2024-03-06 09:25:26 -06:00
Jeffrey Czyz
d9ab2fa581
Add c_bindings version of OfferBuilder
Use the macros introduced in the previous commit to define two builders
for each type parameterization of OfferBuilder
- OfferWithExplicitMetadataBuilder
- OfferWithDerivedMetadataBuilder

The difference between these and OfferBuilder is that these have methods
that take `self` by mutable reference instead of by value and don't
return anything instead returning the modified builder. This is required
because bindings don't support move semantics nor impl blocks specific
to a certain type parameterization. Because of this, the builder's
contents must be cloned when building an Offer.

Keeps OfferBuilder defined so that it can be used internally in
ChannelManager::create_offer_builder even when compiled for c_bindings.
2024-03-06 09:25:26 -06:00
Jeffrey Czyz
a517925f6c
Macro-ize OfferBuilder
OfferBuilder is not exported to bindings because it has methods that
take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.
2024-02-23 16:37:03 -06: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
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
Jeffrey Czyz
c7465bdb3e
Fix panic when peer is mid-handshake
Peer::their_node_id is set to Some during the handshake process.
However, df3ab2ee27 accesses the field
unconditionally, causing a panic. This may be triggered if a gossip
message is received mid-handshake from another peer or if the user calls
broadcast_node_announcement during this time. The latter tends to be
executed on a timer.

Ensure that Peer::their_node_id is only accessed once the handshake is
complete.
2024-01-22 15:35:47 -06:00
Matt Corallo
983ca37a97 Fix deadlock when handling bad calls to batch_funding.._generated
When handling calls to `batch_funding_transaction_generated` which
were missing outputs for one of the batch channels, we'd previously
deadlock when trying to clean up the now-closed channels. This
fixes that and adds a new test case for it.

Found by the full_stack_target fuzzer.
2024-01-22 21:22:54 +00:00
Evan Feenstra
9a665ca0b8 public scid utils 2024-01-21 11:20:52 -08:00
Matt Corallo
37017ec39f Bump crate versions to 0.0.120/invoice 0.28 2024-01-17 21:34:29 +00:00
Matt Corallo
871db638f2
Merge pull request #2818 from valentinewallace/2024-01-blinded-path-retries
Avoid retrying over previously failed blinded paths
2024-01-17 21:21:36 +00:00
valentinewallace
a1759582ad
Merge pull request #2828 from TheBlueMatt/2024-01-crypto-module
Move cryptographic algorithms and utilities to a new `crypto` mod
2024-01-17 12:53:02 -05:00
Valentine Wallace
5c87f40f6b
Test that we won't retry over previously failed blinded paths. 2024-01-17 10:55:41 -05:00
Valentine Wallace
8fcfaeb8d5
Test util: separate out code to construct a blinded path. 2024-01-17 10:55:41 -05:00
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
fbeb7ac9e1
Merge pull request #2831 from jkczyz/2024-01-fix-cltv-expiry-delta
Use consistent `cltv_expiry_delta` in `ForwardTlvs`
2024-01-17 00:47:48 +00:00
Matt Corallo
53f2e2e882
Merge pull request #2812 from valentinewallace/2023-12-blinded-forwarding
Complete route blinding support
2024-01-17 00:28:30 +00:00
Jeffrey Czyz
8053aa3df4
Use consistent cltv_expiry_delta in ForwardTlvs
When converting from CounterpartyForwardingInfo to PaymentRelay, the
cltv_expiry_delta is copied. Then, when forming a blinded payment path,
the value is mutated so that esoteric values don't reveal information
about the path. However, the value was only used in computing
PaymentConstraints and wasn't actually updated in PaymentRelay. Move the
logic for modifying the cltv_expiry_delta to the conversion code to
avoid this inconsistency.
2024-01-16 16:59:27 -06:00
Valentine Wallace
aae39b4090
Advertise route blinding feature as supported.
Now that we fully support forwarding blinded payments, we should advertise
support so nodes on the network can include us in their blinded paths.
2024-01-16 17:46:41 -05:00
Valentine Wallace
027aef2b64
Fix sender double-including shadow offset in CLTV expiry height.
The excess delta is included in the final RouteHop::cltv_expiry_delta, so by
adding it explicitly to cur_cltv we were erroneously including it twice in the
total cltv expiry.

This could've add up to an extra MAX_SHADOW_CLTV_DELTA_OFFSET (432) blocks to
the total cltv expiry.
2024-01-16 17:46:41 -05:00
Valentine Wallace
6e6bd44138
Rename test var to be more descriptive. 2024-01-16 17:46:41 -05:00
Valentine Wallace
a76bb51a3a
Complete remaining TODOs for failing blinded non-intro forwards. 2024-01-16 17:46:41 -05:00
Valentine Wallace
c37d10944e
Add failure mode info to BlindedForward struct.
See added docs.
2024-01-16 17:46:39 -05:00
Matt Corallo
4a0abd52e7 Move cryptographic algorithms and utilities to a new crypto mod
As we'd generally like the `lightning` crate to, over time, have
more modules rather than being very monolithic, we should move the
cryptographic things into their own module, which we do here.

We also take this opportunity to move stream adapters into their
own module and make clear that the ChaChaPoly `decrypt` method is
variable time.
2024-01-16 20:07:08 +00:00
Jeffrey Czyz
4532fb52f0
Fix bench build warning 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
5aeb6c5167
Reorganize #[cfg(not(c_bindings))] imports 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
ffc24c3af9
Add ASCII art diagram explaining offers_tests 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
aef46d8c82
Functional test for failing duplicate payments 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
1c51aa17f3
Functional tests for failing without payment paths 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
e40387fc85
Add Features::clear_route_blinding for testing 2024-01-16 11:12:36 -06:00
Jeffrey Czyz
0a7a90a78f
Offers functional tests for duplicated payment ids 2024-01-16 11:12:35 -06:00
Jeffrey Czyz
757315076a
Functional tests for failing without blinded paths 2024-01-16 11:12:35 -06:00
Jeffrey Czyz
533c3cc868
Functional tests for offers with blinded paths 2024-01-16 11:12:35 -06:00
Jeffrey Czyz
6c67e3e279
Functional tests for offers without blinded paths 2024-01-16 11:12:35 -06:00