X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FFeeEstimator.cs;fp=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FFeeEstimator.cs;h=45694cded4acacb48dea2b77f4cb4360fa511f39;hb=810f7404202e04f70db946ced7363b64ddaf4ce4;hp=0000000000000000000000000000000000000000;hpb=fa130da4108815a8b17c3c093a91fc3d83754a0f;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/FeeEstimator.cs b/c_sharp/src/org/ldk/structs/FeeEstimator.cs new file mode 100644 index 00000000..45694cde --- /dev/null +++ b/c_sharp/src/org/ldk/structs/FeeEstimator.cs @@ -0,0 +1,73 @@ +using org.ldk.impl; +using org.ldk.enums; +using org.ldk.util; +using System; + +namespace org { namespace ldk { namespace structs { + +/** + * A trait which should be implemented to provide feerate information on a number of time + * horizons. + * + * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're + * 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 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; } + private FeeEstimatorInterface arg; + private LDKFeeEstimatorHolder impl_holder; + public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) { + int ret = arg.get_est_sat_per_1000_weight(_confirmation_target); + GC.KeepAlive(arg); + return ret; + } + } + public static FeeEstimator new_impl(FeeEstimatorInterface arg) { + LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder(); + impl_holder.held = new FeeEstimator(new LDKFeeEstimatorImpl(arg, impl_holder)); + return impl_holder.held; + } + /** + * 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 + */ + public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) { + int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target); + GC.KeepAlive(this); + GC.KeepAlive(confirmation_target); + return ret; + } + +} +} } }