[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / FeeEstimator.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of FeeEstimator */
12 public interface FeeEstimatorInterface {
13         /**Gets estimated satoshis of fee required per 1000 Weight-Units.
14          * 
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).
17          * 
18          * The following unit conversions can be used to convert to sats/KW:
19          * satoshis-per-byte * 250
20          * satoshis-per-kbyte / 4
21          */
22         int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target);
23 }
24
25 /**
26  * A trait which should be implemented to provide feerate information on a number of time
27  * horizons.
28  * 
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.
33  * 
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).
36  * 
37  * LDK may generate a substantial number of fee-estimation calls in some cases. You should
38  * pre-calculate and cache the fee estimate results to ensure you don't substantially slow HTLC
39  * handling.
40  */
41 public class FeeEstimator : CommonBase {
42         internal bindings.LDKFeeEstimator bindings_instance;
43         internal long instance_idx;
44
45         internal FeeEstimator(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
46         ~FeeEstimator() {
47                 if (ptr != 0) { bindings.FeeEstimator_free(ptr); }
48         }
49
50         private class LDKFeeEstimatorHolder { internal FeeEstimator held; }
51         private class LDKFeeEstimatorImpl : bindings.LDKFeeEstimator {
52                 internal LDKFeeEstimatorImpl(FeeEstimatorInterface arg, LDKFeeEstimatorHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
53                 private FeeEstimatorInterface arg;
54                 private LDKFeeEstimatorHolder impl_holder;
55                 public int get_est_sat_per_1000_weight(ConfirmationTarget _confirmation_target) {
56                         int ret = arg.get_est_sat_per_1000_weight(_confirmation_target);
57                                 GC.KeepAlive(arg);
58                         return ret;
59                 }
60         }
61
62         /** Creates a new instance of FeeEstimator from a given implementation */
63         public static FeeEstimator new_impl(FeeEstimatorInterface arg) {
64                 LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder();
65                 LDKFeeEstimatorImpl impl = new LDKFeeEstimatorImpl(arg, impl_holder);
66                 long[] ptr_idx = bindings.LDKFeeEstimator_new(impl);
67
68                 impl_holder.held = new FeeEstimator(null, ptr_idx[0]);
69                 impl_holder.held.instance_idx = ptr_idx[1];
70                 impl_holder.held.bindings_instance = impl;
71                 return impl_holder.held;
72         }
73
74         /**
75          * Gets estimated satoshis of fee required per 1000 Weight-Units.
76          * 
77          * LDK will wrap this method and ensure that the value returned is no smaller than 253
78          * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte).
79          * 
80          * The following unit conversions can be used to convert to sats/KW:
81          * satoshis-per-byte * 250
82          * satoshis-per-kbyte / 4
83          */
84         public int get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
85                 int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(confirmation_target);
88                 return ret;
89         }
90
91 }
92 } } }