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