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