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 * A data structure for tracking in-flight HTLCs. May be used during pathfinding to account for
13 * in-use channel liquidity.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class InFlightHtlcs extends CommonBase {
17 InFlightHtlcs(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.InFlightHtlcs_free(ptr); }
25 long ret = bindings.InFlightHtlcs_clone_ptr(this.ptr);
26 Reference.reachabilityFence(this);
31 * Creates a copy of the InFlightHtlcs
33 public InFlightHtlcs clone() {
34 long ret = bindings.InFlightHtlcs_clone(this.ptr);
35 Reference.reachabilityFence(this);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
43 * Constructs an empty `InFlightHtlcs`.
45 public static InFlightHtlcs of() {
46 long ret = bindings.InFlightHtlcs_new();
47 if (ret >= 0 && ret <= 4096) { return null; }
48 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
49 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
54 * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
57 public Option_u64Z used_liquidity_msat(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid) {
58 long ret = bindings.InFlightHtlcs_used_liquidity_msat(this.ptr, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(source);
61 Reference.reachabilityFence(target);
62 Reference.reachabilityFence(channel_scid);
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
65 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
66 if (this != null) { this.ptrs_to.add(source); };
67 if (this != null) { this.ptrs_to.add(target); };
72 * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
74 public byte[] write() {
75 byte[] ret = bindings.InFlightHtlcs_write(this.ptr);
76 Reference.reachabilityFence(this);
81 * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
83 public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
84 long ret = bindings.InFlightHtlcs_read(ser);
85 Reference.reachabilityFence(ser);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);