Merge pull request #45 from TheBlueMatt/main
[ldk-java] / ts / structs / ChainMonitor.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export default class ChainMonitor extends CommonBase {
9                 constructor(_dummy: object, ptr: number) {
10                     super(ptr);
11                 }
12
13                 
14                 protected finalize() {
15                     super.finalize();
16
17                     if (this.ptr != 0) {
18                         bindings.ChainMonitor_free(this.ptr);
19                     }
20                 }
21         public static ChainMonitor constructor_new(Option_FilterZ chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) {
22                 number ret = bindings.ChainMonitor_new(chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr);
23                 const ret_hu_conv: ChainMonitor = new ChainMonitor(null, ret);
24                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
25                 ret_hu_conv.ptrs_to.add(broadcaster);
26                 ret_hu_conv.ptrs_to.add(logger);
27                 ret_hu_conv.ptrs_to.add(feeest);
28                 ret_hu_conv.ptrs_to.add(persister);
29                 return ret_hu_conv;
30         }
31
32         public Balance[] get_claimable_balances(ChannelDetails[] ignored_channels) {
33                 number[] ret = bindings.ChainMonitor_get_claimable_balances(this.ptr, ignored_channels != null ? Arrays.stream(ignored_channels).map(ignored_channels_conv_16 -> ignored_channels_conv_16 == null ? 0 : ignored_channels_conv_16.ptr & ~1).toArray(number[]::new) : null);
34                 Balance[] ret_conv_9_arr = new Balance[ret.length];
35                 for (int j = 0; j < ret.length; j++) {
36                         number ret_conv_9 = ret[j];
37                         Balance ret_conv_9_hu_conv = Balance.constr_from_ptr(ret_conv_9);
38                         ret_conv_9_hu_conv.ptrs_to.add(this);
39                         ret_conv_9_arr[j] = ret_conv_9_hu_conv;
40                 }
41                 for (ChannelDetails ignored_channels_conv_16: ignored_channels) { this.ptrs_to.add(ignored_channels_conv_16); };
42                 return ret_conv_9_arr;
43         }
44
45         public Listen as_Listen() {
46                 number ret = bindings.ChainMonitor_as_Listen(this.ptr);
47                 Listen ret_hu_conv = new Listen(null, ret);
48                 ret_hu_conv.ptrs_to.add(this);
49                 return ret_hu_conv;
50         }
51
52         public Confirm as_Confirm() {
53                 number ret = bindings.ChainMonitor_as_Confirm(this.ptr);
54                 Confirm ret_hu_conv = new Confirm(null, ret);
55                 ret_hu_conv.ptrs_to.add(this);
56                 return ret_hu_conv;
57         }
58
59         public Watch as_Watch() {
60                 number ret = bindings.ChainMonitor_as_Watch(this.ptr);
61                 Watch ret_hu_conv = new Watch(null, ret);
62                 ret_hu_conv.ptrs_to.add(this);
63                 return ret_hu_conv;
64         }
65
66         public EventsProvider as_EventsProvider() {
67                 number ret = bindings.ChainMonitor_as_EventsProvider(this.ptr);
68                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
69                 ret_hu_conv.ptrs_to.add(this);
70                 return ret_hu_conv;
71         }
72
73 }