6 namespace org { namespace ldk { namespace structs {
9 * An event to be processed by the ChannelManager.
11 public class MonitorEvent : CommonBase {
12 protected MonitorEvent(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.MonitorEvent_free(ptr); }
17 internal static MonitorEvent constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKMonitorEvent_ty_from_ptr(ptr);
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);
25 throw new ArgumentException("Impossible enum variant");
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;
39 /** A MonitorEvent of type HolderForceClosedWithInfo */
40 public class MonitorEvent_HolderForceClosedWithInfo : MonitorEvent {
42 * The reason the channel was closed.
44 public ClosureReason reason;
46 * The funding outpoint of the channel.
48 public OutPoint outpoint;
50 * The channel ID of the channel.
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;
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;
78 /** A MonitorEvent of type Completed */
79 public class MonitorEvent_Completed : MonitorEvent {
81 * The funding outpoint of the [`ChannelMonitor`] that was updated
83 public OutPoint funding_txo;
85 * The channel ID of the channel associated with the [`ChannelMonitor`]
87 public ChannelId channel_id;
89 * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
90 * [`ChannelMonitor::get_latest_update_id`].
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.
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);
108 internal long clone_ptr() {
109 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
115 * Creates a copy of the MonitorEvent
117 public MonitorEvent clone() {
118 long ret = bindings.MonitorEvent_clone(this.ptr);
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); };
127 * Utility method to constructs a new HTLCEvent-variant MonitorEvent
129 public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
130 long ret = bindings.MonitorEvent_htlcevent(a.ptr);
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); };
140 * Utility method to constructs a new HolderForceClosedWithInfo-variant MonitorEvent
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); };
157 * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
159 public static MonitorEvent holder_force_closed(org.ldk.structs.OutPoint a) {
160 long ret = bindings.MonitorEvent_holder_force_closed(a.ptr);
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); };
170 * Utility method to constructs a new Completed-variant MonitorEvent
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); };
186 * Checks if two MonitorEvents contain equal inner contents.
187 * This ignores pointers and is_owned flags and looks at the values in fields.
189 public bool eq(org.ldk.structs.MonitorEvent b) {
190 bool ret = bindings.MonitorEvent_eq(this.ptr, b.ptr);
196 public override bool Equals(object o) {
197 if (!(o is MonitorEvent)) return false;
198 return this.eq((MonitorEvent)o);
201 * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
203 public byte[] write() {
204 long ret = bindings.MonitorEvent_write(this.ptr);
206 if (ret >= 0 && ret <= 4096) { return null; }
207 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);