Commit graph

4519 commits

Author SHA1 Message Date
Matt Corallo
cc78b77c71 Fix unknown handling in impl_writeable_tlv_based_enum_upgradable
`impl_writeable_tlv_based_enum_upgradable` professed to supporting
upgrades by returning `None` from `MaybeReadable` when unknown
variants written by newer versions of LDK were read. However, it
generally didn't support this as it didn't discard bytes for
unknown types, resulting in corrupt reading.

This is fixed here for enum variants written as a TLV stream,
however we don't have a length prefix for tuple enum variants, so
the documentation on the macro is updated to mention that
downgrades are not supported for tuple variants.
2024-04-07 19:55:56 +00:00
Elias Rohrer
b8b1ef3149
Merge pull request #2963 from jkczyz/2024-03-a-channel-manager
Use `AChannelManager` in `BackgroundProcessor`
2024-03-25 14:27:08 +01:00
Jeffrey Czyz
d29e2ba949
Use AChannelManager in BackgroundProcessor
Replace instance of ChannelManager in BackgroundProcessor and in
Persister with AChannelManager. This reduces the number of type
parameters need in those types, which would need to be repeated in an
async version of Persister.
2024-03-23 17:02:28 -05:00
Jeffrey Czyz
82a13b52cc
Remove duplicate docs from trait implementations 2024-03-23 16:56:26 -05:00
valentinewallace
6d1111111c
Merge pull request #2756 from arik-so/arik/trampoline/2023-11-outbound
Serialize Trampoline payloads in outbound onions.
2024-03-22 10:41:19 -04:00
Arik Sosman
f15c538e1f
Add Trampoline variant to OutboundOnionPayload. 2024-03-21 18:00:43 -07:00
Arik Sosman
c84d721c99
Introduce TrampolineOnionPacket. 2024-03-21 17:47:00 -07:00
Gursharan Singh
9ca22800b4
Merge pull request #2953 from dunxen/2024-03-fix2941
Fix `ChannelManager::accept_inbound_channel` error handling
2024-03-21 10:55:19 -07:00
Duncan Dean
3206d1fa59
Test ChannelManager::accept_inbound_channel errors 2024-03-21 09:25:18 +02:00
Duncan Dean
1cb6d2faf5
Fix ChannelManager::accept_inbound_channel error handling 2024-03-21 09:25:16 +02:00
Matt Corallo
5e41425179
Merge pull request #2935 from valentinewallace/2024-03-keysend-to-blinded
Support keysend to blinded paths
2024-03-20 19:20:11 +00:00
Matt Corallo
8354e0c9ba
Merge pull request #2419 from jurvis/2023-03-interactivetxs
Interactive Transaction Construction
2024-03-20 19:06:22 +00:00
Matt Corallo
9b7bbe17da
Merge pull request #2887 from benthecarman/htlc-timeout
Add HTLCsTimedOut closing reason
2024-03-20 18:13:27 +00:00
Matt Corallo
0cc08589b7
Merge pull request #2951 from jkczyz/2024-03-fix-sender-is-intro-node
Fix sender is the introduction node onion messages
2024-03-20 14:35:35 +00:00
valentinewallace
a36b529752
Merge pull request #2924 from tnull/2024-03-add-user-channel-id-to-payment-forwarded
Expose `{prev,next}_user_channel_id` fields in `PaymentForwarded`
2024-03-20 10:27:16 -04:00
Matt Corallo
e4b6a5004e
Merge pull request #2948 from arik-so/2024-03-public-node-announcement-excess
Publicize all UnsignedNodeAnnouncement fields.
2024-03-20 00:53:38 +00:00
benthecarman
9b5ebc4bec
Add HTLCsTimedOut closing reason
Before a force closure from timed out HTLCs was treated the same as when
the user manually force closed the channel. This leads to various UX
issues. This adds a new `ClosureReason` called `HTLCsTimedOut` that
signifies that the closure was caused because the HTLCs timed out. To go
along with this, previously we'd always send "Channel force-closed" when
force closing the channel in the error message which was ambigous, now
we send the force closure reason so the peer can know why the channel
was closed.
2024-03-19 18:57:15 -05:00
Jeffrey Czyz
806fef5848
Use OnionMessenger::send_onion_message in tests
Use OnionMessenger's public interface in tests whenever possible (i.e.,
when not using any intermediate_nodes in an OnionMessagePath. This
allows us to exercise DefaultMessageRouter, and, in particular that a
path can be found for an unannounced sender when its in the introduction
node.
2024-03-19 17:45:10 -05:00
Jeffrey Czyz
ad3de23666
Use DefaultMessageRouter in functional tests
This helps test cases in DefaultMessageRouter that may not be exercised
now or in the future.
2024-03-19 17:45:10 -05:00
Jeffrey Czyz
3d2a0c2832
pub(crate) visibility for routing/test_utils.rs
Give pub(crate) visibility to some routing test utilities to facilitate
testing DefaultMessageRouter in functional tests.
2024-03-19 17:45:10 -05:00
Jeffrey Czyz
f2b84e05e8
Fix sender is the introduction node onion messages
DefaultMessageRouter will form an OnionMessagePath from a BlindedPath
where the sender is the introduction node but only if the sender is
announced. If the sender is unannounced, then DefaultMessageRouter will
fail. While DefaultMessageRouter will only create a blinded path with an
announced introduction node, it may receive one where the introduction
node is unannounced. Don't return an error in this case, as the
OnionMessenger can advance the blinded path by one hop.

