X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FRouteParameters.cs;h=de9e018afa451aaad697350d9355fb240ac4573b;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=35c04630acba2b25284177eb671f411eac43bc92;hpb=afc50e5d491a11364849383b75a8f939df703bac;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/RouteParameters.cs b/c_sharp/src/org/ldk/structs/RouteParameters.cs index 35c04630..de9e018a 100644 --- a/c_sharp/src/org/ldk/structs/RouteParameters.cs +++ b/c_sharp/src/org/ldk/structs/RouteParameters.cs @@ -57,17 +57,51 @@ public class RouteParameters : CommonBase { GC.KeepAlive(val); } + /** + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. + */ + public Option_u64Z get_max_total_routing_fee_msat() { + long ret = bindings.RouteParameters_get_max_total_routing_fee_msat(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; + } + + /** + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. + */ + public void set_max_total_routing_fee_msat(org.ldk.structs.Option_u64Z val) { + bindings.RouteParameters_set_max_total_routing_fee_msat(this.ptr, val.ptr); + GC.KeepAlive(this); + GC.KeepAlive(val); + if (this != null) { this.ptrs_to.AddLast(val); }; + } + /** * Constructs a new RouteParameters given each field */ - public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg) { - long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg); + public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg, org.ldk.structs.Option_u64Z max_total_routing_fee_msat_arg) { + long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg, max_total_routing_fee_msat_arg.ptr); GC.KeepAlive(payment_params_arg); GC.KeepAlive(final_value_msat_arg); + GC.KeepAlive(max_total_routing_fee_msat_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(max_total_routing_fee_msat_arg); }; return ret_hu_conv; } @@ -89,6 +123,18 @@ public class RouteParameters : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the RouteParameters. + */ + public long hash() { + long ret = bindings.RouteParameters_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } /** * Checks if two RouteParameterss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -106,20 +152,38 @@ public class RouteParameters : CommonBase { if (!(o is RouteParameters)) return false; return this.eq((RouteParameters)o); } + /** + * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. + * + * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + */ + public static RouteParameters from_payment_params_and_value(org.ldk.structs.PaymentParameters payment_params, long final_value_msat) { + long ret = bindings.RouteParameters_from_payment_params_and_value(payment_params == null ? 0 : payment_params.ptr, final_value_msat); + GC.KeepAlive(payment_params); + GC.KeepAlive(final_value_msat); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_params); }; + return ret_hu_conv; + } + /** * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read */ public byte[] write() { - byte[] ret = bindings.RouteParameters_write(this.ptr); + long ret = bindings.RouteParameters_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Read a RouteParameters from a byte array, created by RouteParameters_write */ public static Result_RouteParametersDecodeErrorZ read(byte[] ser) { - long ret = bindings.RouteParameters_read(ser); + long ret = bindings.RouteParameters_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);