5dc8103c30e56c5af069bf7f702bd7338a7ea7b5
[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         public ChannelMessageHandler(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider) {
45                 this(new bindings.LDKChannelMessageHandler() {
46                         @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
47                                 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
48                                 OpenChannel msg_hu_conv = new OpenChannel(null, msg);
49                                 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
50                         }
51                         @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
52                                 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
53                                 AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
54                                 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
55                         }
56                         @Override public void handle_funding_created(byte[] their_node_id, long msg) {
57                                 FundingCreated msg_hu_conv = new FundingCreated(null, msg);
58                                 arg.handle_funding_created(their_node_id, msg_hu_conv);
59                         }
60                         @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
61                                 FundingSigned msg_hu_conv = new FundingSigned(null, msg);
62                                 arg.handle_funding_signed(their_node_id, msg_hu_conv);
63                         }
64                         @Override public void handle_funding_locked(byte[] their_node_id, long msg) {
65                                 FundingLocked msg_hu_conv = new FundingLocked(null, msg);
66                                 arg.handle_funding_locked(their_node_id, msg_hu_conv);
67                         }
68                         @Override public void handle_shutdown(byte[] their_node_id, long msg) {
69                                 Shutdown msg_hu_conv = new Shutdown(null, msg);
70                                 arg.handle_shutdown(their_node_id, msg_hu_conv);
71                         }
72                         @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
73                                 ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
74                                 arg.handle_closing_signed(their_node_id, msg_hu_conv);
75                         }
76                         @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
77                                 UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
78                                 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
79                         }
80                         @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
81                                 UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
82                                 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
83                         }
84                         @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
85                                 UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
86                                 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
87                         }
88                         @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
89                                 UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
90                                 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
91                         }
92                         @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
93                                 CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
94                                 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
95                         }
96                         @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
97                                 RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
98                                 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
99                         }
100                         @Override public void handle_update_fee(byte[] their_node_id, long msg) {
101                                 UpdateFee msg_hu_conv = new UpdateFee(null, msg);
102                                 arg.handle_update_fee(their_node_id, msg_hu_conv);
103                         }
104                         @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
105                                 AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
106                                 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
107                         }
108                         @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
109                                 arg.peer_disconnected(their_node_id, no_connection_possible);
110                         }
111                         @Override public void peer_connected(byte[] their_node_id, long msg) {
112                                 Init msg_hu_conv = new Init(null, msg);
113                                 arg.peer_connected(their_node_id, msg_hu_conv);
114                         }
115                         @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
116                                 ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
117                                 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
118                         }
119                         @Override public void handle_error(byte[] their_node_id, long msg) {
120                                 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
121                                 arg.handle_error(their_node_id, msg_hu_conv);
122                         }
123                 }, new MessageSendEventsProvider(MessageSendEventsProvider).bindings_instance);
124         }
125         // Skipped ChannelMessageHandler_handle_open_channel
126         // Skipped ChannelMessageHandler_handle_accept_channel
127         public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
128                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
129                 this.ptrs_to.add(msg);
130         }
131
132         public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
133                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
134                 this.ptrs_to.add(msg);
135         }
136
137         public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
138                 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
139                 this.ptrs_to.add(msg);
140         }
141
142         public void handle_shutdown(byte[] their_node_id, Shutdown msg) {
143                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
144                 this.ptrs_to.add(msg);
145         }
146
147         public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
148                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
149                 this.ptrs_to.add(msg);
150         }
151
152         public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
153                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
154                 this.ptrs_to.add(msg);
155         }
156
157         public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
158                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
159                 this.ptrs_to.add(msg);
160         }
161
162         public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
163                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
164                 this.ptrs_to.add(msg);
165         }
166
167         public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
168                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
169                 this.ptrs_to.add(msg);
170         }
171
172         public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
173                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
174                 this.ptrs_to.add(msg);
175         }
176
177         public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
178                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
179                 this.ptrs_to.add(msg);
180         }
181
182         public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
183                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
184                 this.ptrs_to.add(msg);
185         }
186
187         public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
188                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
189                 this.ptrs_to.add(msg);
190         }
191
192         public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
193                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
194         }
195
196         public void peer_connected(byte[] their_node_id, Init msg) {
197                 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
198                 this.ptrs_to.add(msg);
199         }
200
201         public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
202                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
203                 this.ptrs_to.add(msg);
204         }
205
206         public void handle_error(byte[] their_node_id, ErrorMessage msg) {
207                 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
208                 this.ptrs_to.add(msg);
209         }
210
211 }