Merge pull request #124 from TheBlueMatt/main
[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          * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
50          * id.
51          */
52         public Option_u64Z used_liquidity_msat(org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, long channel_scid) {
53                 long ret = bindings.InFlightHtlcs_used_liquidity_msat(this.ptr, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, channel_scid);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(source);
56                 GC.KeepAlive(target);
57                 GC.KeepAlive(channel_scid);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
61                 if (this != null) { this.ptrs_to.AddLast(source); };
62                 if (this != null) { this.ptrs_to.AddLast(target); };
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
68          */
69         public byte[] write() {
70                 byte[] ret = bindings.InFlightHtlcs_write(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
77          */
78         public static Result_InFlightHtlcsDecodeErrorZ read(byte[] ser) {
79                 long ret = bindings.InFlightHtlcs_read(ser);
80                 GC.KeepAlive(ser);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 Result_InFlightHtlcsDecodeErrorZ ret_hu_conv = Result_InFlightHtlcsDecodeErrorZ.constr_from_ptr(ret);
83                 return ret_hu_conv;
84         }
85
86 }
87 } } }