[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / PeerDetails.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Details of a connected peer as returned by [`PeerManager::list_peers`].
11  */
12 public class PeerDetails : CommonBase {
13         internal PeerDetails(object _dummy, long ptr) : base(ptr) { }
14         ~PeerDetails() {
15                 if (ptr != 0) { bindings.PeerDetails_free(ptr); }
16         }
17
18         /**
19          * The node id of the peer.
20          * 
21          * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter
22          * passed in to [`PeerManager::new_outbound_connection`].
23          */
24         public byte[] get_counterparty_node_id() {
25                 long ret = bindings.PeerDetails_get_counterparty_node_id(this.ptr);
26                 GC.KeepAlive(this);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
29                 return ret_conv;
30         }
31
32         /**
33          * The node id of the peer.
34          * 
35          * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter
36          * passed in to [`PeerManager::new_outbound_connection`].
37          */
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)));
40                 GC.KeepAlive(this);
41                 GC.KeepAlive(val);
42         }
43
44         /**
45          * The socket address the peer provided in the initial handshake.
46          * 
47          * Will only be `Some` if an address had been previously provided to
48          * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`].
49          * 
50          * Returns a copy of the field.
51          */
52         public Option_SocketAddressZ get_socket_address() {
53                 long ret = bindings.PeerDetails_get_socket_address(this.ptr);
54                 GC.KeepAlive(this);
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); };
58                 return ret_hu_conv;
59         }
60
61         /**
62          * The socket address the peer provided in the initial handshake.
63          * 
64          * Will only be `Some` if an address had been previously provided to
65          * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`].
66          */
67         public void set_socket_address(org.ldk.structs.Option_SocketAddressZ val) {
68                 bindings.PeerDetails_set_socket_address(this.ptr, val.ptr);
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(val);
71                 if (this != null) { this.ptrs_to.AddLast(val); };
72         }
73
74         /**
75          * The features the peer provided in the initial handshake.
76          */
77         public InitFeatures get_init_features() {
78                 long ret = bindings.PeerDetails_get_init_features(this.ptr);
79                 GC.KeepAlive(this);
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); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * The features the peer provided in the initial handshake.
88          */
89         public void set_init_features(org.ldk.structs.InitFeatures val) {
90                 bindings.PeerDetails_set_init_features(this.ptr, val.ptr);
91                 GC.KeepAlive(this);
92                 GC.KeepAlive(val);
93                 if (this != null) { this.ptrs_to.AddLast(val); };
94         }
95
96         /**
97          * Indicates the direction of the peer connection.
98          * 
99          * Will be `true` for inbound connections, and `false` for outbound connections.
100          */
101         public bool get_is_inbound_connection() {
102                 bool ret = bindings.PeerDetails_get_is_inbound_connection(this.ptr);
103                 GC.KeepAlive(this);
104                 return ret;
105         }
106
107         /**
108          * Indicates the direction of the peer connection.
109          * 
110          * Will be `true` for inbound connections, and `false` for outbound connections.
111          */
112         public void set_is_inbound_connection(bool val) {
113                 bindings.PeerDetails_set_is_inbound_connection(this.ptr, val);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(val);
116         }
117
118         /**
119          * Constructs a new PeerDetails given each field
120          */
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); };
132                 return ret_hu_conv;
133         }
134
135 }
136 } } }