1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
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;
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize();
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, InitFeatures their_features, 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);
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 their_features_hu_conv.ptrs_to.add(this);
51 OpenChannel msg_hu_conv = new OpenChannel(null, msg);
52 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
54 @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
55 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
56 their_features_hu_conv.ptrs_to.add(this);
57 AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
58 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
60 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
61 FundingCreated msg_hu_conv = new FundingCreated(null, msg);
62 arg.handle_funding_created(their_node_id, msg_hu_conv);
64 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
65 FundingSigned msg_hu_conv = new FundingSigned(null, msg);
66 arg.handle_funding_signed(their_node_id, msg_hu_conv);
68 @Override public void handle_funding_locked(byte[] their_node_id, long msg) {
69 FundingLocked msg_hu_conv = new FundingLocked(null, msg);
70 arg.handle_funding_locked(their_node_id, msg_hu_conv);
72 @Override public void handle_shutdown(byte[] their_node_id, long their_features, long msg) {
73 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
74 Shutdown msg_hu_conv = new Shutdown(null, msg);
75 arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
77 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
78 ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
79 arg.handle_closing_signed(their_node_id, msg_hu_conv);
81 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
82 UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
83 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
85 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
86 UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
87 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
89 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
90 UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
91 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
93 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
94 UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
95 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
97 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
98 CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
99 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
101 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
102 RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
103 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
105 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
106 UpdateFee msg_hu_conv = new UpdateFee(null, msg);
107 arg.handle_update_fee(their_node_id, msg_hu_conv);
109 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
110 AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
111 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
113 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
114 arg.peer_disconnected(their_node_id, no_connection_possible);
116 @Override public void peer_connected(byte[] their_node_id, long msg) {
117 Init msg_hu_conv = new Init(null, msg);
118 arg.peer_connected(their_node_id, msg_hu_conv);
120 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
121 ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
122 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
124 @Override public void handle_error(byte[] their_node_id, long msg) {
125 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
126 arg.handle_error(their_node_id, msg_hu_conv);
128 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
129 return impl_holder.held;
131 public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) {
132 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
133 this.ptrs_to.add(their_features);
134 this.ptrs_to.add(msg);
137 public void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg) {
138 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
139 this.ptrs_to.add(their_features);
140 this.ptrs_to.add(msg);
143 public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
144 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
145 this.ptrs_to.add(msg);
148 public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
149 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
150 this.ptrs_to.add(msg);
153 public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
154 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
155 this.ptrs_to.add(msg);
158 public void handle_shutdown(byte[] their_node_id, InitFeatures their_features, Shutdown msg) {
159 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
160 this.ptrs_to.add(their_features);
161 this.ptrs_to.add(msg);
164 public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
165 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
166 this.ptrs_to.add(msg);
169 public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
170 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
171 this.ptrs_to.add(msg);
174 public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
175 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
176 this.ptrs_to.add(msg);
179 public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
180 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
181 this.ptrs_to.add(msg);
184 public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
185 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
186 this.ptrs_to.add(msg);
189 public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
190 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
191 this.ptrs_to.add(msg);
194 public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
195 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
196 this.ptrs_to.add(msg);
199 public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
200 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
201 this.ptrs_to.add(msg);
204 public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
205 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
206 this.ptrs_to.add(msg);
209 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
210 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
213 public void peer_connected(byte[] their_node_id, Init msg) {
214 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
215 this.ptrs_to.add(msg);
218 public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
219 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
220 this.ptrs_to.add(msg);
223 public void handle_error(byte[] their_node_id, ErrorMessage msg) {
224 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
225 this.ptrs_to.add(msg);