]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/ChannelMonitor.ts
Bindings updates for latest upstream, check in .so
[ldk-java] / ts / structs / ChannelMonitor.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 ChannelMonitor 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.ChannelMonitor_free(this.ptr);
19                     }
20                 }
21         public ChannelMonitor clone() {
22                 number ret = bindings.ChannelMonitor_clone(this.ptr);
23                 const ret_hu_conv: ChannelMonitor = new ChannelMonitor(null, ret);
24                 ret_hu_conv.ptrs_to.add(this);
25                 return ret_hu_conv;
26         }
27
28         public Uint8Array write() {
29                 Uint8Array ret = bindings.ChannelMonitor_write(this.ptr);
30                 return ret;
31         }
32
33         public Result_NoneMonitorUpdateErrorZ update_monitor(ChannelMonitorUpdate updates, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
34                 number ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates == null ? 0 : updates.ptr & ~1, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr);
35                 Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
36                 this.ptrs_to.add(updates);
37                 this.ptrs_to.add(broadcaster);
38                 this.ptrs_to.add(fee_estimator);
39                 this.ptrs_to.add(logger);
40                 return ret_hu_conv;
41         }
42
43         public number get_latest_update_id() {
44                 number ret = bindings.ChannelMonitor_get_latest_update_id(this.ptr);
45                 return ret;
46         }
47
48         public TwoTuple<OutPoint, Uint8Array> get_funding_txo() {
49                 number ret = bindings.ChannelMonitor_get_funding_txo(this.ptr);
50                 number ret_a = bindings.LDKC2Tuple_OutPointScriptZ_get_a(ret);
51                 const ret_a_hu_conv: OutPoint = new OutPoint(null, ret_a);
52                 ret_a_hu_conv.ptrs_to.add(this);;
53                 Uint8Array ret_b = bindings.LDKC2Tuple_OutPointScriptZ_get_b(ret);
54                 TwoTuple<OutPoint, Uint8Array> ret_conv = new TwoTuple<OutPoint, Uint8Array>(ret_a_hu_conv, ret_b);
55                 return ret_conv;
56         }
57
58         public MonitorEvent[] get_and_clear_pending_monitor_events() {
59                 number[] ret = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(this.ptr);
60                 MonitorEvent[] arr_conv_14_arr = new MonitorEvent[ret.length];
61                 for (int o = 0; o < ret.length; o++) {
62                         number arr_conv_14 = ret[o];
63                         const arr_conv_14_hu_conv: MonitorEvent = new MonitorEvent(null, arr_conv_14);
64                         arr_conv_14_hu_conv.ptrs_to.add(this);
65                         arr_conv_14_arr[o] = arr_conv_14_hu_conv;
66                 }
67                 return arr_conv_14_arr;
68         }
69
70         public Event[] get_and_clear_pending_events() {
71                 number[] ret = bindings.ChannelMonitor_get_and_clear_pending_events(this.ptr);
72                 Event[] arr_conv_7_arr = new Event[ret.length];
73                 for (int h = 0; h < ret.length; h++) {
74                         number arr_conv_7 = ret[h];
75                         Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7);
76                         arr_conv_7_hu_conv.ptrs_to.add(this);
77                         arr_conv_7_arr[h] = arr_conv_7_hu_conv;
78                 }
79                 return arr_conv_7_arr;
80         }
81
82         public Uint8Array[] get_latest_holder_commitment_txn(Logger logger) {
83                 Uint8Array[] ret = bindings.ChannelMonitor_get_latest_holder_commitment_txn(this.ptr, logger == null ? 0 : logger.ptr);
84                 this.ptrs_to.add(logger);
85                 return ret;
86         }
87
88         public TwoTuple<Uint8Array, TwoTuple<Number, TxOut>[]>[] block_connected(Uint8Array header, TwoTuple<Number, Uint8Array>[] txdata, number height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
89                 number[] ret = bindings.ChannelMonitor_block_connected(this.ptr, header, (number[])Arrays.stream(txdata).map(arr_conv_30 -> bindings.C2Tuple_usizeTransactionZ_new(arr_conv_30.a, arr_conv_30.b)).toArray(), height, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr);
90                 TwoTuple<Uint8Array, TwoTuple<Number, TxOut>[]>[] arr_conv_49_arr = new TwoTuple[ret.length];
91                 for (int x = 0; x < ret.length; x++) {
92                         number arr_conv_49 = ret[x];
93                         Uint8Array arr_conv_49_a = bindings.LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(arr_conv_49);
94                         number[] arr_conv_49_b = bindings.LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(arr_conv_49);
95                         TwoTuple<Number, TxOut>[] arr_conv_25_arr = new TwoTuple[arr_conv_49_b.length];
96                         for (int z = 0; z < arr_conv_49_b.length; z++) {
97                                 number arr_conv_25 = arr_conv_49_b[z];
98                                 number arr_conv_25_a = bindings.LDKC2Tuple_u32TxOutZ_get_a(arr_conv_25);
99                                 number arr_conv_25_b = bindings.TxOut_clone(bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_25));
100                                 TxOut arr_conv_25_b_conv = new TxOut(null, arr_conv_25_b);;
101                                 TwoTuple<Number, TxOut> arr_conv_25_conv = new TwoTuple<Number, TxOut>(arr_conv_25_a, arr_conv_25_b_conv);
102                                 arr_conv_25_arr[z] = arr_conv_25_conv;
103                         };
104                         TwoTuple<Uint8Array, TwoTuple<Number, TxOut>[]> arr_conv_49_conv = new TwoTuple<Uint8Array, TwoTuple<Number, TxOut>[]>(arr_conv_49_a, arr_conv_25_arr);
105                         arr_conv_49_arr[x] = arr_conv_49_conv;
106                 }
107                 /* TODO 2 TwoTuple<Number, Uint8Array>  */;
108                 this.ptrs_to.add(broadcaster);
109                 this.ptrs_to.add(fee_estimator);
110                 this.ptrs_to.add(logger);
111                 return arr_conv_49_arr;
112         }
113
114         public void block_disconnected(Uint8Array header, number height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
115                 bindings.ChannelMonitor_block_disconnected(this.ptr, header, height, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr);
116                 this.ptrs_to.add(broadcaster);
117                 this.ptrs_to.add(fee_estimator);
118                 this.ptrs_to.add(logger);
119         }
120
121 }