[Java] Update auto-generated Java bindings to LDK 0.0.121
[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          * Indicates we broadcasted the channel's latest commitment transaction and thus closed the
51          * channel.
52          */
53         public final static class HolderForceClosed extends MonitorEvent {
54                 public final org.ldk.structs.OutPoint holder_force_closed;
55                 private HolderForceClosed(long ptr, bindings.LDKMonitorEvent.HolderForceClosed obj) {
56                         super(null, ptr);
57                         long holder_force_closed = obj.holder_force_closed;
58                         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); }
59                         if (holder_force_closed_hu_conv != null) { holder_force_closed_hu_conv.ptrs_to.add(this); };
60                         this.holder_force_closed = holder_force_closed_hu_conv;
61                 }
62         }
63         /**
64          * Indicates a [`ChannelMonitor`] update has completed. See
65          * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used.
66          * 
67          * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress
68          */
69         public final static class Completed extends MonitorEvent {
70                 /**
71                  * The funding outpoint of the [`ChannelMonitor`] that was updated
72                 */
73                 public final org.ldk.structs.OutPoint funding_txo;
74                 /**
75                  * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
76                  * [`ChannelMonitor::get_latest_update_id`].
77                  * 
78                  * Note that this should only be set to a given update's ID if all previous updates for the
79                  * same [`ChannelMonitor`] have been applied and persisted.
80                 */
81                 public final long monitor_update_id;
82                 private Completed(long ptr, bindings.LDKMonitorEvent.Completed obj) {
83                         super(null, ptr);
84                         long funding_txo = obj.funding_txo;
85                         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); }
86                         if (funding_txo_hu_conv != null) { funding_txo_hu_conv.ptrs_to.add(this); };
87                         this.funding_txo = funding_txo_hu_conv;
88                         this.monitor_update_id = obj.monitor_update_id;
89                 }
90         }
91         long clone_ptr() {
92                 long ret = bindings.MonitorEvent_clone_ptr(this.ptr);
93                 Reference.reachabilityFence(this);
94                 return ret;
95         }
96
97         /**
98          * Creates a copy of the MonitorEvent
99          */
100         public MonitorEvent clone() {
101                 long ret = bindings.MonitorEvent_clone(this.ptr);
102                 Reference.reachabilityFence(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Utility method to constructs a new HTLCEvent-variant MonitorEvent
111          */
112         public static MonitorEvent htlcevent(org.ldk.structs.HTLCUpdate a) {
113                 long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr);
114                 Reference.reachabilityFence(a);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Utility method to constructs a new HolderForceClosed-variant MonitorEvent
124          */
125         public static MonitorEvent holder_force_closed(org.ldk.structs.OutPoint a) {
126                 long ret = bindings.MonitorEvent_holder_force_closed(a == null ? 0 : a.ptr);
127                 Reference.reachabilityFence(a);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Utility method to constructs a new Completed-variant MonitorEvent
137          */
138         public static MonitorEvent completed(org.ldk.structs.OutPoint funding_txo, long monitor_update_id) {
139                 long ret = bindings.MonitorEvent_completed(funding_txo == null ? 0 : funding_txo.ptr, monitor_update_id);
140                 Reference.reachabilityFence(funding_txo);
141                 Reference.reachabilityFence(monitor_update_id);
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 org.ldk.structs.MonitorEvent ret_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret);
144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_txo); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Checks if two MonitorEvents contain equal inner contents.
151          * This ignores pointers and is_owned flags and looks at the values in fields.
152          */
153         public boolean eq(org.ldk.structs.MonitorEvent b) {
154                 boolean ret = bindings.MonitorEvent_eq(this.ptr, b == null ? 0 : b.ptr);
155                 Reference.reachabilityFence(this);
156                 Reference.reachabilityFence(b);
157                 return ret;
158         }
159
160         @Override public boolean equals(Object o) {
161                 if (!(o instanceof MonitorEvent)) return false;
162                 return this.eq((MonitorEvent)o);
163         }
164         /**
165          * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
166          */
167         public byte[] write() {
168                 byte[] ret = bindings.MonitorEvent_write(this.ptr);
169                 Reference.reachabilityFence(this);
170                 return ret;
171         }
172
173 }