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 public class FeeEstimator : CommonBase {
38 internal bindings.LDKFeeEstimator bindings_instance;
39 internal long instance_idx;
41 internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
43 if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
46 private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
47 private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
48 internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
49 private FeeEstimatorInterface arg;
50 private LDKFeeEstimatorHolder impl_holder;
51 public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) {
52 int ret = arg.get_est_sat_per_1000_weight(_confirmation_target);
58 /** Creates a new instance of FeeEstimator from a given implementation */
59 public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
60 LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
61 LDKFeeEstimatorImpl impl = new LDKFeeEstimatorImpl(arg, impl_holder);
62 long[] ptr_idx = bindings.LDKFeeEstimator_new(impl);
64 impl_holder.held = new FeeEstimator(null, ptr_idx[0]);
65 impl_holder.held.instance_idx = ptr_idx[1];
66 impl_holder.held.bindings_instance = impl;
67 return impl_holder.held;
71 * Gets estimated satoshis of fee required per 1000 Weight-Units.
73 * LDK will wrap this method and ensure that the value returned is no smaller than 253
74 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
76 * The following unit conversions can be used to convert to sats/KW:
77 * satoshis-per-byte * 250
78 * satoshis-per-kbyte / 4
80 public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
81 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
83 GC.KeepAlive(confirmation_target);