Commit graph

6843 commits

Author SHA1 Message Date
valentinewallace
670b41ae4e
Merge pull request #2903 from jkczyz/2024-02-bindings-builders
Offers builders for C-bindings
2024-03-08 16:07:10 -05:00
Matt Corallo
07059ec2c3
Merge pull request #2926 from tnull/2024-03-derive-eq-for-offer-refund
Impl `PartialEq`/`Eq` for `Offer`/`Refund`
2024-03-08 17:34:37 +00:00
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
Elias Rohrer
47954e95df
Implement Hash for Offer and Refund 2024-03-08 17:35:20 +01:00
Elias Rohrer
3eeb8b82a5
Impl PartialEq/Eq for Offer/Refund
We add custom implementations based on comparing the `bytes` for
`Offer`/`Refund` themselves as this is sufficient and should be faster
than comapring all fields in the worst case.
2024-03-08 17:35:20 +01:00
Matt Corallo
aa3dbe8686
Merge pull request #2923 from tnull/2024-03-improve-best-block
Refactor `BestBlock` to expose inner fields
2024-03-07 17:55:59 +00:00
Elias Rohrer
edb22e1ab9
Implement Hash for BestBlock 2024-03-07 17:35:38 +01:00
Elias Rohrer
9bac73b4f3
Merge pull request #2912 from jkczyz/2024-02-prefer-more-connections
Order blinded paths by reliability criteria
2024-03-07 12:06:42 +01:00
Elias Rohrer
007a5dba95
Implement Debug for BestBlock 2024-03-07 11:02:23 +01:00
Elias Rohrer
57911dcd41
Refactor BestBlock to expose inner fields rather than accessors
.. which is more idiomatic Rust, and easier to handle in (downstream)
bindings.
2024-03-07 11:02:23 +01: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
Matt Corallo
7a35bf84f0
Merge pull request #2919 from tnull/2024-03-fix-hashtables-rustfmt
`rustfmt`: Fix CI by running `rustfmt` on `util/hash_tables.rs`
2024-03-04 16:30:29 +00:00
Elias Rohrer
c8880099ac
Run rustfmt on util/hash_tables.rs
.. to fix the silent rebase conflict.
2024-03-04 16:03:41 +01:00
Matt Corallo
3c9d88af26
Merge pull request #2918 from tnull/2024-03-prefer-from-over-into 2024-03-01 21:01:32 +00:00
Elias Rohrer
fe50a507ab
Prefer implementing From over Into
.. as the std library docs state that implementing Into should be avoided:
"One should avoid implementing Into and implement From instead.
Implementing From automatically provides one with an implementation of
Into thanks to the blanket implementation in the standard library."
2024-03-01 11:42:54 +01:00
Matt Corallo
bf3bc420c7
Merge pull request #2916 from sr-gi/2024-02-29-payment-preimage-hash
util: Adds Into<PaymentHash> for PaymentPreimage
2024-02-29 21:48:40 +00:00
Sergi Delgado Segura
d2ffcbc233 util: Adds Into<PaymentHash> for PaymentPreimage
This seems like a useful interface to have for downstream users
2024-02-29 15:41:20 -05:00
Elias Rohrer
cfb4391850
Merge pull request #2915 from TheBlueMatt/2024-02-better-rnf-docs
Update docs on `PaymentFailureReason::RouteNotFound` to add context
2024-02-29 15:58:56 +01:00
Matt Corallo
a6478838e8 Update docs on PaymentFailureReason::RouteNotFound to add context
tnull noted on discord that its somewhat unclear to users what
`RouteNotFound` actually means - that we ran out of routes, rather
than could not find a route at all - so the docs are updated here.
2024-02-29 14:51:21 +00:00
Elias Rohrer
337b8de76e
Merge pull request #2913 from arik-so/2024/02/serialize-socket-address-vectors
Serialize SocketAddress vectors
2024-02-29 09:29:40 +01:00
Arik Sosman
d97e36e3f3
Serialize SocketAddress vectors. 2024-02-28 23:21:53 -08:00
Jeffrey Czyz
e10583365b
Prefer one-hop blinded path to Tor intro nodes
If a node is announced, prefer using a one-hop blinded path with it as
the introduction node to using a two-hop blinded path with a Tor-only
introduction node. The one-hop blinded path is more reliable, thus only
use Tor-only nodes if the recipient is unannounced. And then, prefer
non-Tor-only nodes.
2024-02-28 15:58:14 -06:00
Jeffrey Czyz
5e9a998194
Prefer well-connected nodes for introduction nodes
When forming blinded paths, using a reliable node as the introduction
node is important to ensure onion message reliability. Order blinded
paths by how well-connected the introduction node is as a proxy for
reliability.

