6 namespace org { namespace ldk { namespace structs {
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 public class FeeEstimator : CommonBase {
16 internal readonly bindings.LDKFeeEstimator bindings_instance;
17 internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
18 private FeeEstimator(bindings.LDKFeeEstimator arg) : base(bindings.LDKFeeEstimator_new(arg)) {
19 this.ptrs_to.AddLast(arg);
20 this.bindings_instance = arg;
23 if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
26 public interface FeeEstimatorInterface {
28 * Gets estimated satoshis of fee required per 1000 Weight-Units.
30 * LDK will wrap this method and ensure that the value returned is no smaller than 253
31 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
33 * The following unit conversions can be used to convert to sats/KW:
34 * satoshis-per-byte * 250
35 * satoshis-per-kbyte / 4
37 int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target);
39 private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
40 private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
41 internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
42 private FeeEstimatorInterface arg;
43 private LDKFeeEstimatorHolder impl_holder;
44 public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) {
45 int ret = arg.get_est_sat_per_1000_weight(_confirmation_target);
50 public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
51 LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
52 impl_holder.held = new FeeEstimator(new LDKFeeEstimatorImpl(arg, impl_holder));
53 return impl_holder.held;
56 * Gets estimated satoshis of fee required per 1000 Weight-Units.
58 * LDK will wrap this method and ensure that the value returned is no smaller than 253
59 * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
61 * The following unit conversions can be used to convert to sats/KW:
62 * satoshis-per-byte * 250
63 * satoshis-per-kbyte / 4
65 public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
66 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
68 GC.KeepAlive(confirmation_target);