Updated bindings
[ldk-java] / src / main / java / org / ldk / structs / ChannelMessageHandler.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 ChannelMessageHandler extends CommonBase {
10         final bindings.LDKChannelMessageHandler bindings_instance;
11         ChannelMessageHandler(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private ChannelMessageHandler(bindings.LDKChannelMessageHandler arg, bindings.LDKMessageSendEventsProvider MessageSendEventsProvider) {
13                 super(bindings.LDKChannelMessageHandler_new(arg, MessageSendEventsProvider));
14                 this.ptrs_to.add(arg);
15                 this.ptrs_to.add(MessageSendEventsProvider);
16                 this.bindings_instance = arg;
17         }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize();
21         }
22
23         public static interface ChannelMessageHandlerInterface {
24                 void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg);
25                 void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg);
26                 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
27                 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
28                 void handle_funding_locked(byte[] their_node_id, FundingLocked msg);
29                 void handle_shutdown(byte[] their_node_id, Shutdown msg);
30                 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
31                 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
32                 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
33                 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
34                 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
35                 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
36                 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
37                 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
38                 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
39                 void peer_disconnected(byte[] their_node_id, boolean no_connection_possible);
40                 void peer_connected(byte[] their_node_id, Init msg);
41                 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
42                 void handle_error(byte[] their_node_id, ErrorMessage msg);
43         }
44         private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
45         public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
46                 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
47                 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
48                         @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
49                                 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
50                                 OpenChannel msg_hu_conv = new OpenChannel(null, msg);
51                                 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
52                         }
53                         @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
54                                 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
55                                 AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
56                                 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
57                         }
58                         @Override public void handle_funding_created(byte[] their_node_id, long msg) {
59                                 FundingCreated msg_hu_conv = new FundingCreated(null, msg);
60                                 arg.handle_funding_created(their_node_id, msg_hu_conv);
61                         }
62                         @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
63                                 FundingSigned msg_hu_conv = new FundingSigned(null, msg);
64                                 arg.handle_funding_signed(their_node_id, msg_hu_conv);
65                         }
66                         @Override public void handle_funding_locked(byte[] their_node_id, long msg) {
67                                 FundingLocked msg_hu_conv = new FundingLocked(null, msg);
68                                 arg.handle_funding_locked(their_node_id, msg_hu_conv);
69                         }
70                         @Override public void handle_shutdown(byte[] their_node_id, long msg) {
71                                 Shutdown msg_hu_conv = new Shutdown(null, msg);
72                                 arg.handle_shutdown(their_node_id, msg_hu_conv);
73                         }
74                         @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
75                                 ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
76                                 arg.handle_closing_signed(their_node_id, msg_hu_conv);
77                         }
78                         @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
79                                 UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
80                                 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
81                         }
82                         @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
83                                 UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
84                                 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
85                         }
86                         @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
87                                 UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
88                                 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
89                         }
90                         @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
91                                 UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
92                                 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
93                         }
94                         @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
95                                 CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
96                                 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
97                         }
98                         @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
99                                 RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
100                                 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
101                         }
102                         @Override public void handle_update_fee(byte[] their_node_id, long msg) {
103                                 UpdateFee msg_hu_conv = new UpdateFee(null, msg);
104                                 arg.handle_update_fee(their_node_id, msg_hu_conv);
105                         }
106                         @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
107                                 AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
108                                 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
109                         }
110                         @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
111                                 arg.peer_disconnected(their_node_id, no_connection_possible);
112                         }
113                         @Override public void peer_connected(byte[] their_node_id, long msg) {
114                                 Init msg_hu_conv = new Init(null, msg);
115                                 arg.peer_connected(their_node_id, msg_hu_conv);
116                         }
117                         @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
118                                 ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
119                                 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
120                         }
121                         @Override public void handle_error(byte[] their_node_id, long msg) {
122                                 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
123                                 arg.handle_error(their_node_id, msg_hu_conv);
124                         }
125                 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
126                 return impl_holder.held;
127         }
128         public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) {
129                 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
130                 this.ptrs_to.add(their_features);
131                 this.ptrs_to.add(msg);
132         }
133
134         public void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg) {
135                 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
136                 this.ptrs_to.add(their_features);
137                 this.ptrs_to.add(msg);
138         }
139
140         public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
141                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
142                 this.ptrs_to.add(msg);
143         }
144
145         public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
146                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
147                 this.ptrs_to.add(msg);
148         }
149
150         public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
151                 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
152                 this.ptrs_to.add(msg);
153         }
154
155         public void handle_shutdown(byte[] their_node_id, Shutdown msg) {
156                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
157                 this.ptrs_to.add(msg);
158         }
159
160         public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
161                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
162                 this.ptrs_to.add(msg);
163         }
164
165         public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
166                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
167                 this.ptrs_to.add(msg);
168         }
169
170         public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
171                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
172                 this.ptrs_to.add(msg);
173         }
174
175         public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
176                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
177                 this.ptrs_to.add(msg);
178         }
179
180         public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
181                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
182                 this.ptrs_to.add(msg);
183         }
184
185         public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
186                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
187                 this.ptrs_to.add(msg);
188         }
189
190         public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
191                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
192                 this.ptrs_to.add(msg);
193         }
194
195         public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
196                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
197                 this.ptrs_to.add(msg);
198         }
199
200         public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
201                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
202                 this.ptrs_to.add(msg);
203         }
204
205         public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
206                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
207         }
208
209         public void peer_connected(byte[] their_node_id, Init msg) {
210                 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
211                 this.ptrs_to.add(msg);
212         }
213
214         public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
215                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
216                 this.ptrs_to.add(msg);
217         }
218
219         public void handle_error(byte[] their_node_id, ErrorMessage msg) {
220                 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
221                 this.ptrs_to.add(msg);
222         }
223
224 }