6 namespace org { namespace ldk { namespace structs {
10 * Information about an HTLC that is part of a payment that can be claimed.
12 public class ClaimedHTLC : CommonBase {
13 internal ClaimedHTLC(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.ClaimedHTLC_free(ptr); }
19 * The `channel_id` of the channel over which the HTLC was received.
21 public byte[] get_channel_id() {
22 long ret = bindings.ClaimedHTLC_get_channel_id(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30 * The `channel_id` of the channel over which the HTLC was received.
32 public void set_channel_id(byte[] val) {
33 bindings.ClaimedHTLC_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
39 * The `user_channel_id` of the channel over which the HTLC was received. This is the value
40 * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
41 * [`ChannelManager::accept_inbound_channel`] for inbound channels if
42 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
43 * `user_channel_id` will be randomized for an inbound channel.
45 * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
46 * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
47 * was not actually claimed until after upgrading.)
49 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
50 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
51 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
53 public UInt128 get_user_channel_id() {
54 long ret = bindings.ClaimedHTLC_get_user_channel_id(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
62 * The `user_channel_id` of the channel over which the HTLC was received. This is the value
63 * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
64 * [`ChannelManager::accept_inbound_channel`] for inbound channels if
65 * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
66 * `user_channel_id` will be randomized for an inbound channel.
68 * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
69 * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
70 * was not actually claimed until after upgrading.)
72 * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
73 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
74 * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
76 public void set_user_channel_id(org.ldk.util.UInt128 val) {
77 bindings.ClaimedHTLC_set_user_channel_id(this.ptr, InternalUtils.encodeUint8Array(val.getLEBytes()));
83 * The block height at which this HTLC expires.
85 public int get_cltv_expiry() {
86 int ret = bindings.ClaimedHTLC_get_cltv_expiry(this.ptr);
92 * The block height at which this HTLC expires.
94 public void set_cltv_expiry(int val) {
95 bindings.ClaimedHTLC_set_cltv_expiry(this.ptr, val);
101 * The amount (in msats) of this part of an MPP.
103 public long get_value_msat() {
104 long ret = bindings.ClaimedHTLC_get_value_msat(this.ptr);
110 * The amount (in msats) of this part of an MPP.
112 public void set_value_msat(long val) {
113 bindings.ClaimedHTLC_set_value_msat(this.ptr, val);
119 * Constructs a new ClaimedHTLC given each field
121 public static ClaimedHTLC of(byte[] channel_id_arg, org.ldk.util.UInt128 user_channel_id_arg, int cltv_expiry_arg, long value_msat_arg) {
122 long ret = bindings.ClaimedHTLC_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeUint8Array(user_channel_id_arg.getLEBytes()), cltv_expiry_arg, value_msat_arg);
123 GC.KeepAlive(channel_id_arg);
124 GC.KeepAlive(user_channel_id_arg);
125 GC.KeepAlive(cltv_expiry_arg);
126 GC.KeepAlive(value_msat_arg);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
133 internal long clone_ptr() {
134 long ret = bindings.ClaimedHTLC_clone_ptr(this.ptr);
140 * Creates a copy of the ClaimedHTLC
142 public ClaimedHTLC clone() {
143 long ret = bindings.ClaimedHTLC_clone(this.ptr);
145 if (ret >= 0 && ret <= 4096) { return null; }
146 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
152 * Checks if two ClaimedHTLCs contain equal inner contents.
153 * This ignores pointers and is_owned flags and looks at the values in fields.
154 * Two objects with NULL inner values will be considered "equal" here.
156 public bool eq(org.ldk.structs.ClaimedHTLC b) {
157 bool ret = bindings.ClaimedHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
160 if (this != null) { this.ptrs_to.AddLast(b); };
164 public override bool Equals(object o) {
165 if (!(o is ClaimedHTLC)) return false;
166 return this.eq((ClaimedHTLC)o);
169 * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
171 public byte[] write() {
172 long ret = bindings.ClaimedHTLC_write(this.ptr);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
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(InternalUtils.encodeUint8Array(ser));
185 if (ret >= 0 && ret <= 4096) { return null; }
186 Result_ClaimedHTLCDecodeErrorZ ret_hu_conv = Result_ClaimedHTLCDecodeErrorZ.constr_from_ptr(ret);