[Java] Print error stack trace when tests fail
[ldk-java] / c_sharp / src / org / ldk / structs / ClaimedHTLC.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 /**
10  * Information about an HTLC that is part of a payment that can be claimed.
11  */
12 public class ClaimedHTLC : CommonBase {
13         internal ClaimedHTLC(object _dummy, long ptr) : base(ptr) { }
14         ~ClaimedHTLC() {
15                 if (ptr != 0) { bindings.ClaimedHTLC_free(ptr); }
16         }
17
18         /**
19          * The `channel_id` of the channel over which the HTLC was received.
20          */
21         public ChannelId get_channel_id() {
22                 long ret = bindings.ClaimedHTLC_get_channel_id(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The `channel_id` of the channel over which the HTLC was received.
32          */
33         public void set_channel_id(org.ldk.structs.ChannelId val) {
34                 bindings.ClaimedHTLC_set_channel_id(this.ptr, val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * The `user_channel_id` of the channel over which the HTLC was received. This is the value
42          * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
43          * [`ChannelManager::accept_inbound_channel`] for inbound channels if
44          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
45          * `user_channel_id` will be randomized for an inbound channel.
46          * 
47          * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
48          * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
49          * was not actually claimed until after upgrading.)
50          * 
51          * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
52          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
53          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
54          */
55         public UInt128 get_user_channel_id() {
56                 long ret = bindings.ClaimedHTLC_get_user_channel_id(this.ptr);
57                 GC.KeepAlive(this);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
60                 return ret_conv;
61         }
62
63         /**
64          * The `user_channel_id` of the channel over which the HTLC was received. This is the value
65          * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
66          * [`ChannelManager::accept_inbound_channel`] for inbound channels if
67          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
68          * `user_channel_id` will be randomized for an inbound channel.
69          * 
70          * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
71          * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
72          * was not actually claimed until after upgrading.)
73          * 
74          * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
75          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
76          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
77          */
78         public void set_user_channel_id(org.ldk.util.UInt128 val) {
79                 bindings.ClaimedHTLC_set_user_channel_id(this.ptr, InternalUtils.encodeUint8Array(val.getLEBytes()));
80                 GC.KeepAlive(this);
81                 GC.KeepAlive(val);
82         }
83
84         /**
85          * The block height at which this HTLC expires.
86          */
87         public int get_cltv_expiry() {
88                 int ret = bindings.ClaimedHTLC_get_cltv_expiry(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
91         }
92
93         /**
94          * The block height at which this HTLC expires.
95          */
96         public void set_cltv_expiry(int val) {
97                 bindings.ClaimedHTLC_set_cltv_expiry(this.ptr, val);
98                 GC.KeepAlive(this);
99                 GC.KeepAlive(val);
100         }
101
102         /**
103          * The amount (in msats) of this part of an MPP.
104          */
105         public long get_value_msat() {
106                 long ret = bindings.ClaimedHTLC_get_value_msat(this.ptr);
107                 GC.KeepAlive(this);
108                 return ret;
109         }
110
111         /**
112          * The amount (in msats) of this part of an MPP.
113          */
114         public void set_value_msat(long val) {
115                 bindings.ClaimedHTLC_set_value_msat(this.ptr, val);
116                 GC.KeepAlive(this);
117                 GC.KeepAlive(val);
118         }
119
120         /**
121          * The extra fee our counterparty skimmed off the top of this HTLC, if any.
122          * 
123          * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to
124          * 0.0.119.
125          */
126         public long get_counterparty_skimmed_fee_msat() {
127                 long ret = bindings.ClaimedHTLC_get_counterparty_skimmed_fee_msat(this.ptr);
128                 GC.KeepAlive(this);
129                 return ret;
130         }
131
132         /**
133          * The extra fee our counterparty skimmed off the top of this HTLC, if any.
134          * 
135          * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to
136          * 0.0.119.
137          */
138         public void set_counterparty_skimmed_fee_msat(long val) {
139                 bindings.ClaimedHTLC_set_counterparty_skimmed_fee_msat(this.ptr, val);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(val);
142         }
143
144         /**
145          * Constructs a new ClaimedHTLC given each field
146          */
147         public static ClaimedHTLC of(org.ldk.structs.ChannelId channel_id_arg, org.ldk.util.UInt128 user_channel_id_arg, int cltv_expiry_arg, long value_msat_arg, long counterparty_skimmed_fee_msat_arg) {
148                 long ret = bindings.ClaimedHTLC_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(user_channel_id_arg.getLEBytes()), cltv_expiry_arg, value_msat_arg, counterparty_skimmed_fee_msat_arg);
149                 GC.KeepAlive(channel_id_arg);
150                 GC.KeepAlive(user_channel_id_arg);
151                 GC.KeepAlive(cltv_expiry_arg);
152                 GC.KeepAlive(value_msat_arg);
153                 GC.KeepAlive(counterparty_skimmed_fee_msat_arg);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
158                 return ret_hu_conv;
159         }
160
161         internal long clone_ptr() {
162                 long ret = bindings.ClaimedHTLC_clone_ptr(this.ptr);
163                 GC.KeepAlive(this);
164                 return ret;
165         }
166
167         /**
168          * Creates a copy of the ClaimedHTLC
169          */
170         public ClaimedHTLC clone() {
171                 long ret = bindings.ClaimedHTLC_clone(this.ptr);
172                 GC.KeepAlive(this);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
175                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Checks if two ClaimedHTLCs contain equal inner contents.
181          * This ignores pointers and is_owned flags and looks at the values in fields.
182          * Two objects with NULL inner values will be considered "equal" here.
183          */
184         public bool eq(org.ldk.structs.ClaimedHTLC b) {
185                 bool ret = bindings.ClaimedHTLC_eq(this.ptr, b.ptr);
186                 GC.KeepAlive(this);
187                 GC.KeepAlive(b);
188                 if (this != null) { this.ptrs_to.AddLast(b); };
189                 return ret;
190         }
191
192         public override bool Equals(object o) {
193                 if (!(o is ClaimedHTLC)) return false;
194                 return this.eq((ClaimedHTLC)o);
195         }
196         /**
197          * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
198          */
199         public byte[] write() {
200                 long ret = bindings.ClaimedHTLC_write(this.ptr);
201                 GC.KeepAlive(this);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
204                 return ret_conv;
205         }
206
207         /**
208          * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
209          */
210         public static Result_ClaimedHTLCDecodeErrorZ read(byte[] ser) {
211                 long ret = bindings.ClaimedHTLC_read(InternalUtils.encodeUint8Array(ser));
212                 GC.KeepAlive(ser);
213                 if (ret >= 0 && ret <= 4096) { return null; }
214                 Result_ClaimedHTLCDecodeErrorZ ret_hu_conv = Result_ClaimedHTLCDecodeErrorZ.constr_from_ptr(ret);
215                 return ret_hu_conv;
216         }
217
218 }
219 } } }