+
using org.ldk.impl;
using org.ldk.enums;
using org.ldk.util;
namespace org { namespace ldk { namespace structs {
+
+
+/** An implementation of FeeEstimator */
+public interface FeeEstimatorInterface {
+ /**Gets estimated satoshis of fee required per 1000 Weight-Units.
+ *
+ * LDK will wrap this method and ensure that the value returned is no smaller than 253
+ * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
+ *
+ * The following unit conversions can be used to convert to sats/KW:
+ * satoshis-per-byte * 250
+ * satoshis-per-kbyte / 4
+ */
+ int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target);
+}
+
/**
* A trait which should be implemented to provide feerate information on a number of time
* horizons.
* called from inside the library in response to chain events, P2P events, or timer events).
*/
public class FeeEstimator : CommonBase {
- internal readonly bindings.LDKFeeEstimator bindings_instance;
+ internal bindings.LDKFeeEstimator bindings_instance;
+ internal long instance_idx;
+
internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
- private FeeEstimator(bindings.LDKFeeEstimator arg) : base(bindings.LDKFeeEstimator_new(arg)) {
- this.ptrs_to.AddLast(arg);
- this.bindings_instance = arg;
- }
~FeeEstimator() {
if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
}
- public interface FeeEstimatorInterface {
- /**
- * Gets estimated satoshis of fee required per 1000 Weight-Units.
- *
- * LDK will wrap this method and ensure that the value returned is no smaller than 253
- * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
- *
- * The following unit conversions can be used to convert to sats/KW:
- * satoshis-per-byte * 250
- * satoshis-per-kbyte / 4
- */
- int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target);
- }
private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
return ret;
}
}
+
+ /** Creates a new instance of FeeEstimator from a given implementation */
public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
- impl_holder.held = new FeeEstimator(new LDKFeeEstimatorImpl(arg, impl_holder));
+ LDKFeeEstimatorImpl impl = new LDKFeeEstimatorImpl(arg, impl_holder);
+ long[] ptr_idx = bindings.LDKFeeEstimator_new(impl);
+
+ impl_holder.held = new FeeEstimator(null, ptr_idx[0]);
+ impl_holder.held.instance_idx = ptr_idx[1];
+ impl_holder.held.bindings_instance = impl;
return impl_holder.held;
}
+
/**
* Gets estimated satoshis of fee required per 1000 Weight-Units.
*