[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelCounterparty.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  * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
11  * to better separate parameters.
12  */
13 public class ChannelCounterparty : CommonBase {
14         internal ChannelCounterparty(object _dummy, long ptr) : base(ptr) { }
15         ~ChannelCounterparty() {
16                 if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); }
17         }
18
19         /**
20          * The node_id of our counterparty
21          */
22         public byte[] get_node_id() {
23                 byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * The node_id of our counterparty
30          */
31         public void set_node_id(byte[] val) {
32                 bindings.ChannelCounterparty_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
33                 GC.KeepAlive(this);
34                 GC.KeepAlive(val);
35         }
36
37         /**
38          * The Features the channel counterparty provided upon last connection.
39          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
40          * many routing-relevant features are present in the init context.
41          */
42         public InitFeatures get_features() {
43                 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
44                 GC.KeepAlive(this);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
47                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
48                 return ret_hu_conv;
49         }
50
51         /**
52          * The Features the channel counterparty provided upon last connection.
53          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
54          * many routing-relevant features are present in the init context.
55          */
56         public void set_features(org.ldk.structs.InitFeatures val) {
57                 bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60                 if (this != null) { this.ptrs_to.AddLast(val); };
61         }
62
63         /**
64          * The value, in satoshis, that must always be held in the channel for our counterparty. This
65          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
66          * claiming at least this value on chain.
67          * 
68          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
69          * 
70          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
71          */
72         public long get_unspendable_punishment_reserve() {
73                 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
74                 GC.KeepAlive(this);
75                 return ret;
76         }
77
78         /**
79          * The value, in satoshis, that must always be held in the channel for our counterparty. This
80          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
81          * claiming at least this value on chain.
82          * 
83          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
84          * 
85          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
86          */
87         public void set_unspendable_punishment_reserve(long val) {
88                 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
89                 GC.KeepAlive(this);
90                 GC.KeepAlive(val);
91         }
92
93         /**
94          * Information on the fees and requirements that the counterparty requires when forwarding
95          * payments to us through this channel.
96          * 
97          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
98          */
99         public CounterpartyForwardingInfo get_forwarding_info() {
100                 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
101                 GC.KeepAlive(this);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyForwardingInfo(null, ret); }
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Information on the fees and requirements that the counterparty requires when forwarding
110          * payments to us through this channel.
111          * 
112          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
113          */
114         public void set_forwarding_info(org.ldk.structs.CounterpartyForwardingInfo val) {
115                 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr);
116                 GC.KeepAlive(this);
117                 GC.KeepAlive(val);
118                 if (this != null) { this.ptrs_to.AddLast(val); };
119         }
120
121         /**
122          * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
123          * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
124          * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
125          */
126         public Option_u64Z get_outbound_htlc_minimum_msat() {
127                 long ret = bindings.ChannelCounterparty_get_outbound_htlc_minimum_msat(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
137          * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
138          * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
139          */
140         public void set_outbound_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
141                 bindings.ChannelCounterparty_set_outbound_htlc_minimum_msat(this.ptr, val.ptr);
142                 GC.KeepAlive(this);
143                 GC.KeepAlive(val);
144                 if (this != null) { this.ptrs_to.AddLast(val); };
145         }
146
147         /**
148          * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
149          */
150         public Option_u64Z get_outbound_htlc_maximum_msat() {
151                 long ret = bindings.ChannelCounterparty_get_outbound_htlc_maximum_msat(this.ptr);
152                 GC.KeepAlive(this);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
156                 return ret_hu_conv;
157         }
158
159         /**
160          * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
161          */
162         public void set_outbound_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
163                 bindings.ChannelCounterparty_set_outbound_htlc_maximum_msat(this.ptr, val.ptr);
164                 GC.KeepAlive(this);
165                 GC.KeepAlive(val);
166                 if (this != null) { this.ptrs_to.AddLast(val); };
167         }
168
169         /**
170          * Constructs a new ChannelCounterparty given each field
171          */
172         public static ChannelCounterparty of(byte[] node_id_arg, org.ldk.structs.InitFeatures features_arg, long unspendable_punishment_reserve_arg, org.ldk.structs.CounterpartyForwardingInfo forwarding_info_arg, org.ldk.structs.Option_u64Z outbound_htlc_minimum_msat_arg, org.ldk.structs.Option_u64Z outbound_htlc_maximum_msat_arg) {
173                 long ret = bindings.ChannelCounterparty_new(InternalUtils.check_arr_len(node_id_arg, 33), features_arg == null ? 0 : features_arg.ptr, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr, outbound_htlc_minimum_msat_arg.ptr, outbound_htlc_maximum_msat_arg.ptr);
174                 GC.KeepAlive(node_id_arg);
175                 GC.KeepAlive(features_arg);
176                 GC.KeepAlive(unspendable_punishment_reserve_arg);
177                 GC.KeepAlive(forwarding_info_arg);
178                 GC.KeepAlive(outbound_htlc_minimum_msat_arg);
179                 GC.KeepAlive(outbound_htlc_maximum_msat_arg);
180                 if (ret >= 0 && ret <= 4096) { return null; }
181                 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
183                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(forwarding_info_arg); };
185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_htlc_minimum_msat_arg); };
186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_htlc_maximum_msat_arg); };
187                 return ret_hu_conv;
188         }
189
190         internal long clone_ptr() {
191                 long ret = bindings.ChannelCounterparty_clone_ptr(this.ptr);
192                 GC.KeepAlive(this);
193                 return ret;
194         }
195
196         /**
197          * Creates a copy of the ChannelCounterparty
198          */
199         public ChannelCounterparty clone() {
200                 long ret = bindings.ChannelCounterparty_clone(this.ptr);
201                 GC.KeepAlive(this);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
205                 return ret_hu_conv;
206         }
207
208         /**
209          * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
210          */
211         public byte[] write() {
212                 byte[] ret = bindings.ChannelCounterparty_write(this.ptr);
213                 GC.KeepAlive(this);
214                 return ret;
215         }
216
217         /**
218          * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
219          */
220         public static Result_ChannelCounterpartyDecodeErrorZ read(byte[] ser) {
221                 long ret = bindings.ChannelCounterparty_read(ser);
222                 GC.KeepAlive(ser);
223                 if (ret >= 0 && ret <= 4096) { return null; }
224                 Result_ChannelCounterpartyDecodeErrorZ ret_hu_conv = Result_ChannelCounterpartyDecodeErrorZ.constr_from_ptr(ret);
225                 return ret_hu_conv;
226         }
227
228 }
229 } } }