[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / CustomMessageHandler.cs
index 7a774c6859d770491278b0501b6bf36485cfc475..32d39c27929b0de9114cc53b23a482e6b6d831b9 100644 (file)
@@ -6,7 +6,14 @@ using System;
 namespace org { namespace ldk { namespace structs {
 
 /**
- * Handler for BOLT1-compliant messages.
+ * A handler provided to [`PeerManager`] for reading and handling custom messages.
+ * 
+ * [BOLT 1] specifies a custom message type range for use with experimental or application-specific
+ * messages. `CustomMessageHandler` allows for user-defined handling of such types. See the
+ * [`lightning_custom_message`] crate for tools useful in composing more than one custom handler.
+ * 
+ * [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
+ * [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message
  */
 public class CustomMessageHandler : CommonBase {
        internal readonly bindings.LDKCustomMessageHandler bindings_instance;
@@ -22,17 +29,33 @@ public class CustomMessageHandler : CommonBase {
 
        public interface CustomMessageHandlerInterface {
                /**
-                * Called with the message type that was received and the buffer to be read.
-                * Can return a `MessageHandlingError` if the message could not be handled.
+                * Handles the given message sent from `sender_node_id`, possibly producing messages for
+                * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`]
+                * to send.
                 */
                Result_NoneLightningErrorZ handle_custom_message(Type _msg, byte[] _sender_node_id);
                /**
-                * Gets the list of pending messages which were generated by the custom message
-                * handler, clearing the list in the process. The first tuple element must
-                * correspond to the intended recipients node ids. If no connection to one of the
-                * specified node does not exist, the message is simply not sent to it.
+                * Returns the list of pending messages that were generated by the handler, clearing the list
+                * in the process. Each message is paired with the node id of the intended recipient. If no
+                * connection to the node exists, then the message is simply not sent.
                 */
                TwoTuple_PublicKeyTypeZ[] get_and_clear_pending_msg();
+               /**
+                * Gets the node feature flags which this handler itself supports. All available handlers are
+                * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+                * which are broadcasted in our [`NodeAnnouncement`] message.
+                * 
+                * [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement
+                */
+               NodeFeatures provided_node_features();
+               /**
+                * Gets the init feature flags which should be sent to the given peer. All available handlers
+                * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+                * which are sent in our [`Init`] message.
+                * 
+                * [`Init`]: crate::ln::msgs::Init
+                */
+               InitFeatures provided_init_features(byte[] _their_node_id);
        }
        private class LDKCustomMessageHandlerHolder { internal CustomMessageHandler held; }
        private class LDKCustomMessageHandlerImpl : bindings.LDKCustomMessageHandler {
@@ -53,6 +76,18 @@ public class CustomMessageHandler : CommonBase {
                        long[] result = ret != null ? InternalUtils.mapArray(ret, ret_conv_25 => ret_conv_25 == null ? 0 : ret_conv_25.clone_ptr()) : null;
                        return result;
                }
+               public long provided_node_features() {
+                       NodeFeatures ret = arg.provided_node_features();
+                               GC.KeepAlive(arg);
+                       long result = ret == null ? 0 : ret.clone_ptr();
+                       return result;
+               }
+               public long provided_init_features(byte[] _their_node_id) {
+                       InitFeatures ret = arg.provided_init_features(_their_node_id);
+                               GC.KeepAlive(arg);
+                       long result = ret == null ? 0 : ret.clone_ptr();
+                       return result;
+               }
        }
        public static CustomMessageHandler new_impl(CustomMessageHandlerInterface arg, CustomMessageReader.CustomMessageReaderInterface CustomMessageReader_impl) {
                LDKCustomMessageHandlerHolder impl_holder = new LDKCustomMessageHandlerHolder();
@@ -70,11 +105,12 @@ public class CustomMessageHandler : CommonBase {
        }
 
        /**
-        * Called with the message type that was received and the buffer to be read.
-        * Can return a `MessageHandlingError` if the message could not be handled.
+        * Handles the given message sent from `sender_node_id`, possibly producing messages for
+        * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`]
+        * to send.
         */
        public Result_NoneLightningErrorZ handle_custom_message(org.ldk.structs.Type msg, byte[] sender_node_id) {
-               long ret = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg == null ? 0 : msg.ptr, InternalUtils.check_arr_len(sender_node_id, 33));
+               long ret = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg.ptr, InternalUtils.check_arr_len(sender_node_id, 33));
                GC.KeepAlive(this);
                GC.KeepAlive(msg);
                GC.KeepAlive(sender_node_id);
@@ -85,10 +121,9 @@ public class CustomMessageHandler : CommonBase {
        }
 
        /**
-        * Gets the list of pending messages which were generated by the custom message
-        * handler, clearing the list in the process. The first tuple element must
-        * correspond to the intended recipients node ids. If no connection to one of the
-        * specified node does not exist, the message is simply not sent to it.
+        * Returns the list of pending messages that were generated by the handler, clearing the list
+        * in the process. Each message is paired with the node id of the intended recipient. If no
+        * connection to the node exists, then the message is simply not sent.
         */
        public TwoTuple_PublicKeyTypeZ[] get_and_clear_pending_msg() {
                long[] ret = bindings.CustomMessageHandler_get_and_clear_pending_msg(this.ptr);
@@ -104,5 +139,38 @@ public class CustomMessageHandler : CommonBase {
                return ret_conv_25_arr;
        }
 
+       /**
+        * Gets the node feature flags which this handler itself supports. All available handlers are
+        * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+        * which are broadcasted in our [`NodeAnnouncement`] message.
+        * 
+        * [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement
+        */
+       public NodeFeatures provided_node_features() {
+               long ret = bindings.CustomMessageHandler_provided_node_features(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Gets the init feature flags which should be sent to the given peer. All available handlers
+        * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+        * which are sent in our [`Init`] message.
+        * 
+        * [`Init`]: crate::ln::msgs::Init
+        */
+       public InitFeatures provided_init_features(byte[] their_node_id) {
+               long ret = bindings.CustomMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
+               GC.KeepAlive(this);
+               GC.KeepAlive(their_node_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
 }
 } } }