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 OpenChannel msg_hu_conv = new OpenChannel(null, msg);
51 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
110 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
111 arg.peer_disconnected(their_node_id, no_connection_possible);
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);
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);
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);
125 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
126 return impl_holder.held;
128 // Skipped ChannelMessageHandler_handle_open_channel
129 // Skipped ChannelMessageHandler_handle_accept_channel
130 public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
131 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
132 this.ptrs_to.add(msg);
135 public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
136 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
137 this.ptrs_to.add(msg);
140 public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
141 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
142 this.ptrs_to.add(msg);
145 public void handle_shutdown(byte[] their_node_id, Shutdown msg) {
146 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
147 this.ptrs_to.add(msg);
150 public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
151 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
152 this.ptrs_to.add(msg);
155 public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
156 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
157 this.ptrs_to.add(msg);
160 public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
161 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
162 this.ptrs_to.add(msg);
165 public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
166 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
167 this.ptrs_to.add(msg);
170 public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
171 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
172 this.ptrs_to.add(msg);
175 public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
176 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
177 this.ptrs_to.add(msg);
180 public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
181 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
182 this.ptrs_to.add(msg);
185 public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
186 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
187 this.ptrs_to.add(msg);
190 public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
191 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
192 this.ptrs_to.add(msg);
195 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
196 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
199 public void peer_connected(byte[] their_node_id, Init msg) {
200 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
201 this.ptrs_to.add(msg);
204 public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
205 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
206 this.ptrs_to.add(msg);
209 public void handle_error(byte[] their_node_id, ErrorMessage msg) {
210 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
211 this.ptrs_to.add(msg);