7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of FeeEstimator */
12 public interface FeeEstimatorInterface {
13 /**Gets estimated satoshis of fee required per 1000 Weight-Units.
15 * LDK will wrap this method and ensure that the value returned is no smaller than 253
16 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
18 * The following unit conversions can be used to convert to sats/KW:
19 * satoshis-per-byte * 250
20 * satoshis-per-kbyte / 4
22 int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target);
26 * A trait which should be implemented to provide feerate information on a number of time
29 * If access to a local mempool is not feasible, feerate estimates should be fetched from a set of
30 * third-parties hosting them. Note that this enables them to affect the propagation of your
31 * pre-signed transactions at any time and therefore endangers the safety of channels funds. It
32 * should be considered carefully as a deployment.
34 * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
35 * called from inside the library in response to chain events, P2P events, or timer events).
37 * LDK may generate a substantial number of fee-estimation calls in some cases. You should
38 * pre-calculate and cache the fee estimate results to ensure you don't substantially slow HTLC
41 public class FeeEstimator : CommonBase {
42 internal bindings.LDKFeeEstimator bindings_instance;
43 internal long instance_idx;
45 internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
47 if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
50 private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
51 private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
52 internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
53 private FeeEstimatorInterface arg;
54 private LDKFeeEstimatorHolder impl_holder;
55 public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) {
56 int ret = arg.get_est_sat_per_1000_weight(_confirmation_target);
62 /** Creates a new instance of FeeEstimator from a given implementation */
63 public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
64 LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
65 LDKFeeEstimatorImpl impl = new LDKFeeEstimatorImpl(arg, impl_holder);
66 long[] ptr_idx = bindings.LDKFeeEstimator_new(impl);
68 impl_holder.held = new FeeEstimator(null, ptr_idx[0]);
69 impl_holder.held.instance_idx = ptr_idx[1];
70 impl_holder.held.bindings_instance = impl;
71 return impl_holder.held;
75 * Gets estimated satoshis of fee required per 1000 Weight-Units.
77 * LDK will wrap this method and ensure that the value returned is no smaller than 253
78 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
80 * The following unit conversions can be used to convert to sats/KW:
81 * satoshis-per-byte * 250
82 * satoshis-per-kbyte / 4
84 public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
85 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
87 GC.KeepAlive(confirmation_target);