1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Information about an HTLC that is part of a payment that can be claimed.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ClaimedHTLC extends CommonBase {
16 ClaimedHTLC(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ClaimedHTLC_free(ptr); }
24 * The `channel_id` of the channel over which the HTLC was received.
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.ClaimedHTLC_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The `channel_id` of the channel over which the HTLC was received.
35 public void set_channel_id(byte[] val) {
36 bindings.ClaimedHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The `user_channel_id` of the channel over which the HTLC was received. This is the value
43 * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
44 * [`ChannelManager::accept_inbound_channel`] for inbound channels if
45 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
46 * `user_channel_id` will be randomized for an inbound channel.
48 * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
49 * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
50 * was not actually claimed until after upgrading.)
52 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
53 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
54 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
56 public UInt128 get_user_channel_id() {
57 byte[] ret = bindings.ClaimedHTLC_get_user_channel_id(this.ptr);
58 Reference.reachabilityFence(this);
59 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
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.
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.)
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
78 public void set_user_channel_id(org.ldk.util.UInt128 val) {
79 bindings.ClaimedHTLC_set_user_channel_id(this.ptr, val.getLEBytes());
80 Reference.reachabilityFence(this);
81 Reference.reachabilityFence(val);
85 * The block height at which this HTLC expires.
87 public int get_cltv_expiry() {
88 int ret = bindings.ClaimedHTLC_get_cltv_expiry(this.ptr);
89 Reference.reachabilityFence(this);
94 * The block height at which this HTLC expires.
96 public void set_cltv_expiry(int val) {
97 bindings.ClaimedHTLC_set_cltv_expiry(this.ptr, val);
98 Reference.reachabilityFence(this);
99 Reference.reachabilityFence(val);
103 * The amount (in msats) of this part of an MPP.
105 public long get_value_msat() {
106 long ret = bindings.ClaimedHTLC_get_value_msat(this.ptr);
107 Reference.reachabilityFence(this);
112 * The amount (in msats) of this part of an MPP.
114 public void set_value_msat(long val) {
115 bindings.ClaimedHTLC_set_value_msat(this.ptr, val);
116 Reference.reachabilityFence(this);
117 Reference.reachabilityFence(val);
121 * Constructs a new ClaimedHTLC given each field
123 public static ClaimedHTLC of(byte[] channel_id_arg, org.ldk.util.UInt128 user_channel_id_arg, int cltv_expiry_arg, long value_msat_arg) {
124 long ret = bindings.ClaimedHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), user_channel_id_arg.getLEBytes(), cltv_expiry_arg, value_msat_arg);
125 Reference.reachabilityFence(channel_id_arg);
126 Reference.reachabilityFence(user_channel_id_arg);
127 Reference.reachabilityFence(cltv_expiry_arg);
128 Reference.reachabilityFence(value_msat_arg);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
136 long ret = bindings.ClaimedHTLC_clone_ptr(this.ptr);
137 Reference.reachabilityFence(this);
142 * Creates a copy of the ClaimedHTLC
144 public ClaimedHTLC clone() {
145 long ret = bindings.ClaimedHTLC_clone(this.ptr);
146 Reference.reachabilityFence(this);
147 if (ret >= 0 && ret <= 4096) { return null; }
148 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
149 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
154 * Checks if two ClaimedHTLCs contain equal inner contents.
155 * This ignores pointers and is_owned flags and looks at the values in fields.
156 * Two objects with NULL inner values will be considered "equal" here.
158 public boolean eq(org.ldk.structs.ClaimedHTLC b) {
159 boolean ret = bindings.ClaimedHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
160 Reference.reachabilityFence(this);
161 Reference.reachabilityFence(b);
162 if (this != null) { this.ptrs_to.add(b); };
166 @Override public boolean equals(Object o) {
167 if (!(o instanceof ClaimedHTLC)) return false;
168 return this.eq((ClaimedHTLC)o);
171 * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
173 public byte[] write() {
174 byte[] ret = bindings.ClaimedHTLC_write(this.ptr);
175 Reference.reachabilityFence(this);
180 * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
182 public static Result_ClaimedHTLCDecodeErrorZ read(byte[] ser) {
183 long ret = bindings.ClaimedHTLC_read(ser);
184 Reference.reachabilityFence(ser);
185 if (ret >= 0 && ret <= 4096) { return null; }
186 Result_ClaimedHTLCDecodeErrorZ ret_hu_conv = Result_ClaimedHTLCDecodeErrorZ.constr_from_ptr(ret);