Updated bindings
[ldk-java] / src / main / java / org / ldk / structs / ChannelMonitor.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class ChannelMonitor extends CommonBase {
10         ChannelMonitor(Object _dummy, long ptr) { super(ptr); }
11         @Override @SuppressWarnings("deprecation")
12         protected void finalize() throws Throwable {
13                 super.finalize();
14                 if (ptr != 0) { bindings.ChannelMonitor_free(ptr); }
15         }
16
17         public byte[] write() {
18                 byte[] ret = bindings.ChannelMonitor_write(this.ptr);
19                 return ret;
20         }
21
22         public Result_NoneMonitorUpdateErrorZ update_monitor(ChannelMonitorUpdate updates, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
23                 long 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);
24                 Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
25                 this.ptrs_to.add(updates);
26                 this.ptrs_to.add(broadcaster);
27                 this.ptrs_to.add(fee_estimator);
28                 this.ptrs_to.add(logger);
29                 return ret_hu_conv;
30         }
31
32         public long get_latest_update_id() {
33                 long ret = bindings.ChannelMonitor_get_latest_update_id(this.ptr);
34                 return ret;
35         }
36
37         public TwoTuple<OutPoint, byte[]> get_funding_txo() {
38                 long ret = bindings.ChannelMonitor_get_funding_txo(this.ptr);
39                 long ret_a = bindings.LDKC2Tuple_OutPointScriptZ_get_a(ret);
40                 OutPoint ret_a_hu_conv = new OutPoint(null, ret_a);;
41                 byte[] ret_b = bindings.LDKC2Tuple_OutPointScriptZ_get_b(ret);
42                 TwoTuple<OutPoint, byte[]> ret_conv = new TwoTuple<OutPoint, byte[]>(ret_a_hu_conv, ret_b);
43                 return ret_conv;
44         }
45
46         public MonitorEvent[] get_and_clear_pending_monitor_events() {
47                 long[] ret = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(this.ptr);
48                 MonitorEvent[] arr_conv_14_arr = new MonitorEvent[ret.length];
49                 for (int o = 0; o < ret.length; o++) {
50                         long arr_conv_14 = ret[o];
51                         MonitorEvent arr_conv_14_hu_conv = new MonitorEvent(null, arr_conv_14);
52                         arr_conv_14_arr[o] = arr_conv_14_hu_conv;
53                 }
54                 return arr_conv_14_arr;
55         }
56
57         public Event[] get_and_clear_pending_events() {
58                 long[] ret = bindings.ChannelMonitor_get_and_clear_pending_events(this.ptr);
59                 Event[] arr_conv_7_arr = new Event[ret.length];
60                 for (int h = 0; h < ret.length; h++) {
61                         long arr_conv_7 = ret[h];
62                         Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7);
63                         arr_conv_7_hu_conv.ptrs_to.add(this);
64                         arr_conv_7_arr[h] = arr_conv_7_hu_conv;
65                 }
66                 return arr_conv_7_arr;
67         }
68
69         public byte[][] get_latest_holder_commitment_txn(Logger logger) {
70                 byte[][] ret = bindings.ChannelMonitor_get_latest_holder_commitment_txn(this.ptr, logger == null ? 0 : logger.ptr);
71                 this.ptrs_to.add(logger);
72                 return ret;
73         }
74
75         public TwoTuple<byte[], TwoTuple<Integer, TxOut>[]>[] block_connected(byte[] header, TwoTuple<Long, byte[]>[] txdata, int height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
76                 long[] ret = bindings.ChannelMonitor_block_connected(this.ptr, header, Arrays.stream(txdata).mapToLong(arr_conv_24 -> bindings.C2Tuple_usizeTransactionZ_new(arr_conv_24.a, arr_conv_24.b)).toArray(), height, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr);
77                 TwoTuple<byte[], TwoTuple<Integer, TxOut>[]>[] arr_conv_46_arr = new TwoTuple[ret.length];
78                 for (int u = 0; u < ret.length; u++) {
79                         long arr_conv_46 = ret[u];
80                         byte[] arr_conv_46_a = bindings.LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(arr_conv_46);
81                         long[] arr_conv_46_b = bindings.LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(arr_conv_46);
82                         TwoTuple<Integer, TxOut>[] arr_conv_26_arr = new TwoTuple[arr_conv_46_b.length];
83                         for (int a = 0; a < arr_conv_46_b.length; a++) {
84                                 long arr_conv_26 = arr_conv_46_b[a];
85                                 int arr_conv_26_a = bindings.LDKC2Tuple_u32TxOutZ_get_a(arr_conv_26);
86                                 long arr_conv_26_b = bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_26);
87                                 TxOut arr_conv_26_b_conv = new TxOut(null, arr_conv_26_b);;
88                                 TwoTuple<Integer, TxOut> arr_conv_26_conv = new TwoTuple<Integer, TxOut>(arr_conv_26_a, arr_conv_26_b_conv);
89                                 arr_conv_26_arr[a] = arr_conv_26_conv;
90                         };
91                         TwoTuple<byte[], TwoTuple<Integer, TxOut>[]> arr_conv_46_conv = new TwoTuple<byte[], TwoTuple<Integer, TxOut>[]>(arr_conv_46_a, arr_conv_26_arr);
92                         arr_conv_46_arr[u] = arr_conv_46_conv;
93                 }
94                 /* TODO 2 TwoTuple<Long, byte[]>  */;
95                 this.ptrs_to.add(broadcaster);
96                 this.ptrs_to.add(fee_estimator);
97                 this.ptrs_to.add(logger);
98                 return arr_conv_46_arr;
99         }
100
101         public void block_disconnected(byte[] header, int height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
102                 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);
103                 this.ptrs_to.add(broadcaster);
104                 this.ptrs_to.add(fee_estimator);
105                 this.ptrs_to.add(logger);
106         }
107
108 }