6 namespace org { namespace ldk { namespace structs {
9 * The reason the channel was closed. See individual variants more details.
11 public class ClosureReason : CommonBase {
12 protected ClosureReason(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.ClosureReason_free(ptr); }
17 internal static ClosureReason constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKClosureReason_ty_from_ptr(ptr);
20 case 0: return new ClosureReason_CounterpartyForceClosed(ptr);
21 case 1: return new ClosureReason_HolderForceClosed(ptr);
22 case 2: return new ClosureReason_CooperativeClosure(ptr);
23 case 3: return new ClosureReason_CommitmentTxConfirmed(ptr);
24 case 4: return new ClosureReason_FundingTimedOut(ptr);
25 case 5: return new ClosureReason_ProcessingError(ptr);
26 case 6: return new ClosureReason_DisconnectedPeer(ptr);
27 case 7: return new ClosureReason_OutdatedChannelManager(ptr);
29 throw new ArgumentException("Impossible enum variant");
33 /** A ClosureReason of type CounterpartyForceClosed */
34 public class ClosureReason_CounterpartyForceClosed : ClosureReason {
36 * The error which the peer sent us.
38 * The string should be sanitized before it is used (e.g emitted to logs
39 * or printed to stdout). Otherwise, a well crafted error message may exploit
40 * a security vulnerability in the terminal emulator or the logging subsystem.
42 public string peer_msg;
43 internal ClosureReason_CounterpartyForceClosed(long ptr) : base(null, ptr) {
44 this.peer_msg = bindings.LDKClosureReason_CounterpartyForceClosed_get_peer_msg(ptr);
47 /** A ClosureReason of type HolderForceClosed */
48 public class ClosureReason_HolderForceClosed : ClosureReason {
49 internal ClosureReason_HolderForceClosed(long ptr) : base(null, ptr) {
52 /** A ClosureReason of type CooperativeClosure */
53 public class ClosureReason_CooperativeClosure : ClosureReason {
54 internal ClosureReason_CooperativeClosure(long ptr) : base(null, ptr) {
57 /** A ClosureReason of type CommitmentTxConfirmed */
58 public class ClosureReason_CommitmentTxConfirmed : ClosureReason {
59 internal ClosureReason_CommitmentTxConfirmed(long ptr) : base(null, ptr) {
62 /** A ClosureReason of type FundingTimedOut */
63 public class ClosureReason_FundingTimedOut : ClosureReason {
64 internal ClosureReason_FundingTimedOut(long ptr) : base(null, ptr) {
67 /** A ClosureReason of type ProcessingError */
68 public class ClosureReason_ProcessingError : ClosureReason {
70 * A developer-readable error message which we generated.
73 internal ClosureReason_ProcessingError(long ptr) : base(null, ptr) {
74 this.err = bindings.LDKClosureReason_ProcessingError_get_err(ptr);
77 /** A ClosureReason of type DisconnectedPeer */
78 public class ClosureReason_DisconnectedPeer : ClosureReason {
79 internal ClosureReason_DisconnectedPeer(long ptr) : base(null, ptr) {
82 /** A ClosureReason of type OutdatedChannelManager */
83 public class ClosureReason_OutdatedChannelManager : ClosureReason {
84 internal ClosureReason_OutdatedChannelManager(long ptr) : base(null, ptr) {
87 internal long clone_ptr() {
88 long ret = bindings.ClosureReason_clone_ptr(this.ptr);
94 * Creates a copy of the ClosureReason
96 public ClosureReason clone() {
97 long ret = bindings.ClosureReason_clone(this.ptr);
99 if (ret >= 0 && ret <= 4096) { return null; }
100 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
101 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
106 * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
108 public static ClosureReason counterparty_force_closed(string peer_msg) {
109 long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg);
110 GC.KeepAlive(peer_msg);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
118 * Utility method to constructs a new HolderForceClosed-variant ClosureReason
120 public static ClosureReason holder_force_closed() {
121 long ret = bindings.ClosureReason_holder_force_closed();
122 if (ret >= 0 && ret <= 4096) { return null; }
123 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
129 * Utility method to constructs a new CooperativeClosure-variant ClosureReason
131 public static ClosureReason cooperative_closure() {
132 long ret = bindings.ClosureReason_cooperative_closure();
133 if (ret >= 0 && ret <= 4096) { return null; }
134 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
135 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
140 * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
142 public static ClosureReason commitment_tx_confirmed() {
143 long ret = bindings.ClosureReason_commitment_tx_confirmed();
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
151 * Utility method to constructs a new FundingTimedOut-variant ClosureReason
153 public static ClosureReason funding_timed_out() {
154 long ret = bindings.ClosureReason_funding_timed_out();
155 if (ret >= 0 && ret <= 4096) { return null; }
156 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
162 * Utility method to constructs a new ProcessingError-variant ClosureReason
164 public static ClosureReason processing_error(string err) {
165 long ret = bindings.ClosureReason_processing_error(err);
167 if (ret >= 0 && ret <= 4096) { return null; }
168 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
174 * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
176 public static ClosureReason disconnected_peer() {
177 long ret = bindings.ClosureReason_disconnected_peer();
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
185 * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
187 public static ClosureReason outdated_channel_manager() {
188 long ret = bindings.ClosureReason_outdated_channel_manager();
189 if (ret >= 0 && ret <= 4096) { return null; }
190 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
191 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
196 * Checks if two ClosureReasons contain equal inner contents.
197 * This ignores pointers and is_owned flags and looks at the values in fields.
199 public bool eq(org.ldk.structs.ClosureReason b) {
200 bool ret = bindings.ClosureReason_eq(this.ptr, b == null ? 0 : b.ptr);
206 public override bool Equals(object o) {
207 if (!(o is ClosureReason)) return false;
208 return this.eq((ClosureReason)o);
211 * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
213 public byte[] write() {
214 byte[] ret = bindings.ClosureReason_write(this.ptr);