Commit graph

8 commits

Author SHA1 Message Date
Jeffrey Czyz
8b442fe4eb
Enqueue onion messages in handlers
When constructing onion messages to send initially (opposed to replying
to one from a handler), the user must construct an OnionMessagePath first
before calling OnionMessener::send_onion_message. Additionally, having a
reference to OnionMessener isn't always desirable. For instance, in an
upcoming commit, ChannelManager will implement OffersMessageHandler,
which OnionMessenger needs a reference to. If ChannelManager had a
reference to OnionMessenger, too, there would be a dependency cycle.

Instead, modify OffersMessageHandler and CustomOnionMessageHandler's
interfaces to include a method for releasing pending onion messages.
That way, ChannelManager may, for instance, construct and enqueue an
InvoiceRequest for sending without needing a reference to
OnionMessenger.

Additionally, OnionMessenger has responsibility for path finding just as
it does when replying to messages from a handler. It performs this when
extracting messages from the handlers before returning the next message
to send to a peer.
2023-10-18 18:31:16 -05:00
Jeffrey Czyz
840efd5334
Generalize CustomOnionMessageContents trait
Rename CustomOnionMessageContents to OnionMessageContents and use it as
a trait bound on messages passed to OnionMessenger methods. This allows
using the trait in an upcoming commit as a bound on the contents of
PendingOnionMessage.

Also, make ParsedOnionMessageContent implement OnionMessageContents so
that Payload can be bounded by OnionMessageContents directly, but used
when either reading a ParsedOnionMessageContent or writing a specific
type of OnionMessageContents (e.g., OffersMessage).
2023-10-18 18:15:05 -05:00
Matt Corallo
5f120b1b65 Make OffersMessage and offers errors Cloneable 2023-07-20 21:43:52 +00:00
Jeffrey Czyz
5627d7cc1f
Qualify the BOLT 12 parse error
To avoid a naming conflict in bindings with BOLT 11 parse error, qualify
the BOLT 12 parse error type.
2023-07-14 15:04:43 -05:00
Jeffrey Czyz
f8c9b092fd
Qualify the BOLT 12 invoice type
To avoid a naming conflict in bindings with BOLT 11 invoices, qualify
the BOLT 12 invoice type.
2023-07-14 15:04:43 -05:00
Jeffrey Czyz
c17c2ae3c0
Support onion message replies in OnionMessenger
Modify onion message handlers to return an optional response message for
OnionMessenger to reply with.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
f521e4cceb
OffersMessageHandler trait for OnionMessenger
Add a trait for handling BOLT 12 Offers messages to OnionMessenger and a
skeleton implementation of it for ChannelManager. This allows users to
either provide their own custom handling Offers messages or rely on a
version provided by LDK using stateless verification.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
a799fc9b30
Onion message payload for BOLT 12 Offers
BOLT 12 Offers makes use of onion messages to request and respond with
invoices. Add these types and an error type to OnionMessageContents
along with the necessary parsing and encoding.
2023-06-13 13:07:47 -05:00