[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / InFlightHtlcs.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A data structure for tracking in-flight HTLCs. May be used during pathfinding to account for
13  * in-use channel liquidity.
14  */
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 {
20                 super.finalize();
21                 if (ptr != 0) { bindings.InFlightHtlcs_free(ptr); }
22         }
23
24         long clone_ptr() {
25                 long ret = bindings.InFlightHtlcs_clone_ptr(this.ptr);
26                 Reference.reachabilityFence(this);
27                 return ret;
28         }
29
30         /**
31          * Creates a copy of the InFlightHtlcs
32          */
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); };
39                 return ret_hu_conv;
40         }
41
42         /**
43          * Constructs an empty `InFlightHtlcs`.
44          */
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); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
55          */
56         public void process_path(org.ldk.structs.Path path, byte[] payer_node_id) {
57                 bindings.InFlightHtlcs_process_path(this.ptr, path == null ? 0 : path.ptr, InternalUtils.check_arr_len(payer_node_id, 33));
58                 Reference.reachabilityFence(this);
59                 Reference.reachabilityFence(path);
60                 Reference.reachabilityFence(payer_node_id);
61                 if (this != null) { this.ptrs_to.add(path); };
62         }
63
64         /**
65          * Adds a known HTLC given the public key of the HTLC source, target, and short channel
66          * id.
67          */
68         public void add_inflight_htlc(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid, long used_msat) {
69                 bindings.InFlightHtlcs_add_inflight_htlc(this.ptr, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid, used_msat);
70                 Reference.reachabilityFence(this);
71                 Reference.reachabilityFence(source);
72                 Reference.reachabilityFence(target);
73                 Reference.reachabilityFence(channel_scid);
74                 Reference.reachabilityFence(used_msat);
75                 if (this != null) { this.ptrs_to.add(source); };
76                 if (this != null) { this.ptrs_to.add(target); };
77         }
78
79         /**
80          * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
81          * id.
82          */
83         public Option_u64Z used_liquidity_msat(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid) {
84                 long ret = bindings.InFlightHtlcs_used_liquidity_msat(this.ptr, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid);
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(source);
87                 Reference.reachabilityFence(target);
88                 Reference.reachabilityFence(channel_scid);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92                 if (this != null) { this.ptrs_to.add(source); };
93                 if (this != null) { this.ptrs_to.add(target); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
99          */
100         public byte[] write() {
101                 byte[] ret = bindings.InFlightHtlcs_write(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
108          */
109         public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
110                 long ret = bindings.InFlightHtlcs_read(ser);
111                 Reference.reachabilityFence(ser);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);
114                 return ret_hu_conv;
115         }
116
117 }