[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / ChannelMonitorUpdate.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 update generated by the underlying channel itself which contains some new information the
13  * [`ChannelMonitor`] should be made aware of.
14  * 
15  * Because this represents only a small number of updates to the underlying state, it is generally
16  * much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction
17  * updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment
18  * transaction), a single update may reach upwards of 1 MiB in serialized size.
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class ChannelMonitorUpdate extends CommonBase {
22         ChannelMonitorUpdate(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.ChannelMonitorUpdate_free(ptr); }
27         }
28
29         /**
30          * The sequence number of this update. Updates *must* be replayed in-order according to this
31          * sequence number (and updates may panic if they are not). The update_id values are strictly
32          * increasing and increase by one for each new update, with two exceptions specified below.
33          * 
34          * This sequence number is also used to track up to which points updates which returned
35          * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given
36          * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
37          * 
38          * The only instances we allow where update_id values are not strictly increasing have a
39          * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that
40          * will force close the channel by broadcasting the latest commitment transaction or
41          * special post-force-close updates, like providing preimages necessary to claim outputs on the
42          * broadcast commitment transaction. See its docs for more details.
43          * 
44          * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress
45          */
46         public long get_update_id() {
47                 long ret = bindings.ChannelMonitorUpdate_get_update_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The sequence number of this update. Updates *must* be replayed in-order according to this
54          * sequence number (and updates may panic if they are not). The update_id values are strictly
55          * increasing and increase by one for each new update, with two exceptions specified below.
56          * 
57          * This sequence number is also used to track up to which points updates which returned
58          * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given
59          * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
60          * 
61          * The only instances we allow where update_id values are not strictly increasing have a
62          * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that
63          * will force close the channel by broadcasting the latest commitment transaction or
64          * special post-force-close updates, like providing preimages necessary to claim outputs on the
65          * broadcast commitment transaction. See its docs for more details.
66          * 
67          * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress
68          */
69         public void set_update_id(long val) {
70                 bindings.ChannelMonitorUpdate_set_update_id(this.ptr, val);
71                 Reference.reachabilityFence(this);
72                 Reference.reachabilityFence(val);
73         }
74
75         /**
76          * The channel ID associated with these updates.
77          * 
78          * Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and
79          * always `Some` otherwise.
80          * 
81          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
82          */
83         @Nullable
84         public ChannelId get_channel_id() {
85                 long ret = bindings.ChannelMonitorUpdate_get_channel_id(this.ptr);
86                 Reference.reachabilityFence(this);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
90                 return ret_hu_conv;
91         }
92
93         /**
94          * The channel ID associated with these updates.
95          * 
96          * Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and
97          * always `Some` otherwise.
98          * 
99          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
100          */
101         public void set_channel_id(@Nullable org.ldk.structs.ChannelId val) {
102                 bindings.ChannelMonitorUpdate_set_channel_id(this.ptr, val == null ? 0 : val.ptr);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105                 if (this != null) { this.ptrs_to.add(val); };
106         }
107
108         long clone_ptr() {
109                 long ret = bindings.ChannelMonitorUpdate_clone_ptr(this.ptr);
110                 Reference.reachabilityFence(this);
111                 return ret;
112         }
113
114         /**
115          * Creates a copy of the ChannelMonitorUpdate
116          */
117         public ChannelMonitorUpdate clone() {
118                 long ret = bindings.ChannelMonitorUpdate_clone(this.ptr);
119                 Reference.reachabilityFence(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.ChannelMonitorUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelMonitorUpdate(null, ret); }
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Checks if two ChannelMonitorUpdates contain equal inner contents.
128          * This ignores pointers and is_owned flags and looks at the values in fields.
129          * Two objects with NULL inner values will be considered "equal" here.
130          */
131         public boolean eq(org.ldk.structs.ChannelMonitorUpdate b) {
132                 boolean ret = bindings.ChannelMonitorUpdate_eq(this.ptr, b.ptr);
133                 Reference.reachabilityFence(this);
134                 Reference.reachabilityFence(b);
135                 if (this != null) { this.ptrs_to.add(b); };
136                 return ret;
137         }
138
139         @Override public boolean equals(Object o) {
140                 if (!(o instanceof ChannelMonitorUpdate)) return false;
141                 return this.eq((ChannelMonitorUpdate)o);
142         }
143         /**
144          * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read
145          */
146         public byte[] write() {
147                 byte[] ret = bindings.ChannelMonitorUpdate_write(this.ptr);
148                 Reference.reachabilityFence(this);
149                 return ret;
150         }
151
152         /**
153          * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write
154          */
155         public static Result_ChannelMonitorUpdateDecodeErrorZ read(byte[] ser) {
156                 long ret = bindings.ChannelMonitorUpdate_read(ser);
157                 Reference.reachabilityFence(ser);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 Result_ChannelMonitorUpdateDecodeErrorZ ret_hu_conv = Result_ChannelMonitorUpdateDecodeErrorZ.constr_from_ptr(ret);
160                 return ret_hu_conv;
161         }
162
163 }