[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / MonitorEvent.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An event to be processed by the ChannelManager.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class MonitorEvent extends CommonBase {
16         private MonitorEvent(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.MonitorEvent_free(ptr); }
21         }
22         static MonitorEvent constr_from_ptr(long ptr) {
23                 bindings.LDKMonitorEvent raw_val = bindings.LDKMonitorEvent_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKMonitorEvent.HTLCEvent.class) {
25                         return new HTLCEvent(ptr, (bindings.LDKMonitorEvent.HTLCEvent)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKMonitorEvent.HolderForceClosed.class) {
28                         return new HolderForceClosed(ptr, (bindings.LDKMonitorEvent.HolderForceClosed)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKMonitorEvent.Completed.class) {
31                         return new Completed(ptr, (bindings.LDKMonitorEvent.Completed)raw_val);
32                 }
33                 assert false; return null; // Unreachable without extending the (internal) bindings interface
34         }
35
36         /**
37          * A monitor event containing an HTLCUpdate.
38          */
39         public final static class HTLCEvent extends MonitorEvent {
40                 public final org.ldk.structs.HTLCUpdate htlc_event;
41                 private HTLCEvent(long ptr, bindings.LDKMonitorEvent.HTLCEvent obj) {
42                         super(null, ptr);
43                         long htlc_event = obj.htlc_event;
44                         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); }
45                         if (htlc_event_hu_conv != null) { htlc_event_hu_conv.ptrs_to.add(this); };
46                         this.htlc_event = htlc_event_hu_conv;
47                 }
48         }
49         /**
50          * A monitor event that the Channel's commitment transaction was confirmed.
51          */
52         public final static class HolderForceClosed extends MonitorEvent {
53                 public final org.ldk.structs.OutPoint holder_force_closed;
54                 private HolderForceClosed(long ptr, bindings.LDKMonitorEvent.HolderForceClosed obj) {
55                         super(null, ptr);
56                         long holder_force_closed = obj.holder_force_closed;
57                         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); }
58                         if (holder_force_closed_hu_conv != null) { holder_force_closed_hu_conv.ptrs_to.add(this); };
59                         this.holder_force_closed = holder_force_closed_hu_conv;
60                 }
61         }
62         /**
63          * Indicates a [`ChannelMonitor`] update has completed. See
64          * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used.
65          * 
66          * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress
67          */
68         public final static class Completed extends MonitorEvent {
69                 /**
70                  * The funding outpoint of the [`ChannelMonitor`] that was updated
71                 */
72                 public final org.ldk.structs.OutPoint funding_txo;
73                 /**
74                  * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
75                  * [`ChannelMonitor::get_latest_update_id`].
76                  * 
77                  * Note that this should only be set to a given update's ID if all previous updates for the
78                  * same [`ChannelMonitor`] have been applied and persisted.
79                 */
80                 public final long monitor_update_id;
81                 private Completed(long ptr, bindings.LDKMonitorEvent.Completed obj) {
82                         super(null, ptr);
83                         long funding_txo = obj.funding_txo;
84                         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); }
85                         if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.add(this); };
86                         this.funding_txo = funding_txo_hu_conv;
87                         this.monitor_update_id = obj.monitor_update_id;
88                 }
89         }
90         long clone_ptr() {
91                 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
92                 Reference.reachabilityFence(this);
93                 return ret;
94         }
95
96         /**
97          * Creates a copy of the MonitorEvent
98          */
99         public MonitorEvent clone() {
100                 long ret = bindings.MonitorEvent_clone(this.ptr);
101                 Reference.reachabilityFence(this);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Utility method to constructs a new HTLCEvent-variant MonitorEvent
110          */
111         public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
112                 long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr);
113                 Reference.reachabilityFence(a);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
123          */
124         public static MonitorEvent holder_force_closed(org.ldk.structs.OutPoint a) {
125                 long ret = bindings.MonitorEvent_holder_force_closed(a == null ? 0 : a.ptr);
126                 Reference.reachabilityFence(a);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Utility method to constructs a new Completed-variant MonitorEvent
136          */
137         public static MonitorEvent completed(org.ldk.structs.OutPoint funding_txo, long monitor_update_id) {
138                 long ret = bindings.MonitorEvent_completed(funding_txo == null ? 0 : funding_txo.ptr, monitor_update_id);
139                 Reference.reachabilityFence(funding_txo);
140                 Reference.reachabilityFence(monitor_update_id);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
143                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_txo); };
145                 return ret_hu_conv;
146         }
147
148         /**
149          * Checks if two MonitorEvents contain equal inner contents.
150          * This ignores pointers and is_owned flags and looks at the values in fields.
151          */
152         public boolean eq(org.ldk.structs.MonitorEvent b) {
153                 boolean ret = bindings.MonitorEvent_eq(this.ptr, b == null ? 0 : b.ptr);
154                 Reference.reachabilityFence(this);
155                 Reference.reachabilityFence(b);
156                 return ret;
157         }
158
159         @Override public boolean equals(Object o) {
160                 if (!(o instanceof MonitorEvent)) return false;
161                 return this.eq((MonitorEvent)o);
162         }
163         /**
164          * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
165          */
166         public byte[] write() {
167                 byte[] ret = bindings.MonitorEvent_write(this.ptr);
168                 Reference.reachabilityFence(this);
169                 return ret;
170         }
171
172 }