This may occur when two nodes have an unannounced channel and one (the
offer creator) wants to use it for payments without an intermediary node
and without putting its node id in the offer.
2024-03-19 17:40:25 -05:00
Jeffrey Czyz
dc627b371f
Include SocketAddress in test node_announcement 2024-03-19 17:08:09 -05:00
Jeffrey Czyz
22c9da3cfb
Re-order imports 2024-03-19 17:08:09 -05:00
Arik Sosman
c974225fa4
Add trampoline feature flag. 2024-03-19 13:37:31 -07:00
Valentine Wallace
caccb1cc21
Only write BlindedHopFeatures if any features are set.
Minor space-saving optimization.
2024-03-19 14:58:43 -04:00
Arik Sosman
5f2b04badf
Publicize all UnsignedNodeAnnouncement fields.
This is necessary for RGSS tests to create new announcements.
2024-03-19 08:34:05 -07:00
Elias Rohrer
ab4b872098
Remove redundant claiming_channel_id variable
.. as it's the same as `prev_channel_id` defined a few lines above.
2024-03-19 13:29:09 +01:00
Elias Rohrer
134d60a3e8
Expose {prev,next}_user_channel_id fields in PaymentForwarded
This is useful for users that track channels by `user_channel_id`.

For example, in `lightning-liquidity` we currently keep a full
`HashMap<ChanelId, u128>` around *just* to be able to associate
`PaymentForwarded` events with the channels otherwise tracked by
`user_channel_id`.
2024-03-19 13:29:09 +01:00
Valentine Wallace
18ebbf7244
Make blinded hop features optional per spec.
The spec states that if these features are missing, we MUST process the message
as if it were present and contained an empty array.
2024-03-18 17:07:27 -04:00
Matt Corallo
2c9dbb959d
Merge pull request #2936 from valentinewallace/2024-03-pay-relay-constraints-ser
Fix ser for `PaymentRelay` and `PaymentConstraints`
2024-03-18 13:37:23 +00:00
Elias Rohrer
282b52f7bd
Merge pull request #2942 from benthecarman/node-id-slice
Add NodeId::from_slice
2024-03-18 09:13:00 +00:00
benthecarman
227d73de2b
Add NodeId::from_slice 2024-03-17 15:26:27 +00:00
Matt Corallo
03425e4e4c Avoid writing ChannelManager when hitting lnd bug 6039
When we hit lnd bug 6039, we end up sending error messages to peers
in a loop. This should be fine, but because we used the generic
`PersistenceNotifierGuard::notify_on_drop` lock above the specific
handling, we end up writing `ChannelManager` every time we manage a
round-trip to our peer.

