6 namespace org { namespace ldk { namespace structs {
10 * An [`update_add_htlc`] message to be sent to or received from a peer.
12 * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
14 public class UpdateAddHTLC : CommonBase {
15 internal UpdateAddHTLC(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
23 public byte[] get_channel_id() {
24 long ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
34 public void set_channel_id(byte[] val) {
35 bindings.UpdateAddHTLC_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
43 public long get_htlc_id() {
44 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
52 public void set_htlc_id(long val) {
53 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
59 * The HTLC value in milli-satoshi
61 public long get_amount_msat() {
62 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
68 * The HTLC value in milli-satoshi
70 public void set_amount_msat(long val) {
71 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
77 * The payment hash, the pre-image of which controls HTLC redemption
79 public byte[] get_payment_hash() {
80 long ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
82 if (ret >= 0 && ret <= 4096) { return null; }
83 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
88 * The payment hash, the pre-image of which controls HTLC redemption
90 public void set_payment_hash(byte[] val) {
91 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
97 * The expiry height of the HTLC
99 public int get_cltv_expiry() {
100 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
106 * The expiry height of the HTLC
108 public void set_cltv_expiry(int val) {
109 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
115 * The extra fee skimmed by the sender of this message. See
116 * [`ChannelConfig::accept_underpaying_htlcs`].
118 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
120 public Option_u64Z get_skimmed_fee_msat() {
121 long ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
123 if (ret >= 0 && ret <= 4096) { return null; }
124 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
125 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
130 * The extra fee skimmed by the sender of this message. See
131 * [`ChannelConfig::accept_underpaying_htlcs`].
133 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
135 public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
136 bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, val.ptr);
139 if (this != null) { this.ptrs_to.AddLast(val); };
143 * The onion routing packet with encrypted data for the next hop.
145 public OnionPacket get_onion_routing_packet() {
146 long ret = bindings.UpdateAddHTLC_get_onion_routing_packet(this.ptr);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 org.ldk.structs.OnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionPacket(null, ret); }
150 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
155 * The onion routing packet with encrypted data for the next hop.
157 public void set_onion_routing_packet(org.ldk.structs.OnionPacket val) {
158 bindings.UpdateAddHTLC_set_onion_routing_packet(this.ptr, val == null ? 0 : val.ptr);
161 if (this != null) { this.ptrs_to.AddLast(val); };
165 * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
166 * routing packet and the recipient-provided encrypted payload within.
168 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
170 public byte[] get_blinding_point() {
171 long ret = bindings.UpdateAddHTLC_get_blinding_point(this.ptr);
173 if (ret >= 0 && ret <= 4096) { return null; }
174 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
179 * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
180 * routing packet and the recipient-provided encrypted payload within.
182 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
184 public void set_blinding_point(byte[] val) {
185 bindings.UpdateAddHTLC_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
191 * Constructs a new UpdateAddHTLC given each field
193 * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
195 public static UpdateAddHTLC of(byte[] channel_id_arg, long htlc_id_arg, long amount_msat_arg, byte[] payment_hash_arg, int cltv_expiry_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg, org.ldk.structs.OnionPacket onion_routing_packet_arg, byte[] blinding_point_arg) {
196 long ret = bindings.UpdateAddHTLC_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), htlc_id_arg, amount_msat_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash_arg, 32)), cltv_expiry_arg, skimmed_fee_msat_arg.ptr, onion_routing_packet_arg == null ? 0 : onion_routing_packet_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)));
197 GC.KeepAlive(channel_id_arg);
198 GC.KeepAlive(htlc_id_arg);
199 GC.KeepAlive(amount_msat_arg);
200 GC.KeepAlive(payment_hash_arg);
201 GC.KeepAlive(cltv_expiry_arg);
202 GC.KeepAlive(skimmed_fee_msat_arg);
203 GC.KeepAlive(onion_routing_packet_arg);
204 GC.KeepAlive(blinding_point_arg);
205 if (ret >= 0 && ret <= 4096) { return null; }
206 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
207 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(skimmed_fee_msat_arg); };
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_routing_packet_arg); };
213 internal long clone_ptr() {
214 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
220 * Creates a copy of the UpdateAddHTLC
222 public UpdateAddHTLC clone() {
223 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
225 if (ret >= 0 && ret <= 4096) { return null; }
226 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
227 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
232 * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
235 long ret = bindings.UpdateAddHTLC_hash(this.ptr);
240 public override int GetHashCode() {
241 return (int)this.hash();
244 * Checks if two UpdateAddHTLCs contain equal inner contents.
245 * This ignores pointers and is_owned flags and looks at the values in fields.
246 * Two objects with NULL inner values will be considered "equal" here.
248 public bool eq(org.ldk.structs.UpdateAddHTLC b) {
249 bool ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
252 if (this != null) { this.ptrs_to.AddLast(b); };
256 public override bool Equals(object o) {
257 if (!(o is UpdateAddHTLC)) return false;
258 return this.eq((UpdateAddHTLC)o);
261 * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
263 public byte[] write() {
264 long ret = bindings.UpdateAddHTLC_write(this.ptr);
266 if (ret >= 0 && ret <= 4096) { return null; }
267 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
272 * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
274 public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
275 long ret = bindings.UpdateAddHTLC_read(InternalUtils.encodeUint8Array(ser));
277 if (ret >= 0 && ret <= 4096) { return null; }
278 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);