e824532ab5a45674fb7e43d786f3af77705b88cf
[ldk-java] / src / main / java / org / ldk / structs / ChannelConfigUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A parallel struct to [`ChannelConfig`] to define partial updates.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelConfigUpdate extends CommonBase {
16         ChannelConfigUpdate(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelConfigUpdate_free(ptr); }
21         }
22
23         public Option_u32Z get_forwarding_fee_proportional_millionths() {
24                 long ret = bindings.ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this.ptr);
25                 Reference.reachabilityFence(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret);
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
29                 return ret_hu_conv;
30         }
31
32         public void set_forwarding_fee_proportional_millionths(org.ldk.structs.Option_u32Z val) {
33                 bindings.ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(this.ptr, val.ptr);
34                 Reference.reachabilityFence(this);
35                 Reference.reachabilityFence(val);
36                 if (this != null) { this.ptrs_to.add(val); };
37         }
38
39         public Option_u32Z get_forwarding_fee_base_msat() {
40                 long ret = bindings.ChannelConfigUpdate_get_forwarding_fee_base_msat(this.ptr);
41                 Reference.reachabilityFence(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret);
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45                 return ret_hu_conv;
46         }
47
48         public void set_forwarding_fee_base_msat(org.ldk.structs.Option_u32Z val) {
49                 bindings.ChannelConfigUpdate_set_forwarding_fee_base_msat(this.ptr, val.ptr);
50                 Reference.reachabilityFence(this);
51                 Reference.reachabilityFence(val);
52                 if (this != null) { this.ptrs_to.add(val); };
53         }
54
55         public Option_u16Z get_cltv_expiry_delta() {
56                 long ret = bindings.ChannelConfigUpdate_get_cltv_expiry_delta(this.ptr);
57                 Reference.reachabilityFence(this);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret);
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
61                 return ret_hu_conv;
62         }
63
64         public void set_cltv_expiry_delta(org.ldk.structs.Option_u16Z val) {
65                 bindings.ChannelConfigUpdate_set_cltv_expiry_delta(this.ptr, val.ptr);
66                 Reference.reachabilityFence(this);
67                 Reference.reachabilityFence(val);
68                 if (this != null) { this.ptrs_to.add(val); };
69         }
70
71         /**
72          * Returns a copy of the field.
73          */
74         public Option_MaxDustHTLCExposureZ get_max_dust_htlc_exposure_msat() {
75                 long ret = bindings.ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(this.ptr);
76                 Reference.reachabilityFence(this);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 org.ldk.structs.Option_MaxDustHTLCExposureZ ret_hu_conv = org.ldk.structs.Option_MaxDustHTLCExposureZ.constr_from_ptr(ret);
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
80                 return ret_hu_conv;
81         }
82
83         public void set_max_dust_htlc_exposure_msat(org.ldk.structs.Option_MaxDustHTLCExposureZ val) {
84                 bindings.ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(this.ptr, val.ptr);
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(val);
87                 if (this != null) { this.ptrs_to.add(val); };
88         }
89
90         public Option_u64Z get_force_close_avoidance_max_fee_satoshis() {
91                 long ret = bindings.ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         public void set_force_close_avoidance_max_fee_satoshis(org.ldk.structs.Option_u64Z val) {
100                 bindings.ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(this.ptr, val.ptr);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103                 if (this != null) { this.ptrs_to.add(val); };
104         }
105
106         /**
107          * Constructs a new ChannelConfigUpdate given each field
108          */
109         public static ChannelConfigUpdate of(org.ldk.structs.Option_u32Z forwarding_fee_proportional_millionths_arg, org.ldk.structs.Option_u32Z forwarding_fee_base_msat_arg, org.ldk.structs.Option_u16Z cltv_expiry_delta_arg, org.ldk.structs.Option_MaxDustHTLCExposureZ max_dust_htlc_exposure_msat_arg, org.ldk.structs.Option_u64Z force_close_avoidance_max_fee_satoshis_arg) {
110                 long ret = bindings.ChannelConfigUpdate_new(forwarding_fee_proportional_millionths_arg.ptr, forwarding_fee_base_msat_arg.ptr, cltv_expiry_delta_arg.ptr, max_dust_htlc_exposure_msat_arg.ptr, force_close_avoidance_max_fee_satoshis_arg.ptr);
111                 Reference.reachabilityFence(forwarding_fee_proportional_millionths_arg);
112                 Reference.reachabilityFence(forwarding_fee_base_msat_arg);
113                 Reference.reachabilityFence(cltv_expiry_delta_arg);
114                 Reference.reachabilityFence(max_dust_htlc_exposure_msat_arg);
115                 Reference.reachabilityFence(force_close_avoidance_max_fee_satoshis_arg);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.ChannelConfigUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfigUpdate(null, ret); }
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(forwarding_fee_proportional_millionths_arg); };
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(forwarding_fee_base_msat_arg); };
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(cltv_expiry_delta_arg); };
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(max_dust_htlc_exposure_msat_arg); };
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(force_close_avoidance_max_fee_satoshis_arg); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used.
129          */
130         public static ChannelConfigUpdate with_default() {
131                 long ret = bindings.ChannelConfigUpdate_default();
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 org.ldk.structs.ChannelConfigUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfigUpdate(null, ret); }
134                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
135                 return ret_hu_conv;
136         }
137
138 }