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, 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 msg) {
73 Shutdown msg_hu_conv = new Shutdown(null, msg);
74 arg.handle_shutdown(their_node_id, msg_hu_conv);
76 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
77 ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
78 arg.handle_closing_signed(their_node_id, msg_hu_conv);
80 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
81 UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
82 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
84 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
85 UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
86 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
88 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
89 UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
90 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
92 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
93 UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
94 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
96 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
97 CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
98 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
100 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
101 RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
102 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
104 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
105 UpdateFee msg_hu_conv = new UpdateFee(null, msg);
106 arg.handle_update_fee(their_node_id, msg_hu_conv);
108 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
109 AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
110 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
112 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
113 arg.peer_disconnected(their_node_id, no_connection_possible);
115 @Override public void peer_connected(byte[] their_node_id, long msg) {
116 Init msg_hu_conv = new Init(null, msg);
117 arg.peer_connected(their_node_id, msg_hu_conv);
119 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
120 ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
121 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
123 @Override public void handle_error(byte[] their_node_id, long msg) {
124 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
125 arg.handle_error(their_node_id, msg_hu_conv);
127 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
128 return impl_holder.held;
130 public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) {
131 bindings.ChannelMessageHandler_handle_open_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);
136 public void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg) {
137 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
138 this.ptrs_to.add(their_features);
139 this.ptrs_to.add(msg);
142 public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
143 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
144 this.ptrs_to.add(msg);
147 public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
148 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
149 this.ptrs_to.add(msg);
152 public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
153 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
154 this.ptrs_to.add(msg);
157 public void handle_shutdown(byte[] their_node_id, Shutdown msg) {
158 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
159 this.ptrs_to.add(msg);
162 public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
163 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
164 this.ptrs_to.add(msg);
167 public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
168 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
169 this.ptrs_to.add(msg);
172 public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
173 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
174 this.ptrs_to.add(msg);
177 public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
178 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
179 this.ptrs_to.add(msg);
182 public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
183 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
184 this.ptrs_to.add(msg);
187 public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
188 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
189 this.ptrs_to.add(msg);
192 public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
193 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
194 this.ptrs_to.add(msg);
197 public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
198 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
199 this.ptrs_to.add(msg);
202 public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
203 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
204 this.ptrs_to.add(msg);
207 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
208 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
211 public void peer_connected(byte[] their_node_id, Init msg) {
212 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
213 this.ptrs_to.add(msg);
216 public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
217 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
218 this.ptrs_to.add(msg);
221 public void handle_error(byte[] their_node_id, ErrorMessage msg) {
222 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
223 this.ptrs_to.add(msg);