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.bindings_instance = arg;
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize();
22 public static interface ChannelMessageHandlerInterface {
23 void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg);
24 void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg);
25 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
26 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
27 void handle_funding_locked(byte[] their_node_id, FundingLocked msg);
28 void handle_shutdown(byte[] their_node_id, Shutdown msg);
29 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
30 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
31 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
32 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
33 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
34 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
35 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
36 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
37 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
38 void peer_disconnected(byte[] their_node_id, boolean no_connection_possible);
39 void peer_connected(byte[] their_node_id, Init msg);
40 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
41 void handle_error(byte[] their_node_id, ErrorMessage msg);
43 public ChannelMessageHandler(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider) {
44 this(new bindings.LDKChannelMessageHandler() {
45 @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
46 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
47 OpenChannel msg_hu_conv = new OpenChannel(null, msg);
48 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
50 @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
51 InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
52 AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
53 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
55 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
56 FundingCreated msg_hu_conv = new FundingCreated(null, msg);
57 arg.handle_funding_created(their_node_id, msg_hu_conv);
59 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
60 FundingSigned msg_hu_conv = new FundingSigned(null, msg);
61 arg.handle_funding_signed(their_node_id, msg_hu_conv);
63 @Override public void handle_funding_locked(byte[] their_node_id, long msg) {
64 FundingLocked msg_hu_conv = new FundingLocked(null, msg);
65 arg.handle_funding_locked(their_node_id, msg_hu_conv);
67 @Override public void handle_shutdown(byte[] their_node_id, long msg) {
68 Shutdown msg_hu_conv = new Shutdown(null, msg);
69 arg.handle_shutdown(their_node_id, msg_hu_conv);
71 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
72 ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
73 arg.handle_closing_signed(their_node_id, msg_hu_conv);
75 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
76 UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
77 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
79 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
80 UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
81 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
83 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
84 UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
85 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
87 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
88 UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
89 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
91 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
92 CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
93 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
95 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
96 RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
97 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
99 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
100 UpdateFee msg_hu_conv = new UpdateFee(null, msg);
101 arg.handle_update_fee(their_node_id, msg_hu_conv);
103 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
104 AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
105 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
107 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
108 arg.peer_disconnected(their_node_id, no_connection_possible);
110 @Override public void peer_connected(byte[] their_node_id, long msg) {
111 Init msg_hu_conv = new Init(null, msg);
112 arg.peer_connected(their_node_id, msg_hu_conv);
114 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
115 ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
116 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
118 @Override public void handle_error(byte[] their_node_id, long msg) {
119 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
120 arg.handle_error(their_node_id, msg_hu_conv);
122 }, new MessageSendEventsProvider(MessageSendEventsProvider).bindings_instance);
124 // Skipped ChannelMessageHandler_handle_open_channel
125 // Skipped ChannelMessageHandler_handle_accept_channel
126 public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
127 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
128 this.ptrs_to.add(msg);
131 public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
132 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
133 this.ptrs_to.add(msg);
136 public void handle_funding_locked(byte[] their_node_id, FundingLocked msg) {
137 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
138 this.ptrs_to.add(msg);
141 public void handle_shutdown(byte[] their_node_id, Shutdown msg) {
142 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
143 this.ptrs_to.add(msg);
146 public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
147 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
148 this.ptrs_to.add(msg);
151 public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
152 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
153 this.ptrs_to.add(msg);
156 public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
157 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
158 this.ptrs_to.add(msg);
161 public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
162 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
163 this.ptrs_to.add(msg);
166 public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
167 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
168 this.ptrs_to.add(msg);
171 public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
172 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
173 this.ptrs_to.add(msg);
176 public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
177 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
178 this.ptrs_to.add(msg);
181 public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
182 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
183 this.ptrs_to.add(msg);
186 public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
187 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
188 this.ptrs_to.add(msg);
191 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
192 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
195 public void peer_connected(byte[] their_node_id, Init msg) {
196 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
197 this.ptrs_to.add(msg);
200 public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
201 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
202 this.ptrs_to.add(msg);
205 public void handle_error(byte[] their_node_id, ErrorMessage msg) {
206 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
207 this.ptrs_to.add(msg);