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 ChannelId get_channel_id() {
24 long ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
35 public void set_channel_id(org.ldk.structs.ChannelId val) {
36 bindings.UpdateAddHTLC_set_channel_id(this.ptr, val.ptr);
39 if (this != null) { this.ptrs_to.AddLast(val); };
45 public long get_htlc_id() {
46 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
54 public void set_htlc_id(long val) {
55 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
61 * The HTLC value in milli-satoshi
63 public long get_amount_msat() {
64 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
70 * The HTLC value in milli-satoshi
72 public void set_amount_msat(long val) {
73 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
79 * The payment hash, the pre-image of which controls HTLC redemption
81 public byte[] get_payment_hash() {
82 long ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
90 * The payment hash, the pre-image of which controls HTLC redemption
92 public void set_payment_hash(byte[] val) {
93 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
99 * The expiry height of the HTLC
101 public int get_cltv_expiry() {
102 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
108 * The expiry height of the HTLC
110 public void set_cltv_expiry(int val) {
111 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
117 * The extra fee skimmed by the sender of this message. See
118 * [`ChannelConfig::accept_underpaying_htlcs`].
120 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
122 public Option_u64Z get_skimmed_fee_msat() {
123 long ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
132 * The extra fee skimmed by the sender of this message. See
133 * [`ChannelConfig::accept_underpaying_htlcs`].
135 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
137 public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
138 bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, val.ptr);
141 if (this != null) { this.ptrs_to.AddLast(val); };
145 * The onion routing packet with encrypted data for the next hop.
147 public OnionPacket get_onion_routing_packet() {
148 long ret = bindings.UpdateAddHTLC_get_onion_routing_packet(this.ptr);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.OnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionPacket(null, ret); }
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
157 * The onion routing packet with encrypted data for the next hop.
159 public void set_onion_routing_packet(org.ldk.structs.OnionPacket val) {
160 bindings.UpdateAddHTLC_set_onion_routing_packet(this.ptr, val.ptr);
163 if (this != null) { this.ptrs_to.AddLast(val); };
167 * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
168 * routing packet and the recipient-provided encrypted payload within.
170 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
172 public byte[] get_blinding_point() {
173 long ret = bindings.UpdateAddHTLC_get_blinding_point(this.ptr);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
181 * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
182 * routing packet and the recipient-provided encrypted payload within.
184 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
186 public void set_blinding_point(byte[] val) {
187 bindings.UpdateAddHTLC_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
193 * Constructs a new UpdateAddHTLC given each field
195 * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
197 public static UpdateAddHTLC of(org.ldk.structs.ChannelId 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) {
198 long ret = bindings.UpdateAddHTLC_new(channel_id_arg.ptr, 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.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)));
199 GC.KeepAlive(channel_id_arg);
200 GC.KeepAlive(htlc_id_arg);
201 GC.KeepAlive(amount_msat_arg);
202 GC.KeepAlive(payment_hash_arg);
203 GC.KeepAlive(cltv_expiry_arg);
204 GC.KeepAlive(skimmed_fee_msat_arg);
205 GC.KeepAlive(onion_routing_packet_arg);
206 GC.KeepAlive(blinding_point_arg);
207 if (ret >= 0 && ret <= 4096) { return null; }
208 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(skimmed_fee_msat_arg); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_routing_packet_arg); };
216 internal long clone_ptr() {
217 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
223 * Creates a copy of the UpdateAddHTLC
225 public UpdateAddHTLC clone() {
226 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
235 * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
238 long ret = bindings.UpdateAddHTLC_hash(this.ptr);
243 public override int GetHashCode() {
244 return (int)this.hash();
247 * Checks if two UpdateAddHTLCs contain equal inner contents.
248 * This ignores pointers and is_owned flags and looks at the values in fields.
249 * Two objects with NULL inner values will be considered "equal" here.
251 public bool eq(org.ldk.structs.UpdateAddHTLC b) {
252 bool ret = bindings.UpdateAddHTLC_eq(this.ptr, b.ptr);
255 if (this != null) { this.ptrs_to.AddLast(b); };
259 public override bool Equals(object o) {
260 if (!(o is UpdateAddHTLC)) return false;
261 return this.eq((UpdateAddHTLC)o);
264 * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
266 public byte[] write() {
267 long ret = bindings.UpdateAddHTLC_write(this.ptr);
269 if (ret >= 0 && ret <= 4096) { return null; }
270 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
275 * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
277 public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
278 long ret = bindings.UpdateAddHTLC_read(InternalUtils.encodeUint8Array(ser));
280 if (ret >= 0 && ret <= 4096) { return null; }
281 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);