6 namespace org { namespace ldk { namespace structs {
9 * A trait which should be implemented to provide feerate information on a number of time
12 * If access to a local mempool is not feasible, feerate estimates should be fetched from a set of
13 * third-parties hosting them. Note that this enables them to affect the propagation of your
14 * pre-signed transactions at any time and therefore endangers the safety of channels funds. It
15 * should be considered carefully as a deployment.
17 * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
18 * called from inside the library in response to chain events, P2P events, or timer events).
20 public class FeeEstimator : CommonBase {
21 internal readonly bindings.LDKFeeEstimator bindings_instance;
22 internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
23 private FeeEstimator(bindings.LDKFeeEstimator arg) : base(bindings.LDKFeeEstimator_new(arg)) {
24 this.ptrs_to.AddLast(arg);
25 this.bindings_instance = arg;
28 if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
31 public interface FeeEstimatorInterface {
33 * Gets estimated satoshis of fee required per 1000 Weight-Units.
35 * LDK will wrap this method and ensure that the value returned is no smaller than 253
36 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
38 * The following unit conversions can be used to convert to sats/KW:
39 * satoshis-per-byte * 250
40 * satoshis-per-kbyte / 4
42 int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target);
44 private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
45 private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
46 internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
47 private FeeEstimatorInterface arg;
48 private LDKFeeEstimatorHolder impl_holder;
49 public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) {
50 int ret = arg.get_est_sat_per_1000_weight(_confirmation_target);
55 public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
56 LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
57 impl_holder.held = new FeeEstimator(new LDKFeeEstimatorImpl(arg, impl_holder));
58 return impl_holder.held;
61 * Gets estimated satoshis of fee required per 1000 Weight-Units.
63 * LDK will wrap this method and ensure that the value returned is no smaller than 253
64 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
66 * The following unit conversions can be used to convert to sats/KW:
67 * satoshis-per-byte * 250
68 * satoshis-per-kbyte / 4
70 public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
71 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
73 GC.KeepAlive(confirmation_target);