6 namespace org { namespace ldk { namespace structs {
10 * Details of a connected peer as returned by [`PeerManager::list_peers`].
12 public class PeerDetails : CommonBase {
13 internal PeerDetails(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.PeerDetails_free(ptr); }
19 * The node id of the peer.
21 * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter
22 * passed in to [`PeerManager::new_outbound_connection`].
24 public byte[] get_counterparty_node_id() {
25 long ret = bindings.PeerDetails_get_counterparty_node_id(this.ptr);
27 if (ret >= 0 && ret <= 4096) { return null; }
28 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
33 * The node id of the peer.
35 * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter
36 * passed in to [`PeerManager::new_outbound_connection`].
38 public void set_counterparty_node_id(byte[] val) {
39 bindings.PeerDetails_set_counterparty_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
45 * The socket address the peer provided in the initial handshake.
47 * Will only be `Some` if an address had been previously provided to
48 * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`].
50 * Returns a copy of the field.
52 public Option_SocketAddressZ get_socket_address() {
53 long ret = bindings.PeerDetails_get_socket_address(this.ptr);
55 if (ret >= 0 && ret <= 4096) { return null; }
56 org.ldk.structs.Option_SocketAddressZ ret_hu_conv = org.ldk.structs.Option_SocketAddressZ.constr_from_ptr(ret);
57 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
62 * The socket address the peer provided in the initial handshake.
64 * Will only be `Some` if an address had been previously provided to
65 * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`].
67 public void set_socket_address(org.ldk.structs.Option_SocketAddressZ val) {
68 bindings.PeerDetails_set_socket_address(this.ptr, val.ptr);
71 if (this != null) { this.ptrs_to.AddLast(val); };
75 * The features the peer provided in the initial handshake.
77 public InitFeatures get_init_features() {
78 long ret = bindings.PeerDetails_get_init_features(this.ptr);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87 * The features the peer provided in the initial handshake.
89 public void set_init_features(org.ldk.structs.InitFeatures val) {
90 bindings.PeerDetails_set_init_features(this.ptr, val.ptr);
93 if (this != null) { this.ptrs_to.AddLast(val); };
97 * Indicates the direction of the peer connection.
99 * Will be `true` for inbound connections, and `false` for outbound connections.
101 public bool get_is_inbound_connection() {
102 bool ret = bindings.PeerDetails_get_is_inbound_connection(this.ptr);
108 * Indicates the direction of the peer connection.
110 * Will be `true` for inbound connections, and `false` for outbound connections.
112 public void set_is_inbound_connection(bool val) {
113 bindings.PeerDetails_set_is_inbound_connection(this.ptr, val);
119 * Constructs a new PeerDetails given each field
121 public static PeerDetails of(byte[] counterparty_node_id_arg, org.ldk.structs.Option_SocketAddressZ socket_address_arg, org.ldk.structs.InitFeatures init_features_arg, bool is_inbound_connection_arg) {
122 long ret = bindings.PeerDetails_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id_arg, 33)), socket_address_arg.ptr, init_features_arg.ptr, is_inbound_connection_arg);
123 GC.KeepAlive(counterparty_node_id_arg);
124 GC.KeepAlive(socket_address_arg);
125 GC.KeepAlive(init_features_arg);
126 GC.KeepAlive(is_inbound_connection_arg);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.PeerDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PeerDetails(null, ret); }
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(socket_address_arg); };
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(init_features_arg); };