6 namespace org { namespace ldk { namespace structs {
10 * Information about an incoming HTLC, including the [`PendingHTLCRouting`] describing where it
13 public class PendingHTLCInfo : CommonBase {
14 internal PendingHTLCInfo(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.PendingHTLCInfo_free(ptr); }
20 * Further routing details based on whether the HTLC is being forwarded or received.
22 public PendingHTLCRouting get_routing() {
23 long ret = bindings.PendingHTLCInfo_get_routing(this.ptr);
25 if (ret >= 0 && ret <= 4096) { return null; }
26 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
27 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
32 * Further routing details based on whether the HTLC is being forwarded or received.
34 public void set_routing(org.ldk.structs.PendingHTLCRouting val) {
35 bindings.PendingHTLCInfo_set_routing(this.ptr, val.ptr);
38 if (this != null) { this.ptrs_to.AddLast(val); };
42 * The onion shared secret we build with the sender used to decrypt the onion.
44 * This is later used to encrypt failure packets in the event that the HTLC is failed.
46 public byte[] get_incoming_shared_secret() {
47 long ret = bindings.PendingHTLCInfo_get_incoming_shared_secret(this.ptr);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
55 * The onion shared secret we build with the sender used to decrypt the onion.
57 * This is later used to encrypt failure packets in the event that the HTLC is failed.
59 public void set_incoming_shared_secret(byte[] val) {
60 bindings.PendingHTLCInfo_set_incoming_shared_secret(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
66 * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
68 public byte[] get_payment_hash() {
69 long ret = bindings.PendingHTLCInfo_get_payment_hash(this.ptr);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
77 * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
79 public void set_payment_hash(byte[] val) {
80 bindings.PendingHTLCInfo_set_payment_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
86 * Amount received in the incoming HTLC.
88 * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
91 public Option_u64Z get_incoming_amt_msat() {
92 long ret = bindings.PendingHTLCInfo_get_incoming_amt_msat(this.ptr);
94 if (ret >= 0 && ret <= 4096) { return null; }
95 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
96 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101 * Amount received in the incoming HTLC.
103 * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
106 public void set_incoming_amt_msat(org.ldk.structs.Option_u64Z val) {
107 bindings.PendingHTLCInfo_set_incoming_amt_msat(this.ptr, val.ptr);
110 if (this != null) { this.ptrs_to.AddLast(val); };
114 * The amount the sender indicated should be forwarded on to the next hop or amount the sender
115 * intended for us to receive for received payments.
117 * If the received amount is less than this for received payments, an intermediary hop has
118 * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
119 * it along another path).
121 * Because nodes can take less than their required fees, and because senders may wish to
122 * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
123 * received payments. In such cases, recipients must handle this HTLC as if it had received
124 * [`Self::outgoing_amt_msat`].
126 public long get_outgoing_amt_msat() {
127 long ret = bindings.PendingHTLCInfo_get_outgoing_amt_msat(this.ptr);
133 * The amount the sender indicated should be forwarded on to the next hop or amount the sender
134 * intended for us to receive for received payments.
136 * If the received amount is less than this for received payments, an intermediary hop has
137 * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
138 * it along another path).
140 * Because nodes can take less than their required fees, and because senders may wish to
141 * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
142 * received payments. In such cases, recipients must handle this HTLC as if it had received
143 * [`Self::outgoing_amt_msat`].
145 public void set_outgoing_amt_msat(long val) {
146 bindings.PendingHTLCInfo_set_outgoing_amt_msat(this.ptr, val);
152 * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
153 * should have been set on the received HTLC for received payments).
155 public int get_outgoing_cltv_value() {
156 int ret = bindings.PendingHTLCInfo_get_outgoing_cltv_value(this.ptr);
162 * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
163 * should have been set on the received HTLC for received payments).
165 public void set_outgoing_cltv_value(int val) {
166 bindings.PendingHTLCInfo_set_outgoing_cltv_value(this.ptr, val);
172 * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
174 * If this is a payment for forwarding, this is the fee we are taking before forwarding the
177 * If this is a received payment, this is the fee that our counterparty took.
179 * This is used to allow LSPs to take fees as a part of payments, without the sender having to
182 public Option_u64Z get_skimmed_fee_msat() {
183 long ret = bindings.PendingHTLCInfo_get_skimmed_fee_msat(this.ptr);
185 if (ret >= 0 && ret <= 4096) { return null; }
186 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
187 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
192 * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
194 * If this is a payment for forwarding, this is the fee we are taking before forwarding the
197 * If this is a received payment, this is the fee that our counterparty took.
199 * This is used to allow LSPs to take fees as a part of payments, without the sender having to
202 public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
203 bindings.PendingHTLCInfo_set_skimmed_fee_msat(this.ptr, val.ptr);
206 if (this != null) { this.ptrs_to.AddLast(val); };
210 * Constructs a new PendingHTLCInfo given each field
212 public static PendingHTLCInfo of(org.ldk.structs.PendingHTLCRouting routing_arg, byte[] incoming_shared_secret_arg, byte[] payment_hash_arg, org.ldk.structs.Option_u64Z incoming_amt_msat_arg, long outgoing_amt_msat_arg, int outgoing_cltv_value_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg) {
213 long ret = bindings.PendingHTLCInfo_new(routing_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(incoming_shared_secret_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash_arg, 32)), incoming_amt_msat_arg.ptr, outgoing_amt_msat_arg, outgoing_cltv_value_arg, skimmed_fee_msat_arg.ptr);
214 GC.KeepAlive(routing_arg);
215 GC.KeepAlive(incoming_shared_secret_arg);
216 GC.KeepAlive(payment_hash_arg);
217 GC.KeepAlive(incoming_amt_msat_arg);
218 GC.KeepAlive(outgoing_amt_msat_arg);
219 GC.KeepAlive(outgoing_cltv_value_arg);
220 GC.KeepAlive(skimmed_fee_msat_arg);
221 if (ret >= 0 && ret <= 4096) { return null; }
222 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
223 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
224 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(routing_arg); };
225 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(incoming_amt_msat_arg); };
226 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(skimmed_fee_msat_arg); };
230 internal long clone_ptr() {
231 long ret = bindings.PendingHTLCInfo_clone_ptr(this.ptr);
237 * Creates a copy of the PendingHTLCInfo
239 public PendingHTLCInfo clone() {
240 long ret = bindings.PendingHTLCInfo_clone(this.ptr);
242 if (ret >= 0 && ret <= 4096) { return null; }
243 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
244 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
249 * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read
251 public byte[] write() {
252 long ret = bindings.PendingHTLCInfo_write(this.ptr);
254 if (ret >= 0 && ret <= 4096) { return null; }
255 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
260 * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write
262 public static Result_PendingHTLCInfoDecodeErrorZ read(byte[] ser) {
263 long ret = bindings.PendingHTLCInfo_read(InternalUtils.encodeUint8Array(ser));
265 if (ret >= 0 && ret <= 4096) { return null; }
266 Result_PendingHTLCInfoDecodeErrorZ ret_hu_conv = Result_PendingHTLCInfoDecodeErrorZ.constr_from_ptr(ret);