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 javax.annotation.Nullable;
8
9
10 /**
11  * The reason the channel was closed. See individual variants more details.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ClosureReason extends CommonBase {
15         private ClosureReason(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ClosureReason_free(ptr); }
20         }
21         static ClosureReason constr_from_ptr(long ptr) {
22                 bindings.LDKClosureReason raw_val = bindings.LDKClosureReason_ref_from_ptr(ptr);
23                 if (raw_val.getClass() == bindings.LDKClosureReason.CounterpartyForceClosed.class) {
24                         return new CounterpartyForceClosed(ptr, (bindings.LDKClosureReason.CounterpartyForceClosed)raw_val);
25                 }
26                 if (raw_val.getClass() == bindings.LDKClosureReason.HolderForceClosed.class) {
27                         return new HolderForceClosed(ptr, (bindings.LDKClosureReason.HolderForceClosed)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKClosureReason.CooperativeClosure.class) {
30                         return new CooperativeClosure(ptr, (bindings.LDKClosureReason.CooperativeClosure)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKClosureReason.CommitmentTxConfirmed.class) {
33                         return new CommitmentTxConfirmed(ptr, (bindings.LDKClosureReason.CommitmentTxConfirmed)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKClosureReason.ProcessingError.class) {
36                         return new ProcessingError(ptr, (bindings.LDKClosureReason.ProcessingError)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKClosureReason.DisconnectedPeer.class) {
39                         return new DisconnectedPeer(ptr, (bindings.LDKClosureReason.DisconnectedPeer)raw_val);
40                 }
41                 if (raw_val.getClass() == bindings.LDKClosureReason.OutdatedChannelManager.class) {
42                         return new OutdatedChannelManager(ptr, (bindings.LDKClosureReason.OutdatedChannelManager)raw_val);
43                 }
44                 assert false; return null; // Unreachable without extending the (internal) bindings interface
45         }
46
47         /**
48          * Closure generated from receiving a peer error message.
49          * 
50          * Our counterparty may have broadcasted their latest commitment state, and we have
51          * as well.
52          */
53         public final static class CounterpartyForceClosed extends ClosureReason {
54                 /**
55                  * The error which the peer sent us.
56                  * 
57                  * The string should be sanitized before it is used (e.g emitted to logs
58                  * or printed to stdout). Otherwise, a well crafted error message may exploit
59                  * a security vulnerability in the terminal emulator or the logging subsystem.
60                 */
61                 public final String peer_msg;
62                 private CounterpartyForceClosed(long ptr, bindings.LDKClosureReason.CounterpartyForceClosed obj) {
63                         super(null, ptr);
64                         this.peer_msg = obj.peer_msg;
65                 }
66         }
67         /**
68          * Closure generated from [`ChannelManager::force_close_channel`], called by the user.
69          * 
70          * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
71          */
72         public final static class HolderForceClosed extends ClosureReason {
73                 private HolderForceClosed(long ptr, bindings.LDKClosureReason.HolderForceClosed obj) {
74                         super(null, ptr);
75                 }
76         }
77         /**
78          * The channel was closed after negotiating a cooperative close and we've now broadcasted
79          * the cooperative close transaction. Note the shutdown may have been initiated by us.
80          */
81         public final static class CooperativeClosure extends ClosureReason {
82                 private CooperativeClosure(long ptr, bindings.LDKClosureReason.CooperativeClosure obj) {
83                         super(null, ptr);
84                 }
85         }
86         /**
87          * A commitment transaction was confirmed on chain, closing the channel. Most likely this
88          * commitment transaction came from our counterparty, but it may also have come from
89          * a copy of our own `ChannelMonitor`.
90          */
91         public final static class CommitmentTxConfirmed extends ClosureReason {
92                 private CommitmentTxConfirmed(long ptr, bindings.LDKClosureReason.CommitmentTxConfirmed obj) {
93                         super(null, ptr);
94                 }
95         }
96         /**
97          * Closure generated from processing an event, likely a HTLC forward/relay/reception.
98          */
99         public final static class ProcessingError extends ClosureReason {
100                 /**
101                  * A developer-readable error message which we generated.
102                 */
103                 public final String err;
104                 private ProcessingError(long ptr, bindings.LDKClosureReason.ProcessingError obj) {
105                         super(null, ptr);
106                         this.err = obj.err;
107                 }
108         }
109         /**
110          * The `PeerManager` informed us that we've disconnected from the peer. We close channels
111          * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
112          * peer again in the future or if the peer disconnected before we finished negotiating
113          * the channel open. The first case may be caused by incompatible features which our
114          * counterparty, or we, require.
115          */
116         public final static class DisconnectedPeer extends ClosureReason {
117                 private DisconnectedPeer(long ptr, bindings.LDKClosureReason.DisconnectedPeer obj) {
118                         super(null, ptr);
119                 }
120         }
121         /**
122          * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
123          * the ChannelManager deserialized.
124          */
125         public final static class OutdatedChannelManager extends ClosureReason {
126                 private OutdatedChannelManager(long ptr, bindings.LDKClosureReason.OutdatedChannelManager obj) {
127                         super(null, ptr);
128                 }
129         }
130         long clone_ptr() {
131                 long ret = bindings.ClosureReason_clone_ptr(this.ptr);
132                 return ret;
133         }
134
135         /**
136          * Creates a copy of the ClosureReason
137          */
138         public ClosureReason clone() {
139                 long ret = bindings.ClosureReason_clone(this.ptr);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
142                 ret_hu_conv.ptrs_to.add(this);
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
148          */
149         public static ClosureReason counterparty_force_closed(java.lang.String peer_msg) {
150                 long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
153                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Utility method to constructs a new HolderForceClosed-variant ClosureReason
159          */
160         public static ClosureReason holder_force_closed() {
161                 long ret = bindings.ClosureReason_holder_force_closed();
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
164                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
165                 return ret_hu_conv;
166         }
167
168         /**
169          * Utility method to constructs a new CooperativeClosure-variant ClosureReason
170          */
171         public static ClosureReason cooperative_closure() {
172                 long ret = bindings.ClosureReason_cooperative_closure();
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
175                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
181          */
182         public static ClosureReason commitment_tx_confirmed() {
183                 long ret = bindings.ClosureReason_commitment_tx_confirmed();
184                 if (ret >= 0 && ret <= 4096) { return null; }
185                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
186                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
187                 return ret_hu_conv;
188         }
189
190         /**
191          * Utility method to constructs a new ProcessingError-variant ClosureReason
192          */
193         public static ClosureReason processing_error(java.lang.String err) {
194                 long ret = bindings.ClosureReason_processing_error(err);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
197                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
203          */
204         public static ClosureReason disconnected_peer() {
205                 long ret = bindings.ClosureReason_disconnected_peer();
206                 if (ret >= 0 && ret <= 4096) { return null; }
207                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
208                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
209                 return ret_hu_conv;
210         }
211
212         /**
213          * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
214          */
215         public static ClosureReason outdated_channel_manager() {
216                 long ret = bindings.ClosureReason_outdated_channel_manager();
217                 if (ret >= 0 && ret <= 4096) { return null; }
218                 ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
219                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
220                 return ret_hu_conv;
221         }
222
223         /**
224          * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
225          */
226         public byte[] write() {
227                 byte[] ret = bindings.ClosureReason_write(this.ptr);
228                 return ret;
229         }
230
231 }