[Java] Update auto-generated bindings to LDK 0.0.123
[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 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 [`ConfirmationTarget::OnChainSweep`] feerate (in sats/KW) to
54          * determine the maximum allowed dust exposure. If this variant is used then the maximum dust
55          * exposure in millisatoshis is calculated as:
56          * `feerate_per_kw * value`. For example, with our default value
57          * `FeeRateMultiplier(10_000)`:
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 * 10_000 = 2,530,000 msats.
62          * - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be
63          * 7500 * 50_000 = 75,000,000 msats (0.00075 BTC).
64          * 
65          * Note, if you're using a third-party fee estimator, this may leave you more exposed to a
66          * fee griefing attack, where your fee estimator may purposely overestimate the fee rate,
67          * causing you to accept more dust HTLCs than you would otherwise.
68          * 
69          * This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included
70          * on HTLC outputs means your channel may be subject to more dust exposure in the event of
71          * increases in fee rate.
72          * 
73          * # Backwards Compatibility
74          * This variant only became available in LDK 0.0.116, so if you downgrade to a prior version
75          * by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat.
76          * 
77          * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator
78          * [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep
79          */
80         public final static class FeeRateMultiplier extends MaxDustHTLCExposure {
81                 public final long fee_rate_multiplier;
82                 private FeeRateMultiplier(long ptr, bindings.LDKMaxDustHTLCExposure.FeeRateMultiplier obj) {
83                         super(null, ptr);
84                         this.fee_rate_multiplier = obj.fee_rate_multiplier;
85                 }
86         }
87         long clone_ptr() {
88                 long ret = bindings.MaxDustHTLCExposure_clone_ptr(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * Creates a copy of the MaxDustHTLCExposure
95          */
96         public MaxDustHTLCExposure clone() {
97                 long ret = bindings.MaxDustHTLCExposure_clone(this.ptr);
98                 Reference.reachabilityFence(this);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
101                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
102                 return ret_hu_conv;
103         }
104
105         /**
106          * Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure
107          */
108         public static MaxDustHTLCExposure fixed_limit_msat(long a) {
109                 long ret = bindings.MaxDustHTLCExposure_fixed_limit_msat(a);
110                 Reference.reachabilityFence(a);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
114                 return ret_hu_conv;
115         }
116
117         /**
118          * Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure
119          */
120         public static MaxDustHTLCExposure fee_rate_multiplier(long a) {
121                 long ret = bindings.MaxDustHTLCExposure_fee_rate_multiplier(a);
122                 Reference.reachabilityFence(a);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Checks if two MaxDustHTLCExposures contain equal inner contents.
131          * This ignores pointers and is_owned flags and looks at the values in fields.
132          */
133         public boolean eq(org.ldk.structs.MaxDustHTLCExposure b) {
134                 boolean ret = bindings.MaxDustHTLCExposure_eq(this.ptr, b.ptr);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(b);
137                 return ret;
138         }
139
140         @Override public boolean equals(Object o) {
141                 if (!(o instanceof MaxDustHTLCExposure)) return false;
142                 return this.eq((MaxDustHTLCExposure)o);
143         }
144         /**
145          * Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read
146          */
147         public byte[] write() {
148                 byte[] ret = bindings.MaxDustHTLCExposure_write(this.ptr);
149                 Reference.reachabilityFence(this);
150                 return ret;
151         }
152
153         /**
154          * Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write
155          */
156         public static Result_MaxDustHTLCExposureDecodeErrorZ read(byte[] ser) {
157                 long ret = bindings.MaxDustHTLCExposure_read(ser);
158                 Reference.reachabilityFence(ser);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 Result_MaxDustHTLCExposureDecodeErrorZ ret_hu_conv = Result_MaxDustHTLCExposureDecodeErrorZ.constr_from_ptr(ret);
161                 return ret_hu_conv;
162         }
163
164 }