[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / PeerManager.cs
index 4760b660f29a8ad21afafe68ac58fc45d6ec42bb..c2e1eeb0073b58bbaa1e6a09876fc86601a83fa7 100644 (file)
@@ -45,7 +45,7 @@ public class PeerManager : CommonBase {
         * minute should suffice.
         */
        public static PeerManager of(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, OnionMessageHandler message_handler_onion_message_handler_arg, CustomMessageHandler message_handler_custom_message_handler_arg, int current_time, byte[] ephemeral_random_data, org.ldk.structs.Logger logger, org.ldk.structs.NodeSigner node_signer) {
-               long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg.ptr, message_handler_onion_message_handler_arg.ptr, message_handler_custom_message_handler_arg.ptr), current_time, InternalUtils.check_arr_len(ephemeral_random_data, 32), logger.ptr, node_signer.ptr);
+               long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg.ptr, message_handler_onion_message_handler_arg.ptr, message_handler_custom_message_handler_arg.ptr), current_time, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(ephemeral_random_data, 32)), logger.ptr, node_signer.ptr);
                GC.KeepAlive(message_handler_chan_handler_arg);
                GC.KeepAlive(message_handler_route_handler_arg);
                GC.KeepAlive(message_handler_onion_message_handler_arg);
@@ -67,29 +67,40 @@ public class PeerManager : CommonBase {
        }
 
        /**
-        * Get a list of tuples mapping from node id to network addresses for peers which have
-        * completed the initial handshake.
+        * Returns a list of [`PeerDetails`] for connected peers that have completed the initial
+        * handshake.
+        */
+       public PeerDetails[] list_peers() {
+               long ret = bindings.PeerManager_list_peers(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               int ret_conv_13_len = InternalUtils.getArrayLength(ret);
+               PeerDetails[] ret_conv_13_arr = new PeerDetails[ret_conv_13_len];
+               for (int n = 0; n < ret_conv_13_len; n++) {
+                       long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
+                       org.ldk.structs.PeerDetails ret_conv_13_hu_conv = null; if (ret_conv_13 < 0 || ret_conv_13 > 4096) { ret_conv_13_hu_conv = new org.ldk.structs.PeerDetails(null, ret_conv_13); }
+                       if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
+                       ret_conv_13_arr[n] = ret_conv_13_hu_conv;
+               }
+               bindings.free_buffer(ret);
+               return ret_conv_13_arr;
+       }
+
+       /**
+        * Returns the [`PeerDetails`] of a connected peer that has completed the initial handshake.
         * 
-        * For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter
-        * passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial
-        * handshake has completed and we are sure the remote peer has the private key for the given
-        * [`PublicKey`].
+        * Will return `None` if the peer is unknown or it hasn't completed the initial handshake.
         * 
-        * The returned `Option`s will only be `Some` if an address had been previously given via
-        * [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`].
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public TwoTuple_PublicKeyCOption_NetAddressZZ[] get_peer_node_ids() {
-               long[] ret = bindings.PeerManager_get_peer_node_ids(this.ptr);
+       public PeerDetails peer_by_node_id(byte[] their_node_id) {
+               long ret = bindings.PeerManager_peer_by_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
                GC.KeepAlive(this);
-               int ret_conv_40_len = ret.Length;
-               TwoTuple_PublicKeyCOption_NetAddressZZ[] ret_conv_40_arr = new TwoTuple_PublicKeyCOption_NetAddressZZ[ret_conv_40_len];
-               for (int o = 0; o < ret_conv_40_len; o++) {
-                       long ret_conv_40 = ret[o];
-                       TwoTuple_PublicKeyCOption_NetAddressZZ ret_conv_40_hu_conv = new TwoTuple_PublicKeyCOption_NetAddressZZ(null, ret_conv_40);
-                       if (ret_conv_40_hu_conv != null) { ret_conv_40_hu_conv.ptrs_to.AddLast(this); };
-                       ret_conv_40_arr[o] = ret_conv_40_hu_conv;
-               }
-               return ret_conv_40_arr;
+               GC.KeepAlive(their_node_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.PeerDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PeerDetails(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
        }
 
        /**
@@ -109,8 +120,8 @@ public class PeerManager : CommonBase {
         * 
         * [`socket_disconnected`]: PeerManager::socket_disconnected
         */
-       public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, org.ldk.structs.SocketDescriptor descriptor, org.ldk.structs.Option_NetAddressZ remote_network_address) {
-               long ret = bindings.PeerManager_new_outbound_connection(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), descriptor.ptr, remote_network_address.ptr);
+       public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, org.ldk.structs.SocketDescriptor descriptor, org.ldk.structs.Option_SocketAddressZ remote_network_address) {
+               long ret = bindings.PeerManager_new_outbound_connection(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), descriptor.ptr, remote_network_address.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(their_node_id);
                GC.KeepAlive(descriptor);
@@ -139,7 +150,7 @@ public class PeerManager : CommonBase {
         * 
         * [`socket_disconnected`]: PeerManager::socket_disconnected
         */
-       public Result_NonePeerHandleErrorZ new_inbound_connection(org.ldk.structs.SocketDescriptor descriptor, org.ldk.structs.Option_NetAddressZ remote_network_address) {
+       public Result_NonePeerHandleErrorZ new_inbound_connection(org.ldk.structs.SocketDescriptor descriptor, org.ldk.structs.Option_SocketAddressZ remote_network_address) {
                long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor.ptr, remote_network_address.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(descriptor);
@@ -194,7 +205,7 @@ public class PeerManager : CommonBase {
         * [`process_events`]: PeerManager::process_events
         */
        public Result_boolPeerHandleErrorZ read_event(org.ldk.structs.SocketDescriptor peer_descriptor, byte[] data) {
-               long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor.ptr, data);
+               long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor.ptr, InternalUtils.encodeUint8Array(data));
                GC.KeepAlive(this);
                GC.KeepAlive(peer_descriptor);
                GC.KeepAlive(data);
@@ -245,7 +256,7 @@ public class PeerManager : CommonBase {
         * [`disconnect_socket`]: SocketDescriptor::disconnect_socket
         */
        public void disconnect_by_node_id(byte[] node_id) {
-               bindings.PeerManager_disconnect_by_node_id(this.ptr, InternalUtils.check_arr_len(node_id, 33));
+               bindings.PeerManager_disconnect_by_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)));
                GC.KeepAlive(this);
                GC.KeepAlive(node_id);
        }
@@ -295,13 +306,13 @@ public class PeerManager : CommonBase {
         * 
         * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
         */
-       public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) {
-               bindings.PeerManager_broadcast_node_announcement(this.ptr, InternalUtils.check_arr_len(rgb, 3), InternalUtils.check_arr_len(alias, 32), addresses != null ? InternalUtils.mapArray(addresses, addresses_conv_12 => addresses_conv_12.ptr) : null);
+       public void broadcast_node_announcement(byte[] rgb, byte[] alias, SocketAddress[] addresses) {
+               bindings.PeerManager_broadcast_node_announcement(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(rgb, 3)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(alias, 32)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(addresses, addresses_conv_15 => addresses_conv_15.ptr)));
                GC.KeepAlive(this);
                GC.KeepAlive(rgb);
                GC.KeepAlive(alias);
                GC.KeepAlive(addresses);
-               foreach (NetAddress addresses_conv_12 in addresses) { if (this != null) { this.ptrs_to.AddLast(addresses_conv_12); }; };
+               foreach (SocketAddress addresses_conv_15 in addresses) { if (this != null) { this.ptrs_to.AddLast(addresses_conv_15); }; };
        }
 
 }