]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/ChainMonitor.ts
Update bindings to latest upstream + ChannelMonitor_clone patch
[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 void block_connected(Uint8Array header, TwoTuple<Number, Uint8Array>[] txdata, number height) {
22                 bindings.ChainMonitor_block_connected(this.ptr, header, Arrays.stream(txdata).map(txdata_conv_30 -> bindings.C2Tuple_usizeTransactionZ_new(txdata_conv_30.a, txdata_conv_30.b)).toArray(number[]::new), height);
23                 /* TODO 2 TwoTuple<Number, Uint8Array>  */;
24         }
25
26         public void block_disconnected(Uint8Array header, number disconnected_height) {
27                 bindings.ChainMonitor_block_disconnected(this.ptr, header, disconnected_height);
28         }
29
30         public static ChainMonitor constructor_new(Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) {
31                 number ret = bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr);
32                 const ret_hu_conv: ChainMonitor = new ChainMonitor(null, ret);
33                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
34                 ret_hu_conv.ptrs_to.add(chain_source);
35                 ret_hu_conv.ptrs_to.add(broadcaster);
36                 ret_hu_conv.ptrs_to.add(logger);
37                 ret_hu_conv.ptrs_to.add(feeest);
38                 ret_hu_conv.ptrs_to.add(persister);
39                 return ret_hu_conv;
40         }
41
42         public Watch as_Watch() {
43                 number ret = bindings.ChainMonitor_as_Watch(this.ptr);
44                 Watch ret_hu_conv = new Watch(null, ret);
45                 ret_hu_conv.ptrs_to.add(this);
46                 return ret_hu_conv;
47         }
48
49         public EventsProvider as_EventsProvider() {
50                 number ret = bindings.ChainMonitor_as_EventsProvider(this.ptr);
51                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
52                 ret_hu_conv.ptrs_to.add(this);
53                 return ret_hu_conv;
54         }
55
56 }