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_CommitmentTxConfirmed(ptr);
22 case 2: return new MonitorEvent_Completed(ptr);
23 case 3: return new MonitorEvent_UpdateFailed(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 CommitmentTxConfirmed */
40 public class MonitorEvent_CommitmentTxConfirmed : MonitorEvent {
41 public OutPoint commitment_tx_confirmed;
42 internal MonitorEvent_CommitmentTxConfirmed(long ptr) : base(null, ptr) {
43 long commitment_tx_confirmed = bindings.LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(ptr);
44 org.ldk.structs.OutPoint commitment_tx_confirmed_hu_conv = null; if (commitment_tx_confirmed < 0 || commitment_tx_confirmed > 4096) { commitment_tx_confirmed_hu_conv = new org.ldk.structs.OutPoint(null, commitment_tx_confirmed); }
45 if (commitment_tx_confirmed_hu_conv != null) { commitment_tx_confirmed_hu_conv.ptrs_to.AddLast(this); };
46 this.commitment_tx_confirmed = commitment_tx_confirmed_hu_conv;
49 /** A MonitorEvent of type Completed */
50 public class MonitorEvent_Completed : MonitorEvent {
52 * The funding outpoint of the [`ChannelMonitor`] that was updated
54 public OutPoint funding_txo;
56 * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
57 * [`ChannelMonitor::get_latest_update_id`].
59 * Note that this should only be set to a given update's ID if all previous updates for the
60 * same [`ChannelMonitor`] have been applied and persisted.
62 public long monitor_update_id;
63 internal MonitorEvent_Completed(long ptr) : base(null, ptr) {
64 long funding_txo = bindings.LDKMonitorEvent_Completed_get_funding_txo(ptr);
65 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); }
66 if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.AddLast(this); };
67 this.funding_txo = funding_txo_hu_conv;
68 this.monitor_update_id = bindings.LDKMonitorEvent_Completed_get_monitor_update_id(ptr);
71 /** A MonitorEvent of type UpdateFailed */
72 public class MonitorEvent_UpdateFailed : MonitorEvent {
73 public OutPoint update_failed;
74 internal MonitorEvent_UpdateFailed(long ptr) : base(null, ptr) {
75 long update_failed = bindings.LDKMonitorEvent_UpdateFailed_get_update_failed(ptr);
76 org.ldk.structs.OutPoint update_failed_hu_conv = null; if (update_failed < 0 || update_failed > 4096) { update_failed_hu_conv = new org.ldk.structs.OutPoint(null, update_failed); }
77 if (update_failed_hu_conv != null) { update_failed_hu_conv.ptrs_to.AddLast(this); };
78 this.update_failed = update_failed_hu_conv;
81 internal long clone_ptr() {
82 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
88 * Creates a copy of the MonitorEvent
90 public MonitorEvent clone() {
91 long ret = bindings.MonitorEvent_clone(this.ptr);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
100 * Utility method to constructs a new HTLCEvent-variant MonitorEvent
102 public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
103 long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
108 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
113 * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent
115 public static MonitorEvent commitment_tx_confirmed(org.ldk.structs.OutPoint a) {
116 long ret = bindings.MonitorEvent_commitment_tx_confirmed(a == null ? 0 : a.ptr);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
126 * Utility method to constructs a new Completed-variant MonitorEvent
128 public static MonitorEvent completed(org.ldk.structs.OutPoint funding_txo, long monitor_update_id) {
129 long ret = bindings.MonitorEvent_completed(funding_txo == null ? 0 : funding_txo.ptr, monitor_update_id);
130 GC.KeepAlive(funding_txo);
131 GC.KeepAlive(monitor_update_id);
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(funding_txo); };
140 * Utility method to constructs a new UpdateFailed-variant MonitorEvent
142 public static MonitorEvent update_failed(org.ldk.structs.OutPoint a) {
143 long ret = bindings.MonitorEvent_update_failed(a == null ? 0 : a.ptr);
145 if (ret >= 0 && ret <= 4096) { return null; }
146 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
153 * Checks if two MonitorEvents contain equal inner contents.
154 * This ignores pointers and is_owned flags and looks at the values in fields.
156 public bool eq(org.ldk.structs.MonitorEvent b) {
157 bool ret = bindings.MonitorEvent_eq(this.ptr, b == null ? 0 : b.ptr);
163 public override bool Equals(object o) {
164 if (!(o is MonitorEvent)) return false;
165 return this.eq((MonitorEvent)o);
168 * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
170 public byte[] write() {
171 byte[] ret = bindings.MonitorEvent_write(this.ptr);