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 map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC
13 * is traveling in. The direction boolean is determined by checking if the HTLC source's public
14 * key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class InFlightHtlcs extends CommonBase {
19 InFlightHtlcs(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.InFlightHtlcs_free(ptr); }
27 * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
30 public Option_u64Z used_liquidity_msat(NodeId source, NodeId target, long channel_scid) {
31 long ret = bindings.InFlightHtlcs_used_liquidity_msat(this.ptr, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid);
32 Reference.reachabilityFence(this);
33 Reference.reachabilityFence(source);
34 Reference.reachabilityFence(target);
35 Reference.reachabilityFence(channel_scid);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
39 if (this != null) { this.ptrs_to.add(source); };
40 if (this != null) { this.ptrs_to.add(target); };
45 * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
47 public byte[] write() {
48 byte[] ret = bindings.InFlightHtlcs_write(this.ptr);
49 Reference.reachabilityFence(this);
54 * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
56 public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
57 long ret = bindings.InFlightHtlcs_read(ser);
58 Reference.reachabilityFence(ser);
59 if (ret >= 0 && ret <= 4096) { return null; }
60 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);