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