[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / MonitorEvent.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  * An event to be processed by the ChannelManager.
10  */
11 public class MonitorEvent : CommonBase {
12         protected MonitorEvent(object _dummy, long ptr) : base(ptr) { }
13         ~MonitorEvent() {
14                 if (ptr != 0) { bindings.MonitorEvent_free(ptr); }
15         }
16
17         internal static MonitorEvent constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKMonitorEvent_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new MonitorEvent_HTLCEvent(ptr);
21                         case 1: return new MonitorEvent_HolderForceClosedWithInfo(ptr);
22                         case 2: return new MonitorEvent_HolderForceClosed(ptr);
23                         case 3: return new MonitorEvent_Completed(ptr);
24                         default:
25                                 throw new ArgumentException("Impossible enum variant");
26                 }
27         }
28
29         /** A MonitorEvent of type HTLCEvent */
30         public class MonitorEvent_HTLCEvent : MonitorEvent {
31                 public HTLCUpdate htlc_event;
32                 internal MonitorEvent_HTLCEvent(long ptr) : base(null, ptr) {
33                         long htlc_event = bindings.LDKMonitorEvent_HTLCEvent_get_htlc_event(ptr);
34                         org.ldk.structs.HTLCUpdate htlc_event_hu_conv = null; if (htlc_event < 0 || htlc_event > 4096) { htlc_event_hu_conv = new org.ldk.structs.HTLCUpdate(null, htlc_event); }
35                         if (htlc_event_hu_conv != null) { htlc_event_hu_conv.ptrs_to.AddLast(this); };
36                         this.htlc_event = htlc_event_hu_conv;
37                 }
38         }
39         /** A MonitorEvent of type HolderForceClosedWithInfo */
40         public class MonitorEvent_HolderForceClosedWithInfo : MonitorEvent {
41                 /**
42                  * The reason the channel was closed.
43                  */
44                 public ClosureReason reason;
45                 /**
46                  * The funding outpoint of the channel.
47                  */
48                 public OutPoint outpoint;
49                 /**
50                  * The channel ID of the channel.
51                  */
52                 public ChannelId channel_id;
53                 internal MonitorEvent_HolderForceClosedWithInfo(long ptr) : base(null, ptr) {
54                         long reason = bindings.LDKMonitorEvent_HolderForceClosedWithInfo_get_reason(ptr);
55                         org.ldk.structs.ClosureReason reason_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(reason);
56                         if (reason_hu_conv != null) { reason_hu_conv.ptrs_to.AddLast(this); };
57                         this.reason = reason_hu_conv;
58                         long outpoint = bindings.LDKMonitorEvent_HolderForceClosedWithInfo_get_outpoint(ptr);
59                         org.ldk.structs.OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new org.ldk.structs.OutPoint(null, outpoint); }
60                         if (outpoint_hu_conv != null) { outpoint_hu_conv.ptrs_to.AddLast(this); };
61                         this.outpoint = outpoint_hu_conv;
62                         long channel_id = bindings.LDKMonitorEvent_HolderForceClosedWithInfo_get_channel_id(ptr);
63                         org.ldk.structs.ChannelId channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new org.ldk.structs.ChannelId(null, channel_id); }
64                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.AddLast(this); };
65                         this.channel_id = channel_id_hu_conv;
66                 }
67         }
68         /** A MonitorEvent of type HolderForceClosed */
69         public class MonitorEvent_HolderForceClosed : MonitorEvent {
70                 public OutPoint holder_force_closed;
71                 internal MonitorEvent_HolderForceClosed(long ptr) : base(null, ptr) {
72                         long holder_force_closed = bindings.LDKMonitorEvent_HolderForceClosed_get_holder_force_closed(ptr);
73                         org.ldk.structs.OutPoint holder_force_closed_hu_conv = null; if (holder_force_closed < 0 || holder_force_closed > 4096) { holder_force_closed_hu_conv = new org.ldk.structs.OutPoint(null, holder_force_closed); }
74                         if (holder_force_closed_hu_conv != null) { holder_force_closed_hu_conv.ptrs_to.AddLast(this); };
75                         this.holder_force_closed = holder_force_closed_hu_conv;
76                 }
77         }
78         /** A MonitorEvent of type Completed */
79         public class MonitorEvent_Completed : MonitorEvent {
80                 /**
81                  * The funding outpoint of the [`ChannelMonitor`] that was updated
82                  */
83                 public OutPoint funding_txo;
84                 /**
85                  * The channel ID of the channel associated with the [`ChannelMonitor`]
86                  */
87                 public ChannelId channel_id;
88                 /**
89                  * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
90                  * [`ChannelMonitor::get_latest_update_id`].
91                  * 
92                  * Note that this should only be set to a given update's ID if all previous updates for the
93                  * same [`ChannelMonitor`] have been applied and persisted.
94                  */
95                 public long monitor_update_id;
96                 internal MonitorEvent_Completed(long ptr) : base(null, ptr) {
97                         long funding_txo = bindings.LDKMonitorEvent_Completed_get_funding_txo(ptr);
98                         org.ldk.structs.OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new org.ldk.structs.OutPoint(null, funding_txo); }
99                         if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.AddLast(this); };
100                         this.funding_txo = funding_txo_hu_conv;
101                         long channel_id = bindings.LDKMonitorEvent_Completed_get_channel_id(ptr);
102                         org.ldk.structs.ChannelId channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new org.ldk.structs.ChannelId(null, channel_id); }
103                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.AddLast(this); };
104                         this.channel_id = channel_id_hu_conv;
105                         this.monitor_update_id = bindings.LDKMonitorEvent_Completed_get_monitor_update_id(ptr);
106                 }
107         }
108         internal long clone_ptr() {
109                 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         /**
115          * Creates a copy of the MonitorEvent
116          */
117         public MonitorEvent clone() {
118                 long ret = bindings.MonitorEvent_clone(this.ptr);
119                 GC.KeepAlive(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Utility method to constructs a new HTLCEvent-variant MonitorEvent
128          */
129         public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
130                 long ret = bindings.MonitorEvent_htlcevent(a.ptr);
131                 GC.KeepAlive(a);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
134                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
136                 return ret_hu_conv;
137         }
138
139         /**
140          * Utility method to constructs a new HolderForceClosedWithInfo-variant MonitorEvent
141          */
142         public static MonitorEvent holder_force_closed_with_info(org.ldk.structs.ClosureReason reason, org.ldk.structs.OutPoint outpoint, org.ldk.structs.ChannelId channel_id) {
143                 long ret = bindings.MonitorEvent_holder_force_closed_with_info(reason.ptr, outpoint.ptr, channel_id.ptr);
144                 GC.KeepAlive(reason);
145                 GC.KeepAlive(outpoint);
146                 GC.KeepAlive(channel_id);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
149                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reason); };
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id); };
153                 return ret_hu_conv;
154         }
155
156         /**
157          * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
158          */
159         public static MonitorEvent holder_force_closed(org.ldk.structs.OutPoint a) {
160                 long ret = bindings.MonitorEvent_holder_force_closed(a.ptr);
161                 GC.KeepAlive(a);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
164                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
165                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Utility method to constructs a new Completed-variant MonitorEvent
171          */
172         public static MonitorEvent completed(org.ldk.structs.OutPoint funding_txo, org.ldk.structs.ChannelId channel_id, long monitor_update_id) {
173                 long ret = bindings.MonitorEvent_completed(funding_txo.ptr, channel_id.ptr, monitor_update_id);
174                 GC.KeepAlive(funding_txo);
175                 GC.KeepAlive(channel_id);
176                 GC.KeepAlive(monitor_update_id);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(funding_txo); };
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id); };
182                 return ret_hu_conv;
183         }
184
185         /**
186          * Checks if two MonitorEvents contain equal inner contents.
187          * This ignores pointers and is_owned flags and looks at the values in fields.
188          */
189         public bool eq(org.ldk.structs.MonitorEvent b) {
190                 bool ret = bindings.MonitorEvent_eq(this.ptr, b.ptr);
191                 GC.KeepAlive(this);
192                 GC.KeepAlive(b);
193                 return ret;
194         }
195
196         public override bool Equals(object o) {
197                 if (!(o is MonitorEvent)) return false;
198                 return this.eq((MonitorEvent)o);
199         }
200         /**
201          * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
202          */
203         public byte[] write() {
204                 long ret = bindings.MonitorEvent_write(this.ptr);
205                 GC.KeepAlive(this);
206                 if (ret >= 0 && ret <= 4096) { return null; }
207                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
208                 return ret_conv;
209         }
210
211 }
212 } } }