6 namespace org { namespace ldk { namespace structs {
10 * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
11 * it can take multiple paths. Each path is composed of one or more hops through the network.
13 public class Route : CommonBase {
14 internal Route(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.Route_free(ptr); }
20 * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
21 * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT
22 * INCLUDING our own, where the last hop is the destination. Thus, this must always be at
23 * least length one. While the maximum length of any given path is variable, keeping the length
24 * of any path less or equal to 19 should currently ensure it is viable.
26 public RouteHop[][] get_paths() {
27 long[][] ret = bindings.Route_get_paths(this.ptr);
29 int ret_conv_12_len = ret.Length;
30 RouteHop[][] ret_conv_12_arr = new RouteHop[ret_conv_12_len][];
31 for (int m = 0; m < ret_conv_12_len; m++) {
32 long[] ret_conv_12 = ret[m];
33 int ret_conv_12_conv_10_len = ret_conv_12.Length;
34 RouteHop[] ret_conv_12_conv_10_arr = new RouteHop[ret_conv_12_conv_10_len];
35 for (int k = 0; k < ret_conv_12_conv_10_len; k++) {
36 long ret_conv_12_conv_10 = ret_conv_12[k];
37 org.ldk.structs.RouteHop ret_conv_12_conv_10_hu_conv = null; if (ret_conv_12_conv_10 < 0 || ret_conv_12_conv_10 > 4096) { ret_conv_12_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, ret_conv_12_conv_10); }
38 if (ret_conv_12_conv_10_hu_conv != null) { ret_conv_12_conv_10_hu_conv.ptrs_to.AddLast(this); };
39 ret_conv_12_conv_10_arr[k] = ret_conv_12_conv_10_hu_conv;
41 ret_conv_12_arr[m] = ret_conv_12_conv_10_arr;
43 return ret_conv_12_arr;
47 * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
48 * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT
49 * INCLUDING our own, where the last hop is the destination. Thus, this must always be at
50 * least length one. While the maximum length of any given path is variable, keeping the length
51 * of any path less or equal to 19 should currently ensure it is viable.
53 public void set_paths(RouteHop[][] val) {
54 bindings.Route_set_paths(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_12 => val_conv_12 != null ? InternalUtils.mapArray(val_conv_12, val_conv_12_conv_10 => val_conv_12_conv_10 == null ? 0 : val_conv_12_conv_10.ptr) : null) : null);
57 foreach (RouteHop[] val_conv_12 in val) { foreach (RouteHop val_conv_12_conv_10 in val_conv_12) { if (this != null) { this.ptrs_to.AddLast(val_conv_12_conv_10); }; }; };
61 * The `payment_params` parameter passed to [`find_route`].
62 * This is used by `ChannelManager` to track information which may be required for retries,
63 * provided back to you via [`Event::PaymentPathFailed`].
65 * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
67 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
69 public PaymentParameters get_payment_params() {
70 long ret = bindings.Route_get_payment_params(this.ptr);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
79 * The `payment_params` parameter passed to [`find_route`].
80 * This is used by `ChannelManager` to track information which may be required for retries,
81 * provided back to you via [`Event::PaymentPathFailed`].
83 * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
85 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
87 public void set_payment_params(org.ldk.structs.PaymentParameters val) {
88 bindings.Route_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
91 if (this != null) { this.ptrs_to.AddLast(val); };
95 * Constructs a new Route given each field
97 public static Route of(RouteHop[][] paths_arg, org.ldk.structs.PaymentParameters payment_params_arg) {
98 long ret = bindings.Route_new(paths_arg != null ? InternalUtils.mapArray(paths_arg, paths_arg_conv_12 => paths_arg_conv_12 != null ? InternalUtils.mapArray(paths_arg_conv_12, paths_arg_conv_12_conv_10 => paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr) : null) : null, payment_params_arg == null ? 0 : payment_params_arg.ptr);
99 GC.KeepAlive(paths_arg);
100 GC.KeepAlive(payment_params_arg);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Route(null, ret); }
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
104 foreach (RouteHop[] paths_arg_conv_12 in paths_arg) { foreach (RouteHop paths_arg_conv_12_conv_10 in paths_arg_conv_12) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(paths_arg_conv_12_conv_10); }; }; };
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params_arg); };
109 internal long clone_ptr() {
110 long ret = bindings.Route_clone_ptr(this.ptr);
116 * Creates a copy of the Route
118 public Route clone() {
119 long ret = bindings.Route_clone(this.ptr);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 org.ldk.structs.Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Route(null, ret); }
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
128 * Checks if two Routes contain equal inner contents.
131 long ret = bindings.Route_hash(this.ptr);
136 public override int GetHashCode() {
137 return (int)this.hash();
140 * Checks if two Routes contain equal inner contents.
141 * This ignores pointers and is_owned flags and looks at the values in fields.
142 * Two objects with NULL inner values will be considered "equal" here.
144 public bool eq(org.ldk.structs.Route b) {
145 bool ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr);
148 if (this != null) { this.ptrs_to.AddLast(b); };
152 public override bool Equals(object o) {
153 if (!(o is Route)) return false;
154 return this.eq((Route)o);
157 * Returns the total amount of fees paid on this [`Route`].
159 * This doesn't include any extra payment made to the recipient, which can happen in excess of
160 * the amount passed to [`find_route`]'s `params.final_value_msat`.
162 public long get_total_fees() {
163 long ret = bindings.Route_get_total_fees(this.ptr);
169 * Returns the total amount paid on this [`Route`], excluding the fees.
171 public long get_total_amount() {
172 long ret = bindings.Route_get_total_amount(this.ptr);
178 * Serialize the Route object into a byte array which can be read by Route_read
180 public byte[] write() {
181 byte[] ret = bindings.Route_write(this.ptr);
187 * Read a Route from a byte array, created by Route_write
189 public static Result_RouteDecodeErrorZ read(byte[] ser) {
190 long ret = bindings.Route_read(ser);
192 if (ret >= 0 && ret <= 4096) { return null; }
193 Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);