1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Fees for routing via a given channel or a node
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RoutingFees extends CommonBase {
16 RoutingFees(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.RoutingFees_free(ptr); }
24 * Flat routing fee in satoshis
26 public int get_base_msat() {
27 int ret = bindings.RoutingFees_get_base_msat(this.ptr);
28 Reference.reachabilityFence(this);
33 * Flat routing fee in satoshis
35 public void set_base_msat(int val) {
36 bindings.RoutingFees_set_base_msat(this.ptr, val);
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * Liquidity-based routing fee in millionths of a routed amount.
43 * In other words, 10000 is 1%.
45 public int get_proportional_millionths() {
46 int ret = bindings.RoutingFees_get_proportional_millionths(this.ptr);
47 Reference.reachabilityFence(this);
52 * Liquidity-based routing fee in millionths of a routed amount.
53 * In other words, 10000 is 1%.
55 public void set_proportional_millionths(int val) {
56 bindings.RoutingFees_set_proportional_millionths(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Constructs a new RoutingFees given each field
64 public static RoutingFees of(int base_msat_arg, int proportional_millionths_arg) {
65 long ret = bindings.RoutingFees_new(base_msat_arg, proportional_millionths_arg);
66 Reference.reachabilityFence(base_msat_arg);
67 Reference.reachabilityFence(proportional_millionths_arg);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75 * Checks if two RoutingFeess contain equal inner contents.
76 * This ignores pointers and is_owned flags and looks at the values in fields.
77 * Two objects with NULL inner values will be considered "equal" here.
79 public boolean eq(RoutingFees b) {
80 boolean ret = bindings.RoutingFees_eq(this.ptr, b == null ? 0 : b.ptr);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(b);
83 if (this != null) { this.ptrs_to.add(b); };
87 @Override public boolean equals(Object o) {
88 if (!(o instanceof RoutingFees)) return false;
89 return this.eq((RoutingFees)o);
92 long ret = bindings.RoutingFees_clone_ptr(this.ptr);
93 Reference.reachabilityFence(this);
98 * Creates a copy of the RoutingFees
100 public RoutingFees clone() {
101 long ret = bindings.RoutingFees_clone(this.ptr);
102 Reference.reachabilityFence(this);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
110 * Checks if two RoutingFeess contain equal inner contents.
113 long ret = bindings.RoutingFees_hash(this.ptr);
114 Reference.reachabilityFence(this);
118 @Override public int hashCode() {
119 return (int)this.hash();
122 * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
124 public byte[] write() {
125 byte[] ret = bindings.RoutingFees_write(this.ptr);
126 Reference.reachabilityFence(this);
131 * Read a RoutingFees from a byte array, created by RoutingFees_write
133 public static Result_RoutingFeesDecodeErrorZ read(byte[] ser) {
134 long ret = bindings.RoutingFees_read(ser);
135 Reference.reachabilityFence(ser);
136 if (ret >= 0 && ret <= 4096) { return null; }
137 Result_RoutingFeesDecodeErrorZ ret_hu_conv = Result_RoutingFeesDecodeErrorZ.constr_from_ptr(ret);