6 namespace org { namespace ldk { namespace structs {
10 * A data structure for tracking in-flight HTLCs. May be used during pathfinding to account for
11 * in-use channel liquidity.
13 public class InFlightHtlcs : CommonBase {
14 internal InFlightHtlcs(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.InFlightHtlcs_free(ptr); }
19 internal long clone_ptr() {
20 long ret = bindings.InFlightHtlcs_clone_ptr(this.ptr);
26 * Creates a copy of the InFlightHtlcs
28 public InFlightHtlcs clone() {
29 long ret = bindings.InFlightHtlcs_clone(this.ptr);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
38 * Constructs an empty `InFlightHtlcs`.
40 public static InFlightHtlcs of() {
41 long ret = bindings.InFlightHtlcs_new();
42 if (ret >= 0 && ret <= 4096) { return null; }
43 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
44 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
49 * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
51 public void process_path(org.ldk.structs.Path path, byte[] payer_node_id) {
52 bindings.InFlightHtlcs_process_path(this.ptr, path.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payer_node_id, 33)));
55 GC.KeepAlive(payer_node_id);
56 if (this != null) { this.ptrs_to.AddLast(path); };
60 * Adds a known HTLC given the public key of the HTLC source, target, and short channel
63 public void add_inflight_htlc(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid, long used_msat) {
64 bindings.InFlightHtlcs_add_inflight_htlc(this.ptr, source.ptr, target.ptr, channel_scid, used_msat);
68 GC.KeepAlive(channel_scid);
69 GC.KeepAlive(used_msat);
70 if (this != null) { this.ptrs_to.AddLast(source); };
71 if (this != null) { this.ptrs_to.AddLast(target); };
75 * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
78 public Option_u64Z used_liquidity_msat(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid) {
79 long ret = bindings.InFlightHtlcs_used_liquidity_msat(this.ptr, source.ptr, target.ptr, channel_scid);
83 GC.KeepAlive(channel_scid);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
86 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87 if (this != null) { this.ptrs_to.AddLast(source); };
88 if (this != null) { this.ptrs_to.AddLast(target); };
93 * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
95 public byte[] write() {
96 long ret = bindings.InFlightHtlcs_write(this.ptr);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
104 * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
106 public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
107 long ret = bindings.InFlightHtlcs_read(InternalUtils.encodeUint8Array(ser));
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);