1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
9 * A trait which should be implemented to provide feerate information on a number of time
12 * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
13 * called from inside the library in response to chain events, P2P events, or timer events).
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class FeeEstimator extends CommonBase {
17 final bindings.LDKFeeEstimator bindings_instance;
18 FeeEstimator(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
19 private FeeEstimator(bindings.LDKFeeEstimator arg) {
20 super(bindings.LDKFeeEstimator_new(arg));
21 this.ptrs_to.add(arg);
22 this.bindings_instance = arg;
24 @Override @SuppressWarnings("deprecation")
25 protected void finalize() throws Throwable {
26 if (ptr != 0) { bindings.FeeEstimator_free(ptr); } super.finalize();
29 public static interface FeeEstimatorInterface {
31 * Gets estimated satoshis of fee required per 1000 Weight-Units.
33 * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
34 * don't put us below 1 satoshi-per-byte).
37 * satoshis-per-byte * 250
38 * ceil(satoshis-per-kbyte / 4)
40 int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target);
42 private static class LDKFeeEstimatorHolder { FeeEstimator held; }
43 public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
44 final LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
45 impl_holder.held = new FeeEstimator(new bindings.LDKFeeEstimator() {
46 @Override public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) {
47 int ret = arg.get_est_sat_per_1000_weight(confirmation_target);
51 return impl_holder.held;
54 * Gets estimated satoshis of fee required per 1000 Weight-Units.
56 * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
57 * don't put us below 1 satoshi-per-byte).
60 * satoshis-per-byte * 250
61 * ceil(satoshis-per-kbyte / 4)
63 public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) {
64 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);