+ /**
+ * Indicates a new outbound connection has been established to a node with the given node_id.
+ * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
+ * descriptor but must disconnect the connection immediately.
+ *
+ * Returns a small number of bytes to send to the remote node (currently always 50).
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet been
+ * [`socket_disconnected()`].
+ *
+ * [`socket_disconnected()`]: PeerManager::socket_disconnected
+ */
+ public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_new_outbound_connection(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), descriptor == null ? 0 : descriptor.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(their_node_id);
+ Reference.reachabilityFence(descriptor);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates a new inbound connection has been established.
+ *
+ * May refuse the connection by returning an Err, but will never write bytes to the remote end
+ * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
+ * call socket_disconnected for the new descriptor but must disconnect the connection
+ * immediately.
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet been
+ * [`socket_disconnected()`].
+ *
+ * [`socket_disconnected()`]: PeerManager::socket_disconnected
+ */
+ public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(descriptor);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates that there is room to write data to the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before
+ * returning. Thus, be very careful with reentrancy issues! The invariants around calling
+ * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be
+ * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't
+ * sufficient!
+ *
+ * [`send_data`]: SocketDescriptor::send_data
+ * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail
+ */
+ public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(descriptor);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates that data was read from the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity.
+ * Thus, however, you should call [`process_events`] after any `read_event` to generate
+ * [`send_data`] calls to handle responses.
+ *
+ * If `Ok(true)` is returned, further read_events should not be triggered until a
+ * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the
+ * send buffer).
+ *
+ * [`send_data`]: SocketDescriptor::send_data
+ * [`process_events`]: PeerManager::process_events
+ */
+ public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) {
+ long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(peer_descriptor);
+ Reference.reachabilityFence(data);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Checks for any events generated by our handlers and processes them. Includes sending most
+ * response messages as well as messages generated by calls to handler functions directly (eg
+ * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]).
+ *
+ * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy
+ * issues!
+ *
+ * You don't have to call this function explicitly if you are using [`lightning-net-tokio`]
+ * or one of the other clients provided in our language bindings.
+ *
+ * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
+ * [`send_data`]: SocketDescriptor::send_data
+ */