35c04630acba2b25284177eb671f411eac43bc92
[ldk-java] / c_sharp / src / org / ldk / structs / RouteParameters.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  * Parameters needed to find a [`Route`].
11  * 
12  * Passed to [`find_route`] and [`build_route_from_hops`].
13  */
14 public class RouteParameters : CommonBase {
15         internal RouteParameters(object _dummy, long ptr) : base(ptr) { }
16         ~RouteParameters() {
17                 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
18         }
19
20         /**
21          * The parameters of the failed payment path.
22          */
23         public PaymentParameters get_payment_params() {
24                 long ret = bindings.RouteParameters_get_payment_params(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The parameters of the failed payment path.
34          */
35         public void set_payment_params(org.ldk.structs.PaymentParameters val) {
36                 bindings.RouteParameters_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The amount in msats sent on the failed payment path.
44          */
45         public long get_final_value_msat() {
46                 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The amount in msats sent on the failed payment path.
53          */
54         public void set_final_value_msat(long val) {
55                 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * Constructs a new RouteParameters given each field
62          */
63         public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg) {
64                 long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg);
65                 GC.KeepAlive(payment_params_arg);
66                 GC.KeepAlive(final_value_msat_arg);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params_arg); };
71                 return ret_hu_conv;
72         }
73
74         internal long clone_ptr() {
75                 long ret = bindings.RouteParameters_clone_ptr(this.ptr);
76                 GC.KeepAlive(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the RouteParameters
82          */
83         public RouteParameters clone() {
84                 long ret = bindings.RouteParameters_clone(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Checks if two RouteParameterss contain equal inner contents.
94          * This ignores pointers and is_owned flags and looks at the values in fields.
95          * Two objects with NULL inner values will be considered "equal" here.
96          */
97         public bool eq(org.ldk.structs.RouteParameters b) {
98                 bool ret = bindings.RouteParameters_eq(this.ptr, b == null ? 0 : b.ptr);
99                 GC.KeepAlive(this);
100                 GC.KeepAlive(b);
101                 if (this != null) { this.ptrs_to.AddLast(b); };
102                 return ret;
103         }
104
105         public override bool Equals(object o) {
106                 if (!(o is RouteParameters)) return false;
107                 return this.eq((RouteParameters)o);
108         }
109         /**
110          * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
111          */
112         public byte[] write() {
113                 byte[] ret = bindings.RouteParameters_write(this.ptr);
114                 GC.KeepAlive(this);
115                 return ret;
116         }
117
118         /**
119          * Read a RouteParameters from a byte array, created by RouteParameters_write
120          */
121         public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.RouteParameters_read(ser);
123                 GC.KeepAlive(ser);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129 }
130 } } }