1fa7af7a79f994a3d3d5df657a9124c9dda7acbc
[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`], but also provided in
13  * [`Event::PaymentPathFailed`] for retrying a failed payment path.
14  * 
15  * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
16  */
17 public class RouteParameters : CommonBase {
18         internal RouteParameters(object _dummy, long ptr) : base(ptr) { }
19         ~RouteParameters() {
20                 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
21         }
22
23         /**
24          * The parameters of the failed payment path.
25          */
26         public PaymentParameters get_payment_params() {
27                 long ret = bindings.RouteParameters_get_payment_params(this.ptr);
28                 GC.KeepAlive(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The parameters of the failed payment path.
37          */
38         public void set_payment_params(org.ldk.structs.PaymentParameters val) {
39                 bindings.RouteParameters_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
40                 GC.KeepAlive(this);
41                 GC.KeepAlive(val);
42                 if (this != null) { this.ptrs_to.AddLast(val); };
43         }
44
45         /**
46          * The amount in msats sent on the failed payment path.
47          */
48         public long get_final_value_msat() {
49                 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
50                 GC.KeepAlive(this);
51                 return ret;
52         }
53
54         /**
55          * The amount in msats sent on the failed payment path.
56          */
57         public void set_final_value_msat(long val) {
58                 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
59                 GC.KeepAlive(this);
60                 GC.KeepAlive(val);
61         }
62
63         /**
64          * The CLTV on the final hop of the failed payment path.
65          */
66         public int get_final_cltv_expiry_delta() {
67                 int ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr);
68                 GC.KeepAlive(this);
69                 return ret;
70         }
71
72         /**
73          * The CLTV on the final hop of the failed payment path.
74          */
75         public void set_final_cltv_expiry_delta(int val) {
76                 bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val);
77                 GC.KeepAlive(this);
78                 GC.KeepAlive(val);
79         }
80
81         /**
82          * Constructs a new RouteParameters given each field
83          */
84         public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg, int final_cltv_expiry_delta_arg) {
85                 long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg, final_cltv_expiry_delta_arg);
86                 GC.KeepAlive(payment_params_arg);
87                 GC.KeepAlive(final_value_msat_arg);
88                 GC.KeepAlive(final_cltv_expiry_delta_arg);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params_arg); };
93                 return ret_hu_conv;
94         }
95
96         internal long clone_ptr() {
97                 long ret = bindings.RouteParameters_clone_ptr(this.ptr);
98                 GC.KeepAlive(this);
99                 return ret;
100         }
101
102         /**
103          * Creates a copy of the RouteParameters
104          */
105         public RouteParameters clone() {
106                 long ret = bindings.RouteParameters_clone(this.ptr);
107                 GC.KeepAlive(this);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
116          */
117         public byte[] write() {
118                 byte[] ret = bindings.RouteParameters_write(this.ptr);
119                 GC.KeepAlive(this);
120                 return ret;
121         }
122
123         /**
124          * Read a RouteParameters from a byte array, created by RouteParameters_write
125          */
126         public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
127                 long ret = bindings.RouteParameters_read(ser);
128                 GC.KeepAlive(ser);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
131                 return ret_hu_conv;
132         }
133
134 }
135 } } }