For short paths (e.g., when the sender and recipient share an LSP), this
may also result in a scenario where initiating a direct connection isn't
necessary. That is helpful when using RGS since it currently doesn't
include node announcements and thus cannot initiate a direct connection.
2024-02-28 11:23:56 -06:00
Elias Rohrer
7ab438ddcc
Merge pull request #2911 from jkczyz/2024-02-sort-blinded-paths
Prefer non-Tor nodes when creating blinded paths
2024-02-28 12:01:55 +01:00
Jeffrey Czyz
b9547480ea
Prefer non-Tor nodes when creating blinded paths
Tor nodes can have high latency which can have a detrimental effect on
onion message reliability. Prefer using nodes that aren't Tor-only when
creating blinded paths both in offers and in onion message reply paths.
2024-02-27 18:50:58 -06:00
Jeffrey Czyz
093ceffd24
Add NodeInfo::is_tor_only
Add a method to NodeInfo to determine if the node has only announced Tor
addresses. Useful for preferring blinded paths that don't use Tor for
better reliability and improved latency.
2024-02-27 16:14:44 -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
36e434d8ce
Merge pull request #2909 from benthecarman/inv-pk-helper
Add helper function to properly get invoice pubkey
2024-02-22 19:32:02 +00:00
Matt Corallo
c4a2f1bb21
Merge pull request #2877 from tnull/2024-02-start-rustfmt-journey
`rustfmt`: Add CI scripts and format `onion_utils.rs`
2024-02-22 19:30:17 +00:00
benthecarman
53fc986378
Add helper function to properly get invoice pubkey 2024-02-22 18:05:37 +00:00
Elias Rohrer
affe55733b
Merge pull request #2908 from TheBlueMatt/2024-02-drop-useless-refs
Drop unnecessary int reference in SCID conversion utilities
2024-02-22 11:36:38 +01:00
Matt Corallo
716269e1e8
Merge pull request #2905 from tnull/2024-02-expose-init-features
Refactor `PeerManager::get_peer_node_ids` in favor of `list_peers`/`peer_by_node_id` returning additional information
2024-02-22 00:06:30 +00:00
Matt Corallo
0cd353c2bb Drop unnecessary int reference in SCID conversion utilities 2024-02-21 22:26:27 +00:00
Matt Corallo
2964751bd3
Merge pull request #2770 from dunxen/2023-12-dualfundingpreliminaries
Preliminary refactoring & structure for dual-funded channels
2024-02-21 21:09:26 +00:00
Elias Rohrer
0c74cdc573
Introduce PeerManager::list_peers and peer_by_node_id
.. returning `PeerDetails` rather than tuples of peer-associated values.

Previously, we wouldn't offer any way to retrieve the features a
peer provided in their `Init` message.

Here, we allow to retrieve them via a new `PeerDetails` struct,
side-by-side with `SocketAddress`es and a bool indicating the direction
of the peer connection.
2024-02-21 10:12:16 +01:00
Matt Corallo
a854ccb9b5
Merge pull request #2898 from tnull/2024-02-ignore-RUSTSEC-2021-0145
Have CI's `cargo audit` ignore `RUSTSEC-2021-0125`
2024-02-20 17:42:18 +00:00
Duncan Dean
efec33fc57
Add V2 ChannelPhase variants 2024-02-20 09:15:18 +02:00
Duncan Dean
e142e4a4e6
Add maybe_handle_error_without_close for OutboundV2Channel 2024-02-20 09:15:17 +02:00
Duncan Dean
909130bfed
Add OutboundV2Channel struct 2024-02-20 09:15:16 +02:00
Duncan Dean
2f43953089
Create ChannelContext constructor for outbound channels 2024-02-20 09:15:15 +02:00