This can add up quite quickly, and isn't actually changing, so we
really need to avoid writing the `ChannelManager` in this case.
2024-03-14 20:03:48 +00:00
Valentine Wallace
ef02b9e6f9
Fix ser for PaymentRelay and PaymentConstraints.
Two fields were serialized as u32/u64 when the spec said *tu32/tu64*.
/facepalm.
2024-03-14 15:26:11 -04:00
Duncan Dean
c56198ade5
Implement interactive tx construction protocol via InteractiveTxConstructor
This implements the interactive construction protocol described at
78e5a6b066/02-peer-protocol.md (L92).

Our implementation includes a state machine with typed states and transitions
to ensure consumers have compile-time assurances that the protocol is upheld.

States are tracked as in the `StateMachine` enum and can take on all
possible states during the negotiation.

The states are further divided into two categories, namely by the two traits
they implement, either `ReceivedMsgState` or `SentMsgState`.

The defined `StateTransitions` enforce the transitions that `ReceivedMsgState`,
`SentMsgState`, and the `_TxComplete`s can go through.

Co-authored-by: Wilmer Paulino <9447167+wpaulino@users.noreply.github.com>
Co-authored-by: Duncan Dean <git@dunxen.dev>
Co-authored-by: Jurvis Tan <5944973+jurvis@users.noreply.github.com>
2024-03-14 16:10:46 +02:00
Valentine Wallace
664abf20d0
Support receiving keysend payments to blinded paths. 2024-03-13 15:48:04 -04:00
Valentine Wallace
154aa211e6
Parse keysend preimages in blinded onion payloads. 2024-03-13 15:47:58 -04:00
Valentine Wallace
658e2c0a48
Support sending keysend payments to blinded paths. 2024-03-13 15:47:52 -04:00
Matt Corallo
29984a78ac Use structured logging where appropriate in OnionMessenger 2024-03-13 14:18:44 +00:00
Matt Corallo
b29033659f Add PersistenceNotifierGuard take to offer/refund payments
This resolves an issue where offer and refund payments get delayed
while we wait for the `invoice_request`/`invoice` onion messages to
get sent. It further ensures we're likely to have the
`ChannelManager` persisted with the new payment info after
initiating the send/receive.
2024-03-13 14:18:44 +00:00
Matt Corallo
98340dc253 Use {}, not {:?} for PublicKey logging
The `Debug` serialization of `PublicKey`s includes both the X and Y
coordinate, which isn't something most of our users deal with.
Instead, logging using `Display` gives users the keys they're used
to.
2024-03-13 13:58:47 +00:00
Matt Corallo
aa334d5753
Merge pull request #2917 from jkczyz/2024-02-refund-unsupported-chain
Fail `request_refund_payment` for unsupported chain
2024-03-12 15:18:32 +00:00
Jeffrey Czyz
228e72ca34
Fail request_refund_payment for unsupported chain
If a Refund has an unsupported chain, ChannelManager should not send an
invoice as it can't be paid on that chain. Instead, return an error when
calling ChannelManager::request_refund_payment for such refunds.
2024-03-08 15:57:10 -06:00
Jeffrey Czyz
ad91fcd510
Update pay_for_offer docs about unsupported chains 2024-03-08 15:40:29 -06:00
Jeffrey Czyz
07d766a5e9
Test failing pay_for_offer on an unsupported chain 2024-03-08 15:40:16 -06:00
Matt Corallo
6d5c952556
Merge pull request #2823 from valentinewallace/2024-01-blinded-forwarding-tests
Test blinded forwarding
2024-03-08 21:32:40 +00:00
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
Valentine Wallace
2027bf4e2a
Test that we'll round up blinded intermediate node fees if needed.
See comment in the new test.
2024-03-08 12:03:17 -05:00
Valentine Wallace
7777fc5285
Test utils: support intermediate nodes taking 1msat extra fee.
See docs on the new field.
2024-03-08 12:03:17 -05:00
Valentine Wallace
c30332ac86
Support fee overpayment by 1 msat in expect_payment_forwarded test util.
See ClaimAlongRouteArgs::allow_1_msat_fee_overpay.
2024-03-08 12:03:17 -05:00