]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/FeeEstimator.ts
Merge pull request #47 from TheBlueMatt/main
[ldk-java] / ts / structs / FeeEstimator.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class FeeEstimator extends CommonBase {
9
10                 bindings_instance?: bindings.LDKFeeEstimator;
11
12                 constructor(ptr?: number, arg?: bindings.LDKFeeEstimator) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKFeeEstimator_new(arg));
19                                         this.ptrs_to.push(arg);
20                                         
21                                     }
22                 }
23
24                 protected finalize() {
25                     if (this.ptr != 0) {
26                         bindings.FeeEstimator_free(this.ptr);
27                     }
28                     super.finalize();
29                 }
30
31                 static new_impl(arg: FeeEstimatorInterface): FeeEstimator {
32                     const impl_holder: LDKFeeEstimatorHolder = new LDKFeeEstimatorHolder();
33                     let structImplementation = <bindings.LDKFeeEstimator>{
34                         // todo: in-line interface filling
35                         get_est_sat_per_1000_weight (confirmation_target: ConfirmationTarget): number {
36                                                         number ret = arg.get_est_sat_per_1000_weight(confirmation_target);
37                                 return ret;
38                                                 },
39
40                                                 
41                     };
42                     impl_holder.held = new FeeEstimator (null, structImplementation);
43                 }
44             }
45
46             export interface FeeEstimatorInterface {
47                 get_est_sat_per_1000_weight(confirmation_target: ConfirmationTarget): number;
48                                 
49             }
50
51             class LDKFeeEstimatorHolder {
52                 held: FeeEstimator;
53             }
54         public number get_est_sat_per_1000_weight(ConfirmationTarget confirmation_target) {
55                 number ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target);
56                 return ret;
57         }
58
59 }