[Java] Update auto-generated bindings
[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 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                 assert false; return null; // Unreachable without extending the (internal) bindings interface
49         }
50
51         /**
52          * Closure generated from receiving a peer error message.
53          * 
54          * Our counterparty may have broadcasted their latest commitment state, and we have
55          * as well.
56          */
57         public final static class CounterpartyForceClosed extends ClosureReason {
58                 /**
59                  * The error which the peer sent us.
60                  * 
61                  * The string should be sanitized before it is used (e.g emitted to logs
62                  * or printed to stdout). Otherwise, a well crafted error message may exploit
63                  * a security vulnerability in the terminal emulator or the logging subsystem.
64                 */
65                 public final java.lang.String peer_msg;
66                 private CounterpartyForceClosed(long ptr, bindings.LDKClosureReason.CounterpartyForceClosed obj) {
67                         super(null, ptr);
68                         this.peer_msg = obj.peer_msg;
69                 }
70         }
71         /**
72          * Closure generated from [`ChannelManager::force_close_channel`], called by the user.
73          * 
74          * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
75          */
76         public final static class HolderForceClosed extends ClosureReason {
77                 private HolderForceClosed(long ptr, bindings.LDKClosureReason.HolderForceClosed obj) {
78                         super(null, ptr);
79                 }
80         }
81         /**
82          * The channel was closed after negotiating a cooperative close and we've now broadcasted
83          * the cooperative close transaction. Note the shutdown may have been initiated by us.
84          */
85         public final static class CooperativeClosure extends ClosureReason {
86                 private CooperativeClosure(long ptr, bindings.LDKClosureReason.CooperativeClosure obj) {
87                         super(null, ptr);
88                 }
89         }
90         /**
91          * A commitment transaction was confirmed on chain, closing the channel. Most likely this
92          * commitment transaction came from our counterparty, but it may also have come from
93          * a copy of our own `ChannelMonitor`.
94          */
95         public final static class CommitmentTxConfirmed extends ClosureReason {
96                 private CommitmentTxConfirmed(long ptr, bindings.LDKClosureReason.CommitmentTxConfirmed obj) {
97                         super(null, ptr);
98                 }
99         }
100         /**
101          * The funding transaction failed to confirm in a timely manner on an inbound channel.
102          */
103         public final static class FundingTimedOut extends ClosureReason {
104                 private FundingTimedOut(long ptr, bindings.LDKClosureReason.FundingTimedOut obj) {
105                         super(null, ptr);
106                 }
107         }
108         /**
109          * Closure generated from processing an event, likely a HTLC forward/relay/reception.
110          */
111         public final static class ProcessingError extends ClosureReason {
112                 /**
113                  * A developer-readable error message which we generated.
114                 */
115                 public final java.lang.String err;
116                 private ProcessingError(long ptr, bindings.LDKClosureReason.ProcessingError obj) {
117                         super(null, ptr);
118                         this.err = obj.err;
119                 }
120         }
121         /**
122          * The `PeerManager` informed us that we've disconnected from the peer. We close channels
123          * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
124          * peer again in the future or if the peer disconnected before we finished negotiating
125          * the channel open. The first case may be caused by incompatible features which our
126          * counterparty, or we, require.
127          */
128         public final static class DisconnectedPeer extends ClosureReason {
129                 private DisconnectedPeer(long ptr, bindings.LDKClosureReason.DisconnectedPeer obj) {
130                         super(null, ptr);
131                 }
132         }
133         /**
134          * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
135          * the ChannelManager deserialized.
136          */
137         public final static class OutdatedChannelManager extends ClosureReason {
138                 private OutdatedChannelManager(long ptr, bindings.LDKClosureReason.OutdatedChannelManager obj) {
139                         super(null, ptr);
140                 }
141         }
142         long clone_ptr() {
143                 long ret = bindings.ClosureReason_clone_ptr(this.ptr);
144                 Reference.reachabilityFence(this);
145                 return ret;
146         }
147
148         /**
149          * Creates a copy of the ClosureReason
150          */
151         public ClosureReason clone() {
152                 long ret = bindings.ClosureReason_clone(this.ptr);
153                 Reference.reachabilityFence(this);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
156                 ret_hu_conv.ptrs_to.add(this);
157                 return ret_hu_conv;
158         }
159
160         /**
161          * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
162          */
163         public static ClosureReason counterparty_force_closed(java.lang.String peer_msg) {
164                 long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg);
165                 Reference.reachabilityFence(peer_msg);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
168                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Utility method to constructs a new HolderForceClosed-variant ClosureReason
174          */
175         public static ClosureReason holder_force_closed() {
176                 long ret = bindings.ClosureReason_holder_force_closed();
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
179                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
180                 return ret_hu_conv;
181         }
182
183         /**
184          * Utility method to constructs a new CooperativeClosure-variant ClosureReason
185          */
186         public static ClosureReason cooperative_closure() {
187                 long ret = bindings.ClosureReason_cooperative_closure();
188                 if (ret >= 0 && ret <= 4096) { return null; }
189                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
190                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
191                 return ret_hu_conv;
192         }
193
194         /**
195          * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
196          */
197         public static ClosureReason commitment_tx_confirmed() {
198                 long ret = bindings.ClosureReason_commitment_tx_confirmed();
199                 if (ret >= 0 && ret <= 4096) { return null; }
200                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
201                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
202                 return ret_hu_conv;
203         }
204
205         /**
206          * Utility method to constructs a new FundingTimedOut-variant ClosureReason
207          */
208         public static ClosureReason funding_timed_out() {
209                 long ret = bindings.ClosureReason_funding_timed_out();
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
212                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Utility method to constructs a new ProcessingError-variant ClosureReason
218          */
219         public static ClosureReason processing_error(java.lang.String err) {
220                 long ret = bindings.ClosureReason_processing_error(err);
221                 Reference.reachabilityFence(err);
222                 if (ret >= 0 && ret <= 4096) { return null; }
223                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
224                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
225                 return ret_hu_conv;
226         }
227
228         /**
229          * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
230          */
231         public static ClosureReason disconnected_peer() {
232                 long ret = bindings.ClosureReason_disconnected_peer();
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
235                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
241          */
242         public static ClosureReason outdated_channel_manager() {
243                 long ret = bindings.ClosureReason_outdated_channel_manager();
244                 if (ret >= 0 && ret <= 4096) { return null; }
245                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
246                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
247                 return ret_hu_conv;
248         }
249
250         /**
251          * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
252          */
253         public byte[] write() {
254                 byte[] ret = bindings.ClosureReason_write(this.ptr);
255                 Reference.reachabilityFence(this);
256                 return ret;
257         }
258
259 }