[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / MaxDustHTLCExposure.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  * Options for how to set the max dust HTLC exposure allowed on a channel. See
13  * [`ChannelConfig::max_dust_htlc_exposure`] for details.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class MaxDustHTLCExposure extends CommonBase {
17         private MaxDustHTLCExposure(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.MaxDustHTLCExposure_free(ptr); }
22         }
23         static MaxDustHTLCExposure constr_from_ptr(long ptr) {
24                 bindings.LDKMaxDustHTLCExposure raw_val = bindings.LDKMaxDustHTLCExposure_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKMaxDustHTLCExposure.FixedLimitMsat.class) {
26                         return new FixedLimitMsat(ptr, (bindings.LDKMaxDustHTLCExposure.FixedLimitMsat)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKMaxDustHTLCExposure.FeeRateMultiplier.class) {
29                         return new FeeRateMultiplier(ptr, (bindings.LDKMaxDustHTLCExposure.FeeRateMultiplier)raw_val);
30                 }
31                 assert false; return null; // Unreachable without extending the (internal) bindings interface
32         }
33
34         /**
35          * This sets a fixed limit on the total dust exposure in millisatoshis. Setting this too low
36          * may prevent the sending or receipt of low-value HTLCs on high-traffic nodes, however this
37          * limit is very important to prevent stealing of large amounts of dust HTLCs by miners
38          * through [fee griefing
39          * attacks](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html).
40          * 
41          * Note that if the feerate increases significantly, without a manual increase
42          * to this maximum the channel may be unable to send/receive HTLCs between the maximum dust
43          * exposure and the new minimum value for HTLCs to be economically viable to claim.
44          */
45         public final static class FixedLimitMsat extends MaxDustHTLCExposure {
46                 public final long fixed_limit_msat;
47                 private FixedLimitMsat(long ptr, bindings.LDKMaxDustHTLCExposure.FixedLimitMsat obj) {
48                         super(null, ptr);
49                         this.fixed_limit_msat = obj.fixed_limit_msat;
50                 }
51         }
52         /**
53          * This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from
54          * [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used
55          * then the maximum dust exposure in millisatoshis is calculated as:
56          * `high_priority_feerate_per_kw * value`. For example, with our default value
57          * `FeeRateMultiplier(5000)`:
58          * 
59          * - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum
60          * defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would
61          * be 253 * 5000 = 1,265,000 msats.
62          * - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be
63          * 7500 * 5000 = 37,500,000 msats.
64          * 
65          * This allows the maximum dust exposure to automatically scale with fee rate changes.
66          * 
67          * Note, if you're using a third-party fee estimator, this may leave you more exposed to a
68          * fee griefing attack, where your fee estimator may purposely overestimate the fee rate,
69          * causing you to accept more dust HTLCs than you would otherwise.
70          * 
71          * This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included
72          * on HTLC outputs means your channel may be subject to more dust exposure in the event of
73          * increases in fee rate.
74          * 
75          * # Backwards Compatibility
76          * This variant only became available in LDK 0.0.116, so if you downgrade to a prior version
77          * by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat.
78          * 
79          * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator
80          */
81         public final static class FeeRateMultiplier extends MaxDustHTLCExposure {
82                 public final long fee_rate_multiplier;
83                 private FeeRateMultiplier(long ptr, bindings.LDKMaxDustHTLCExposure.FeeRateMultiplier obj) {
84                         super(null, ptr);
85                         this.fee_rate_multiplier = obj.fee_rate_multiplier;
86                 }
87         }
88         long clone_ptr() {
89                 long ret = bindings.MaxDustHTLCExposure_clone_ptr(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * Creates a copy of the MaxDustHTLCExposure
96          */
97         public MaxDustHTLCExposure clone() {
98                 long ret = bindings.MaxDustHTLCExposure_clone(this.ptr);
99                 Reference.reachabilityFence(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure
108          */
109         public static MaxDustHTLCExposure fixed_limit_msat(long a) {
110                 long ret = bindings.MaxDustHTLCExposure_fixed_limit_msat(a);
111                 Reference.reachabilityFence(a);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure
120          */
121         public static MaxDustHTLCExposure fee_rate_multiplier(long a) {
122                 long ret = bindings.MaxDustHTLCExposure_fee_rate_multiplier(a);
123                 Reference.reachabilityFence(a);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Checks if two MaxDustHTLCExposures contain equal inner contents.
132          * This ignores pointers and is_owned flags and looks at the values in fields.
133          */
134         public boolean eq(org.ldk.structs.MaxDustHTLCExposure b) {
135                 boolean ret = bindings.MaxDustHTLCExposure_eq(this.ptr, b == null ? 0 : b.ptr);
136                 Reference.reachabilityFence(this);
137                 Reference.reachabilityFence(b);
138                 return ret;
139         }
140
141         @Override public boolean equals(Object o) {
142                 if (!(o instanceof MaxDustHTLCExposure)) return false;
143                 return this.eq((MaxDustHTLCExposure)o);
144         }
145         /**
146          * Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read
147          */
148         public byte[] write() {
149                 byte[] ret = bindings.MaxDustHTLCExposure_write(this.ptr);
150                 Reference.reachabilityFence(this);
151                 return ret;
152         }
153
154         /**
155          * Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write
156          */
157         public static Result_MaxDustHTLCExposureDecodeErrorZ read(byte[] ser) {
158                 long ret = bindings.MaxDustHTLCExposure_read(ser);
159                 Reference.reachabilityFence(ser);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 Result_MaxDustHTLCExposureDecodeErrorZ ret_hu_conv = Result_MaxDustHTLCExposureDecodeErrorZ.constr_from_ptr(ret);
162                 return ret_hu_conv;
163         }
164
165 }