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 [`Path`]s taken for a single (potentially-)multi-part payment. If no
21 * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
24 public Path[] get_paths() {
25 long[] ret = bindings.Route_get_paths(this.ptr);
27 int ret_conv_6_len = ret.Length;
28 Path[] ret_conv_6_arr = new Path[ret_conv_6_len];
29 for (int g = 0; g < ret_conv_6_len; g++) {
30 long ret_conv_6 = ret[g];
31 org.ldk.structs.Path ret_conv_6_hu_conv = null; if (ret_conv_6 < 0 || ret_conv_6 > 4096) { ret_conv_6_hu_conv = new org.ldk.structs.Path(null, ret_conv_6); }
32 if (ret_conv_6_hu_conv != null) { ret_conv_6_hu_conv.ptrs_to.AddLast(this); };
33 ret_conv_6_arr[g] = ret_conv_6_hu_conv;
35 return ret_conv_6_arr;
39 * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no
40 * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
43 public void set_paths(Path[] val) {
44 bindings.Route_set_paths(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_6 => val_conv_6 == null ? 0 : val_conv_6.ptr) : null);
47 foreach (Path val_conv_6 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_6); }; };
51 * The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`].
53 * This is used by `ChannelManager` to track information which may be required for retries.
55 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
57 public PaymentParameters get_payment_params() {
58 long ret = bindings.Route_get_payment_params(this.ptr);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
62 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
67 * The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`].
69 * This is used by `ChannelManager` to track information which may be required for retries.
71 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
73 public void set_payment_params(org.ldk.structs.PaymentParameters val) {
74 bindings.Route_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
77 if (this != null) { this.ptrs_to.AddLast(val); };
81 * Constructs a new Route given each field
83 public static Route of(Path[] paths_arg, org.ldk.structs.PaymentParameters payment_params_arg) {
84 long ret = bindings.Route_new(paths_arg != null ? InternalUtils.mapArray(paths_arg, paths_arg_conv_6 => paths_arg_conv_6 == null ? 0 : paths_arg_conv_6.ptr) : null, payment_params_arg == null ? 0 : payment_params_arg.ptr);
85 GC.KeepAlive(paths_arg);
86 GC.KeepAlive(payment_params_arg);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 org.ldk.structs.Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Route(null, ret); }
89 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
90 foreach (Path paths_arg_conv_6 in paths_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(paths_arg_conv_6); }; };
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params_arg); };
95 internal long clone_ptr() {
96 long ret = bindings.Route_clone_ptr(this.ptr);
102 * Creates a copy of the Route
104 public Route clone() {
105 long ret = bindings.Route_clone(this.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Route(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
114 * Generates a non-cryptographic 64-bit hash of the Route.
117 long ret = bindings.Route_hash(this.ptr);
122 public override int GetHashCode() {
123 return (int)this.hash();
126 * Checks if two Routes contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public bool eq(org.ldk.structs.Route b) {
131 bool ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr);
134 if (this != null) { this.ptrs_to.AddLast(b); };
138 public override bool Equals(object o) {
139 if (!(o is Route)) return false;
140 return this.eq((Route)o);
143 * Returns the total amount of fees paid on this [`Route`].
145 * This doesn't include any extra payment made to the recipient, which can happen in excess of
146 * the amount passed to [`find_route`]'s `route_params.final_value_msat`.
148 public long get_total_fees() {
149 long ret = bindings.Route_get_total_fees(this.ptr);
155 * Returns the total amount paid on this [`Route`], excluding the fees. Might be more than
156 * requested if we had to reach htlc_minimum_msat.
158 public long get_total_amount() {
159 long ret = bindings.Route_get_total_amount(this.ptr);
165 * Serialize the Route object into a byte array which can be read by Route_read
167 public byte[] write() {
168 byte[] ret = bindings.Route_write(this.ptr);
174 * Read a Route from a byte array, created by Route_write
176 public static Result_RouteDecodeErrorZ read(byte[] ser) {
177 long ret = bindings.Route_read(ser);
179 if (ret >= 0 && ret <= 4096) { return null; }
180 Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);