[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Path.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 path in a [`Route`] to the payment recipient. Must always be at least length one.
11  * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19.
12  */
13 public class Path : CommonBase {
14         internal Path(object _dummy, long ptr) : base(ptr) { }
15         ~Path() {
16                 if (ptr != 0) { bindings.Path_free(ptr); }
17         }
18
19         /**
20          * The list of unblinded hops in this [`Path`]. Must be at least length one.
21          */
22         public RouteHop[] get_hops() {
23                 long ret = bindings.Path_get_hops(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 int ret_conv_10_len = InternalUtils.getArrayLength(ret);
27                 RouteHop[] ret_conv_10_arr = new RouteHop[ret_conv_10_len];
28                 for (int k = 0; k < ret_conv_10_len; k++) {
29                         long ret_conv_10 = InternalUtils.getU64ArrayElem(ret, k);
30                         org.ldk.structs.RouteHop ret_conv_10_hu_conv = null; if (ret_conv_10 < 0 || ret_conv_10 > 4096) { ret_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, ret_conv_10); }
31                         if (ret_conv_10_hu_conv != null) { ret_conv_10_hu_conv.ptrs_to.AddLast(this); };
32                         ret_conv_10_arr[k] = ret_conv_10_hu_conv;
33                 }
34                 bindings.free_buffer(ret);
35                 return ret_conv_10_arr;
36         }
37
38         /**
39          * The list of unblinded hops in this [`Path`]. Must be at least length one.
40          */
41         public void set_hops(RouteHop[] val) {
42                 bindings.Path_set_hops(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_10 => val_conv_10 == null ? 0 : val_conv_10.ptr)));
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45                 foreach (RouteHop val_conv_10 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_10); }; };
46         }
47
48         /**
49          * The blinded path at which this path terminates, if we're sending to one, and its metadata.
50          * 
51          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
52          */
53         public BlindedTail get_blinded_tail() {
54                 long ret = bindings.Path_get_blinded_tail(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.BlindedTail ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedTail(null, ret); }
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * The blinded path at which this path terminates, if we're sending to one, and its metadata.
64          * 
65          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
66          */
67         public void set_blinded_tail(org.ldk.structs.BlindedTail val) {
68                 bindings.Path_set_blinded_tail(this.ptr, val == null ? 0 : val.ptr);
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(val);
71                 if (this != null) { this.ptrs_to.AddLast(val); };
72         }
73
74         /**
75          * Constructs a new Path given each field
76          * 
77          * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
78          */
79         public static Path of(RouteHop[] hops_arg, org.ldk.structs.BlindedTail blinded_tail_arg) {
80                 long ret = bindings.Path_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(hops_arg, hops_arg_conv_10 => hops_arg_conv_10 == null ? 0 : hops_arg_conv_10.ptr)), blinded_tail_arg == null ? 0 : blinded_tail_arg.ptr);
81                 GC.KeepAlive(hops_arg);
82                 GC.KeepAlive(blinded_tail_arg);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 org.ldk.structs.Path ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Path(null, ret); }
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
86                 foreach (RouteHop hops_arg_conv_10 in hops_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(hops_arg_conv_10); }; };
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(blinded_tail_arg); };
88                 return ret_hu_conv;
89         }
90
91         internal long clone_ptr() {
92                 long ret = bindings.Path_clone_ptr(this.ptr);
93                 GC.KeepAlive(this);
94                 return ret;
95         }
96
97         /**
98          * Creates a copy of the Path
99          */
100         public Path clone() {
101                 long ret = bindings.Path_clone(this.ptr);
102                 GC.KeepAlive(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.Path ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Path(null, ret); }
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Generates a non-cryptographic 64-bit hash of the Path.
111          */
112         public long hash() {
113                 long ret = bindings.Path_hash(this.ptr);
114                 GC.KeepAlive(this);
115                 return ret;
116         }
117
118         public override int GetHashCode() {
119                 return (int)this.hash();
120         }
121         /**
122          * Checks if two Paths contain equal inner contents.
123          * This ignores pointers and is_owned flags and looks at the values in fields.
124          * Two objects with NULL inner values will be considered "equal" here.
125          */
126         public bool eq(org.ldk.structs.Path b) {
127                 bool ret = bindings.Path_eq(this.ptr, b == null ? 0 : b.ptr);
128                 GC.KeepAlive(this);
129                 GC.KeepAlive(b);
130                 if (this != null) { this.ptrs_to.AddLast(b); };
131                 return ret;
132         }
133
134         public override bool Equals(object o) {
135                 if (!(o is Path)) return false;
136                 return this.eq((Path)o);
137         }
138         /**
139          * Gets the fees for a given path, excluding any excess paid to the recipient.
140          */
141         public long fee_msat() {
142                 long ret = bindings.Path_fee_msat(this.ptr);
143                 GC.KeepAlive(this);
144                 return ret;
145         }
146
147         /**
148          * Gets the total amount paid on this [`Path`], excluding the fees.
149          */
150         public long final_value_msat() {
151                 long ret = bindings.Path_final_value_msat(this.ptr);
152                 GC.KeepAlive(this);
153                 return ret;
154         }
155
156         /**
157          * Gets the final hop's CLTV expiry delta.
158          */
159         public Option_u32Z final_cltv_expiry_delta() {
160                 long ret = bindings.Path_final_cltv_expiry_delta(this.ptr);
161                 GC.KeepAlive(this);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret);
164                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
165                 return ret_hu_conv;
166         }
167
168 }
169 } } }