[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ClosureReason.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * The reason the channel was closed. See individual variants for more details.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ClosureReason extends CommonBase {
16         private ClosureReason(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ClosureReason_free(ptr); }
21         }
22         static ClosureReason constr_from_ptr(long ptr) {
23                 bindings.LDKClosureReason raw_val = bindings.LDKClosureReason_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKClosureReason.CounterpartyForceClosed.class) {
25                         return new CounterpartyForceClosed(ptr, (bindings.LDKClosureReason.CounterpartyForceClosed)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKClosureReason.HolderForceClosed.class) {
28                         return new HolderForceClosed(ptr, (bindings.LDKClosureReason.HolderForceClosed)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKClosureReason.CooperativeClosure.class) {
31                         return new CooperativeClosure(ptr, (bindings.LDKClosureReason.CooperativeClosure)raw_val);
32                 }
33                 if (raw_val.getClass() == bindings.LDKClosureReason.CommitmentTxConfirmed.class) {
34                         return new CommitmentTxConfirmed(ptr, (bindings.LDKClosureReason.CommitmentTxConfirmed)raw_val);
35                 }
36                 if (raw_val.getClass() == bindings.LDKClosureReason.FundingTimedOut.class) {
37                         return new FundingTimedOut(ptr, (bindings.LDKClosureReason.FundingTimedOut)raw_val);
38                 }
39                 if (raw_val.getClass() == bindings.LDKClosureReason.ProcessingError.class) {
40                         return new ProcessingError(ptr, (bindings.LDKClosureReason.ProcessingError)raw_val);
41                 }
42                 if (raw_val.getClass() == bindings.LDKClosureReason.DisconnectedPeer.class) {
43                         return new DisconnectedPeer(ptr, (bindings.LDKClosureReason.DisconnectedPeer)raw_val);
44                 }
45                 if (raw_val.getClass() == bindings.LDKClosureReason.OutdatedChannelManager.class) {
46                         return new OutdatedChannelManager(ptr, (bindings.LDKClosureReason.OutdatedChannelManager)raw_val);
47                 }
48                 if (raw_val.getClass() == bindings.LDKClosureReason.CounterpartyCoopClosedUnfundedChannel.class) {
49                         return new CounterpartyCoopClosedUnfundedChannel(ptr, (bindings.LDKClosureReason.CounterpartyCoopClosedUnfundedChannel)raw_val);
50                 }
51                 if (raw_val.getClass() == bindings.LDKClosureReason.FundingBatchClosure.class) {
52                         return new FundingBatchClosure(ptr, (bindings.LDKClosureReason.FundingBatchClosure)raw_val);
53                 }
54                 assert false; return null; // Unreachable without extending the (internal) bindings interface
55         }
56
57         /**
58          * Closure generated from receiving a peer error message.
59          * 
60          * Our counterparty may have broadcasted their latest commitment state, and we have
61          * as well.
62          */
63         public final static class CounterpartyForceClosed extends ClosureReason {
64                 /**
65                  * The error which the peer sent us.
66                  * 
67                  * Be careful about printing the peer_msg, a well-crafted message could exploit
68                  * a security vulnerability in the terminal emulator or the logging subsystem.
69                  * To be safe, use `Display` on `UntrustedString`
70                  * 
71                  * [`UntrustedString`]: crate::util::string::UntrustedString
72                 */
73                 public final org.ldk.structs.UntrustedString peer_msg;
74                 private CounterpartyForceClosed(long ptr, bindings.LDKClosureReason.CounterpartyForceClosed obj) {
75                         super(null, ptr);
76                         long peer_msg = obj.peer_msg;
77                         org.ldk.structs.UntrustedString peer_msg_hu_conv = null; if (peer_msg < 0 || peer_msg > 4096) { peer_msg_hu_conv = new org.ldk.structs.UntrustedString(null, peer_msg); }
78                         if (peer_msg_hu_conv != null) { peer_msg_hu_conv.ptrs_to.add(this); };
79                         this.peer_msg = peer_msg_hu_conv;
80                 }
81         }
82         /**
83          * Closure generated from [`ChannelManager::force_close_channel`], called by the user.
84          * 
85          * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
86          */
87         public final static class HolderForceClosed extends ClosureReason {
88                 private HolderForceClosed(long ptr, bindings.LDKClosureReason.HolderForceClosed obj) {
89                         super(null, ptr);
90                 }
91         }
92         /**
93          * The channel was closed after negotiating a cooperative close and we've now broadcasted
94          * the cooperative close transaction. Note the shutdown may have been initiated by us.
95          */
96         public final static class CooperativeClosure extends ClosureReason {
97                 private CooperativeClosure(long ptr, bindings.LDKClosureReason.CooperativeClosure obj) {
98                         super(null, ptr);
99                 }
100         }
101         /**
102          * A commitment transaction was confirmed on chain, closing the channel. Most likely this
103          * commitment transaction came from our counterparty, but it may also have come from
104          * a copy of our own `ChannelMonitor`.
105          */
106         public final static class CommitmentTxConfirmed extends ClosureReason {
107                 private CommitmentTxConfirmed(long ptr, bindings.LDKClosureReason.CommitmentTxConfirmed obj) {
108                         super(null, ptr);
109                 }
110         }
111         /**
112          * The funding transaction failed to confirm in a timely manner on an inbound channel.
113          */
114         public final static class FundingTimedOut extends ClosureReason {
115                 private FundingTimedOut(long ptr, bindings.LDKClosureReason.FundingTimedOut obj) {
116                         super(null, ptr);
117                 }
118         }
119         /**
120          * Closure generated from processing an event, likely a HTLC forward/relay/reception.
121          */
122         public final static class ProcessingError extends ClosureReason {
123                 /**
124                  * A developer-readable error message which we generated.
125                 */
126                 public final java.lang.String err;
127                 private ProcessingError(long ptr, bindings.LDKClosureReason.ProcessingError obj) {
128                         super(null, ptr);
129                         this.err = obj.err;
130                 }
131         }
132         /**
133          * The peer disconnected prior to funding completing. In this case the spec mandates that we
134          * forget the channel entirely - we can attempt again if the peer reconnects.
135          * 
136          * This includes cases where we restarted prior to funding completion, including prior to the
137          * initial [`ChannelMonitor`] persistence completing.
138          * 
139          * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
140          * peer because of mutual incompatibility between us and our channel counterparty.
141          * 
142          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
143          */
144         public final static class DisconnectedPeer extends ClosureReason {
145                 private DisconnectedPeer(long ptr, bindings.LDKClosureReason.DisconnectedPeer obj) {
146                         super(null, ptr);
147                 }
148         }
149         /**
150          * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than
151          * the [`ChannelManager`] deserialized.
152          * 
153          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
154          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
155          */
156         public final static class OutdatedChannelManager extends ClosureReason {
157                 private OutdatedChannelManager(long ptr, bindings.LDKClosureReason.OutdatedChannelManager obj) {
158                         super(null, ptr);
159                 }
160         }
161         /**
162          * The counterparty requested a cooperative close of a channel that had not been funded yet.
163          * The channel has been immediately closed.
164          */
165         public final static class CounterpartyCoopClosedUnfundedChannel extends ClosureReason {
166                 private CounterpartyCoopClosedUnfundedChannel(long ptr, bindings.LDKClosureReason.CounterpartyCoopClosedUnfundedChannel obj) {
167                         super(null, ptr);
168                 }
169         }
170         /**
171          * Another channel in the same funding batch closed before the funding transaction
172          * was ready to be broadcast.
173          */
174         public final static class FundingBatchClosure extends ClosureReason {
175                 private FundingBatchClosure(long ptr, bindings.LDKClosureReason.FundingBatchClosure obj) {
176                         super(null, ptr);
177                 }
178         }
179         long clone_ptr() {
180                 long ret = bindings.ClosureReason_clone_ptr(this.ptr);
181                 Reference.reachabilityFence(this);
182                 return ret;
183         }
184
185         /**
186          * Creates a copy of the ClosureReason
187          */
188         public ClosureReason clone() {
189                 long ret = bindings.ClosureReason_clone(this.ptr);
190                 Reference.reachabilityFence(this);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
193                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
194                 return ret_hu_conv;
195         }
196
197         /**
198          * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
199          */
200         public static ClosureReason counterparty_force_closed(org.ldk.structs.UntrustedString peer_msg) {
201                 long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg == null ? 0 : peer_msg.ptr);
202                 Reference.reachabilityFence(peer_msg);
203                 if (ret >= 0 && ret <= 4096) { return null; }
204                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
206                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(peer_msg); };
207                 return ret_hu_conv;
208         }
209
210         /**
211          * Utility method to constructs a new HolderForceClosed-variant ClosureReason
212          */
213         public static ClosureReason holder_force_closed() {
214                 long ret = bindings.ClosureReason_holder_force_closed();
215                 if (ret >= 0 && ret <= 4096) { return null; }
216                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
217                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
218                 return ret_hu_conv;
219         }
220
221         /**
222          * Utility method to constructs a new CooperativeClosure-variant ClosureReason
223          */
224         public static ClosureReason cooperative_closure() {
225                 long ret = bindings.ClosureReason_cooperative_closure();
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
228                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
229                 return ret_hu_conv;
230         }
231
232         /**
233          * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
234          */
235         public static ClosureReason commitment_tx_confirmed() {
236                 long ret = bindings.ClosureReason_commitment_tx_confirmed();
237                 if (ret >= 0 && ret <= 4096) { return null; }
238                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
239                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
240                 return ret_hu_conv;
241         }
242
243         /**
244          * Utility method to constructs a new FundingTimedOut-variant ClosureReason
245          */
246         public static ClosureReason funding_timed_out() {
247                 long ret = bindings.ClosureReason_funding_timed_out();
248                 if (ret >= 0 && ret <= 4096) { return null; }
249                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
250                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
251                 return ret_hu_conv;
252         }
253
254         /**
255          * Utility method to constructs a new ProcessingError-variant ClosureReason
256          */
257         public static ClosureReason processing_error(java.lang.String err) {
258                 long ret = bindings.ClosureReason_processing_error(err);
259                 Reference.reachabilityFence(err);
260                 if (ret >= 0 && ret <= 4096) { return null; }
261                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
262                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
263                 return ret_hu_conv;
264         }
265
266         /**
267          * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
268          */
269         public static ClosureReason disconnected_peer() {
270                 long ret = bindings.ClosureReason_disconnected_peer();
271                 if (ret >= 0 && ret <= 4096) { return null; }
272                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
273                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
274                 return ret_hu_conv;
275         }
276
277         /**
278          * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
279          */
280         public static ClosureReason outdated_channel_manager() {
281                 long ret = bindings.ClosureReason_outdated_channel_manager();
282                 if (ret >= 0 && ret <= 4096) { return null; }
283                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
284                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
285                 return ret_hu_conv;
286         }
287
288         /**
289          * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason
290          */
291         public static ClosureReason counterparty_coop_closed_unfunded_channel() {
292                 long ret = bindings.ClosureReason_counterparty_coop_closed_unfunded_channel();
293                 if (ret >= 0 && ret <= 4096) { return null; }
294                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
295                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
296                 return ret_hu_conv;
297         }
298
299         /**
300          * Utility method to constructs a new FundingBatchClosure-variant ClosureReason
301          */
302         public static ClosureReason funding_batch_closure() {
303                 long ret = bindings.ClosureReason_funding_batch_closure();
304                 if (ret >= 0 && ret <= 4096) { return null; }
305                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
306                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
307                 return ret_hu_conv;
308         }
309
310         /**
311          * Checks if two ClosureReasons contain equal inner contents.
312          * This ignores pointers and is_owned flags and looks at the values in fields.
313          */
314         public boolean eq(org.ldk.structs.ClosureReason b) {
315                 boolean ret = bindings.ClosureReason_eq(this.ptr, b == null ? 0 : b.ptr);
316                 Reference.reachabilityFence(this);
317                 Reference.reachabilityFence(b);
318                 return ret;
319         }
320
321         @Override public boolean equals(Object o) {
322                 if (!(o instanceof ClosureReason)) return false;
323                 return this.eq((ClosureReason)o);
324         }
325         /**
326          * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
327          */
328         public byte[] write() {
329                 byte[] ret = bindings.ClosureReason_write(this.ptr);
330                 Reference.reachabilityFence(this);
331                 return ret;
332         }
333
334 }