[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / InFlightHtlcs.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A data structure for tracking in-flight HTLCs. May be used during pathfinding to account for
11  * in-use channel liquidity.
12  */
13 public class InFlightHtlcs : CommonBase {
14         internal InFlightHtlcs(object _dummy, long ptr) : base(ptr) { }
15         ~InFlightHtlcs() {
16                 if (ptr != 0) { bindings.InFlightHtlcs_free(ptr); }
17         }
18
19         internal long clone_ptr() {
20                 long ret = bindings.InFlightHtlcs_clone_ptr(this.ptr);
21                 GC.KeepAlive(this);
22                 return ret;
23         }
24
25         /**
26          * Creates a copy of the InFlightHtlcs
27          */
28         public InFlightHtlcs clone() {
29                 long ret = bindings.InFlightHtlcs_clone(this.ptr);
30                 GC.KeepAlive(this);
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); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Constructs an empty `InFlightHtlcs`.
39          */
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); };
45                 return ret_hu_conv;
46         }
47
48         /**
49          * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
50          */
51         public void process_path(org.ldk.structs.Path path, byte[] payer_node_id) {
52                 bindings.InFlightHtlcs_process_path(this.ptr, path == null ? 0 : path.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payer_node_id, 33)));
53                 GC.KeepAlive(this);
54                 GC.KeepAlive(path);
55                 GC.KeepAlive(payer_node_id);
56                 if (this != null) { this.ptrs_to.AddLast(path); };
57         }
58
59         /**
60          * Adds a known HTLC given the public key of the HTLC source, target, and short channel
61          * id.
62          */
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 == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid, used_msat);
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(source);
67                 GC.KeepAlive(target);
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); };
72         }
73
74         /**
75          * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
76          * id.
77          */
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 == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid);
80                 GC.KeepAlive(this);
81                 GC.KeepAlive(source);
82                 GC.KeepAlive(target);
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); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
94          */
95         public byte[] write() {
96                 long ret = bindings.InFlightHtlcs_write(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
100                 return ret_conv;
101         }
102
103         /**
104          * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
105          */
106         public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
107                 long ret = bindings.InFlightHtlcs_read(InternalUtils.encodeUint8Array(ser));
108                 GC.KeepAlive(ser);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);
111                 return ret_hu_conv;
112         }
113
114 }
115 } } }