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_HolderForceClosed(ptr);
22 case 2: return new MonitorEvent_Completed(ptr);
24 throw new ArgumentException("Impossible enum variant");
28 /** A MonitorEvent of type HTLCEvent */
29 public class MonitorEvent_HTLCEvent : MonitorEvent {
30 public HTLCUpdate htlc_event;
31 internal MonitorEvent_HTLCEvent(long ptr) : base(null, ptr) {
32 long htlc_event = bindings.LDKMonitorEvent_HTLCEvent_get_htlc_event(ptr);
33 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); }
34 if (htlc_event_hu_conv != null) { htlc_event_hu_conv.ptrs_to.AddLast(this); };
35 this.htlc_event = htlc_event_hu_conv;
38 /** A MonitorEvent of type HolderForceClosed */
39 public class MonitorEvent_HolderForceClosed : MonitorEvent {
40 public OutPoint holder_force_closed;
41 internal MonitorEvent_HolderForceClosed(long ptr) : base(null, ptr) {
42 long holder_force_closed = bindings.LDKMonitorEvent_HolderForceClosed_get_holder_force_closed(ptr);
43 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); }
44 if (holder_force_closed_hu_conv != null) { holder_force_closed_hu_conv.ptrs_to.AddLast(this); };
45 this.holder_force_closed = holder_force_closed_hu_conv;
48 /** A MonitorEvent of type Completed */
49 public class MonitorEvent_Completed : MonitorEvent {
51 * The funding outpoint of the [`ChannelMonitor`] that was updated
53 public OutPoint funding_txo;
55 * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
56 * [`ChannelMonitor::get_latest_update_id`].
58 * Note that this should only be set to a given update's ID if all previous updates for the
59 * same [`ChannelMonitor`] have been applied and persisted.
61 public long monitor_update_id;
62 internal MonitorEvent_Completed(long ptr) : base(null, ptr) {
63 long funding_txo = bindings.LDKMonitorEvent_Completed_get_funding_txo(ptr);
64 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); }
65 if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.AddLast(this); };
66 this.funding_txo = funding_txo_hu_conv;
67 this.monitor_update_id = bindings.LDKMonitorEvent_Completed_get_monitor_update_id(ptr);
70 internal long clone_ptr() {
71 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
77 * Creates a copy of the MonitorEvent
79 public MonitorEvent clone() {
80 long ret = bindings.MonitorEvent_clone(this.ptr);
82 if (ret >= 0 && ret <= 4096) { return null; }
83 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
84 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89 * Utility method to constructs a new HTLCEvent-variant MonitorEvent
91 public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
92 long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr);
94 if (ret >= 0 && ret <= 4096) { return null; }
95 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
96 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
97 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
102 * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
104 public static MonitorEvent holder_force_closed(org.ldk.structs.OutPoint a) {
105 long ret = bindings.MonitorEvent_holder_force_closed(a == null ? 0 : a.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
115 * Utility method to constructs a new Completed-variant MonitorEvent
117 public static MonitorEvent completed(org.ldk.structs.OutPoint funding_txo, long monitor_update_id) {
118 long ret = bindings.MonitorEvent_completed(funding_txo == null ? 0 : funding_txo.ptr, monitor_update_id);
119 GC.KeepAlive(funding_txo);
120 GC.KeepAlive(monitor_update_id);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(funding_txo); };
129 * Checks if two MonitorEvents contain equal inner contents.
130 * This ignores pointers and is_owned flags and looks at the values in fields.
132 public bool eq(org.ldk.structs.MonitorEvent b) {
133 bool ret = bindings.MonitorEvent_eq(this.ptr, b == null ? 0 : b.ptr);
139 public override bool Equals(object o) {
140 if (!(o is MonitorEvent)) return false;
141 return this.eq((MonitorEvent)o);
144 * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
146 public byte[] write() {
147 long ret = bindings.MonitorEvent_write(this.ptr);
149 if (ret >= 0 && ret <= 4096) { return null; }
150 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);