[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / OnionMessenger.cs
index 457b960870a4dc7d5334b6edc184f359eecac841..5ad8a929c735416ac93bd6a87a6d3bd3ab33fb5e 100644 (file)
@@ -7,9 +7,21 @@ namespace org { namespace ldk { namespace structs {
 
 
 /**
- * A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be
- * used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending
- * and receiving custom onion messages is supported.
+ * A sender, receiver and forwarder of [`OnionMessage`]s.
+ * 
+ * # Handling Messages
+ * 
+ * `OnionMessenger` implements [`OnionMessageHandler`], making it responsible for either forwarding
+ * messages to peers or delegating to the appropriate handler for the message type. Currently, the
+ * available handlers are:
+ * [`OffersMessageHandler`], for responding to [`InvoiceRequest`]s and paying [`Bolt12Invoice`]s
+ * [`CustomOnionMessageHandler`], for handling user-defined message types
+ * 
+ * # Sending Messages
+ * 
+ * [`OnionMessage`]s are sent initially using [`OnionMessenger::send_onion_message`]. When handling
+ * a message, the matched handler may return a response message which `OnionMessenger` will send
+ * on its behalf.
  * 
  * # Example
  * 
@@ -21,7 +33,7 @@ namespace org { namespace ldk { namespace structs {
  * # use lightning::sign::KeysManager;
  * # use lightning::ln::peer_handler::IgnoringMessageHandler;
  * # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessenger, OnionMessagePath};
- * # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents};
+ * # use lightning::onion_message::packet::OnionMessageContents;
  * # use lightning::util::logger::{Logger, Record};
  * # use lightning::util::ser::{Writeable, Writer};
  * # use lightning::io;
@@ -63,7 +75,7 @@ namespace org { namespace ldk { namespace structs {
  * \t\t// Write your custom onion message to `w`
  * \t}
  * }
- * impl CustomOnionMessageContents for YourCustomMessage {
+ * impl OnionMessageContents for YourCustomMessage {
  * \tfn tlv_type(&self) -> u64 {
  * \t\t# let your_custom_message_type = 42;
  * \t\tyour_custom_message_type
@@ -75,8 +87,7 @@ namespace org { namespace ldk { namespace structs {
  * \tdestination: Destination::Node(destination_node_id),
  * };
  * let reply_path = None;
- * # let your_custom_message = YourCustomMessage {};
- * let message = OnionMessageContents::Custom(your_custom_message);
+ * # let message = YourCustomMessage {};
  * onion_messenger.send_onion_message(path, message, reply_path);
  * 
  * Create a blinded path to yourself, for someone to send an onion message to.
@@ -90,13 +101,12 @@ namespace org { namespace ldk { namespace structs {
  * \tdestination: Destination::BlindedPath(blinded_path),
  * };
  * let reply_path = None;
- * # let your_custom_message = YourCustomMessage {};
- * let message = OnionMessageContents::Custom(your_custom_message);
+ * # let message = YourCustomMessage {};
  * onion_messenger.send_onion_message(path, message, reply_path);
  * ```
  * 
- * [offers]: <https://github.com/lightning/bolts/pull/798>
- * [`OnionMessenger`]: crate::onion_message::OnionMessenger
+ * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
  */
 public class OnionMessenger : CommonBase {
        internal OnionMessenger(object _dummy, long ptr) : base(ptr) { }
@@ -129,22 +139,23 @@ public class OnionMessenger : CommonBase {
        }
 
        /**
-        * Send an onion message with contents `message` to the destination of `path`.
+        * Sends an [`OnionMessage`] with the given `contents` for sending to the destination of
+        * `path`.
         * 
         * See [`OnionMessenger`] for example usage.
         * 
         * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result_NoneSendErrorZ send_onion_message(org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents message, org.ldk.structs.BlindedPath reply_path) {
-               long ret = bindings.OnionMessenger_send_onion_message(this.ptr, path == null ? 0 : path.ptr, message.ptr, reply_path == null ? 0 : reply_path.ptr);
+       public Result_NoneSendErrorZ send_onion_message(org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, org.ldk.structs.BlindedPath reply_path) {
+               long ret = bindings.OnionMessenger_send_onion_message(this.ptr, path == null ? 0 : path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(path);
-               GC.KeepAlive(message);
+               GC.KeepAlive(contents);
                GC.KeepAlive(reply_path);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneSendErrorZ ret_hu_conv = Result_NoneSendErrorZ.constr_from_ptr(ret);
                if (this != null) { this.ptrs_to.AddLast(path); };
-               if (this != null) { this.ptrs_to.AddLast(message); };
+               if (this != null) { this.ptrs_to.AddLast(contents); };
                if (this != null) { this.ptrs_to.AddLast(reply_path); };
                return ret_hu_conv;
        }
@@ -162,18 +173,5 @@ public class OnionMessenger : CommonBase {
                return ret_hu_conv;
        }
 
-       /**
-        * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg.
-        * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is
-        */
-       public OnionMessageProvider as_OnionMessageProvider() {
-               long ret = bindings.OnionMessenger_as_OnionMessageProvider(this.ptr);
-               GC.KeepAlive(this);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               OnionMessageProvider ret_hu_conv = new OnionMessageProvider(null, ret);
-               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
-               return ret_hu_conv;
-       }
-
 }
 } } }