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