[C#] Update auto-generated C# bindings
[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_HolderForceClosed(ptr);
22                         case 2: return new MonitorEvent_Completed(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
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;
36                 }
37         }
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;
46                 }
47         }
48         /** A MonitorEvent of type Completed */
49         public class MonitorEvent_Completed : MonitorEvent {
50                 /**
51                  * The funding outpoint of the [`ChannelMonitor`] that was updated
52                  */
53                 public OutPoint funding_txo;
54                 /**
55                  * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
56                  * [`ChannelMonitor::get_latest_update_id`].
57                  * 
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.
60                  */
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);
68                 }
69         }
70         internal long clone_ptr() {
71                 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
72                 GC.KeepAlive(this);
73                 return ret;
74         }
75
76         /**
77          * Creates a copy of the MonitorEvent
78          */
79         public MonitorEvent clone() {
80                 long ret = bindings.MonitorEvent_clone(this.ptr);
81                 GC.KeepAlive(this);
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); };
85                 return ret_hu_conv;
86         }
87
88         /**
89          * Utility method to constructs a new HTLCEvent-variant MonitorEvent
90          */
91         public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
92                 long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr);
93                 GC.KeepAlive(a);
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); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
103          */
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);
106                 GC.KeepAlive(a);
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); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Utility method to constructs a new Completed-variant MonitorEvent
116          */
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); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Checks if two MonitorEvents contain equal inner contents.
130          * This ignores pointers and is_owned flags and looks at the values in fields.
131          */
132         public bool eq(org.ldk.structs.MonitorEvent b) {
133                 bool ret = bindings.MonitorEvent_eq(this.ptr, b == null ? 0 : b.ptr);
134                 GC.KeepAlive(this);
135                 GC.KeepAlive(b);
136                 return ret;
137         }
138
139         public override bool Equals(object o) {
140                 if (!(o is MonitorEvent)) return false;
141                 return this.eq((MonitorEvent)o);
142         }
143         /**
144          * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
145          */
146         public byte[] write() {
147                 long ret = bindings.MonitorEvent_write(this.ptr);
148                 GC.KeepAlive(this);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
151                 return ret_conv;
152         }
153
154 }
155 } } }