]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/ChannelMessageHandler.ts
Fix CI
[ldk-java] / ts / structs / ChannelMessageHandler.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class ChannelMessageHandler extends CommonBase {
9
10                 bindings_instance?: bindings.LDKChannelMessageHandler;
11
12                 constructor(ptr?: number, arg?: bindings.LDKChannelMessageHandler, messageSendEventsProvider?: bindings.LDKMessageSendEventsProvider) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKChannelMessageHandler_new(arg, messageSendEventsProvider));
19                                         this.ptrs_to.push(arg);
20                                         this.ptrs_to.push(messageSendEventsProvider);
21
22                                     }
23                 }
24
25                 protected finalize() {
26                     if (this.ptr != 0) {
27                         bindings.ChannelMessageHandler_free(this.ptr);
28                     }
29                     super.finalize();
30                 }
31
32                 static new_impl(arg: ChannelMessageHandlerInterface, messageSendEventsProvider_impl: MessageSendEventsProvider.MessageSendEventsProviderInterface): ChannelMessageHandler {
33                     const impl_holder: LDKChannelMessageHandlerHolder = new LDKChannelMessageHandlerHolder();
34                     let structImplementation = <bindings.LDKChannelMessageHandler>{
35                         // todo: in-line interface filling
36                         handle_open_channel (their_node_id: Uint8Array, their_features: number, msg: number): void {
37                                                         const their_features_hu_conv: InitFeatures = new InitFeatures(null, their_features);
38                                 their_features_hu_conv.ptrs_to.add(this);
39                                                         const msg_hu_conv: OpenChannel = new OpenChannel(null, msg);
40                                                         arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
41                                                 },
42
43                                                 handle_accept_channel (their_node_id: Uint8Array, their_features: number, msg: number): void {
44                                                         const their_features_hu_conv: InitFeatures = new InitFeatures(null, their_features);
45                                 their_features_hu_conv.ptrs_to.add(this);
46                                                         const msg_hu_conv: AcceptChannel = new AcceptChannel(null, msg);
47                                                         arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
48                                                 },
49
50                                                 handle_funding_created (their_node_id: Uint8Array, msg: number): void {
51                                                         const msg_hu_conv: FundingCreated = new FundingCreated(null, msg);
52                                                         arg.handle_funding_created(their_node_id, msg_hu_conv);
53                                                 },
54
55                                                 handle_funding_signed (their_node_id: Uint8Array, msg: number): void {
56                                                         const msg_hu_conv: FundingSigned = new FundingSigned(null, msg);
57                                                         arg.handle_funding_signed(their_node_id, msg_hu_conv);
58                                                 },
59
60                                                 handle_funding_locked (their_node_id: Uint8Array, msg: number): void {
61                                                         const msg_hu_conv: FundingLocked = new FundingLocked(null, msg);
62                                                         arg.handle_funding_locked(their_node_id, msg_hu_conv);
63                                                 },
64
65                                                 handle_shutdown (their_node_id: Uint8Array, their_features: number, msg: number): void {
66                                                         const their_features_hu_conv: InitFeatures = new InitFeatures(null, their_features);
67                                                         const msg_hu_conv: Shutdown = new Shutdown(null, msg);
68                                                         arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
69                                                 },
70
71                                                 handle_closing_signed (their_node_id: Uint8Array, msg: number): void {
72                                                         const msg_hu_conv: ClosingSigned = new ClosingSigned(null, msg);
73                                                         arg.handle_closing_signed(their_node_id, msg_hu_conv);
74                                                 },
75
76                                                 handle_update_add_htlc (their_node_id: Uint8Array, msg: number): void {
77                                                         const msg_hu_conv: UpdateAddHTLC = new UpdateAddHTLC(null, msg);
78                                                         arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
79                                                 },
80
81                                                 handle_update_fulfill_htlc (their_node_id: Uint8Array, msg: number): void {
82                                                         const msg_hu_conv: UpdateFulfillHTLC = new UpdateFulfillHTLC(null, msg);
83                                                         arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
84                                                 },
85
86                                                 handle_update_fail_htlc (their_node_id: Uint8Array, msg: number): void {
87                                                         const msg_hu_conv: UpdateFailHTLC = new UpdateFailHTLC(null, msg);
88                                                         arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
89                                                 },
90
91                                                 handle_update_fail_malformed_htlc (their_node_id: Uint8Array, msg: number): void {
92                                                         const msg_hu_conv: UpdateFailMalformedHTLC = new UpdateFailMalformedHTLC(null, msg);
93                                                         arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
94                                                 },
95
96                                                 handle_commitment_signed (their_node_id: Uint8Array, msg: number): void {
97                                                         const msg_hu_conv: CommitmentSigned = new CommitmentSigned(null, msg);
98                                                         arg.handle_commitment_signed(their_node_id, msg_hu_conv);
99                                                 },
100
101                                                 handle_revoke_and_ack (their_node_id: Uint8Array, msg: number): void {
102                                                         const msg_hu_conv: RevokeAndACK = new RevokeAndACK(null, msg);
103                                                         arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
104                                                 },
105
106                                                 handle_update_fee (their_node_id: Uint8Array, msg: number): void {
107                                                         const msg_hu_conv: UpdateFee = new UpdateFee(null, msg);
108                                                         arg.handle_update_fee(their_node_id, msg_hu_conv);
109                                                 },
110
111                                                 handle_announcement_signatures (their_node_id: Uint8Array, msg: number): void {
112                                                         const msg_hu_conv: AnnouncementSignatures = new AnnouncementSignatures(null, msg);
113                                                         arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
114                                                 },
115
116                                                 peer_disconnected (their_node_id: Uint8Array, no_connection_possible: boolean): void {
117                                                         arg.peer_disconnected(their_node_id, no_connection_possible);
118                                                 },
119
120                                                 peer_connected (their_node_id: Uint8Array, msg: number): void {
121                                                         const msg_hu_conv: Init = new Init(null, msg);
122                                                         arg.peer_connected(their_node_id, msg_hu_conv);
123                                                 },
124
125                                                 handle_channel_reestablish (their_node_id: Uint8Array, msg: number): void {
126                                                         const msg_hu_conv: ChannelReestablish = new ChannelReestablish(null, msg);
127                                                         arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
128                                                 },
129
130                                                 handle_channel_update (their_node_id: Uint8Array, msg: number): void {
131                                                         const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
132                                                         arg.handle_channel_update(their_node_id, msg_hu_conv);
133                                                 },
134
135                                                 handle_error (their_node_id: Uint8Array, msg: number): void {
136                                                         const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
137                                                         arg.handle_error(their_node_id, msg_hu_conv);
138                                                 },
139
140                                                 
141                     };
142                     impl_holder.held = new ChannelMessageHandler (null, structImplementation, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
143                 }
144             }
145
146             export interface ChannelMessageHandlerInterface {
147                 handle_open_channel(their_node_id: Uint8Array, their_features: InitFeatures, msg: OpenChannel): void;
148                                 handle_accept_channel(their_node_id: Uint8Array, their_features: InitFeatures, msg: AcceptChannel): void;
149                                 handle_funding_created(their_node_id: Uint8Array, msg: FundingCreated): void;
150                                 handle_funding_signed(their_node_id: Uint8Array, msg: FundingSigned): void;
151                                 handle_funding_locked(their_node_id: Uint8Array, msg: FundingLocked): void;
152                                 handle_shutdown(their_node_id: Uint8Array, their_features: InitFeatures, msg: Shutdown): void;
153                                 handle_closing_signed(their_node_id: Uint8Array, msg: ClosingSigned): void;
154                                 handle_update_add_htlc(their_node_id: Uint8Array, msg: UpdateAddHTLC): void;
155                                 handle_update_fulfill_htlc(their_node_id: Uint8Array, msg: UpdateFulfillHTLC): void;
156                                 handle_update_fail_htlc(their_node_id: Uint8Array, msg: UpdateFailHTLC): void;
157                                 handle_update_fail_malformed_htlc(their_node_id: Uint8Array, msg: UpdateFailMalformedHTLC): void;
158                                 handle_commitment_signed(their_node_id: Uint8Array, msg: CommitmentSigned): void;
159                                 handle_revoke_and_ack(their_node_id: Uint8Array, msg: RevokeAndACK): void;
160                                 handle_update_fee(their_node_id: Uint8Array, msg: UpdateFee): void;
161                                 handle_announcement_signatures(their_node_id: Uint8Array, msg: AnnouncementSignatures): void;
162                                 peer_disconnected(their_node_id: Uint8Array, no_connection_possible: boolean): void;
163                                 peer_connected(their_node_id: Uint8Array, msg: Init): void;
164                                 handle_channel_reestablish(their_node_id: Uint8Array, msg: ChannelReestablish): void;
165                                 handle_channel_update(their_node_id: Uint8Array, msg: ChannelUpdate): void;
166                                 handle_error(their_node_id: Uint8Array, msg: ErrorMessage): void;
167                                 
168             }
169
170             class LDKChannelMessageHandlerHolder {
171                 held: ChannelMessageHandler;
172             }
173         public void handle_open_channel(Uint8Array their_node_id, InitFeatures their_features, OpenChannel msg) {
174                 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
175                 this.ptrs_to.add(their_features);
176                 this.ptrs_to.add(msg);
177         }
178
179         public void handle_accept_channel(Uint8Array their_node_id, InitFeatures their_features, AcceptChannel msg) {
180                 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
181                 this.ptrs_to.add(their_features);
182                 this.ptrs_to.add(msg);
183         }
184
185         public void handle_funding_created(Uint8Array their_node_id, FundingCreated msg) {
186                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
187                 this.ptrs_to.add(msg);
188         }
189
190         public void handle_funding_signed(Uint8Array their_node_id, FundingSigned msg) {
191                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
192                 this.ptrs_to.add(msg);
193         }
194
195         public void handle_funding_locked(Uint8Array their_node_id, FundingLocked msg) {
196                 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
197                 this.ptrs_to.add(msg);
198         }
199
200         public void handle_shutdown(Uint8Array their_node_id, InitFeatures their_features, Shutdown msg) {
201                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
202                 this.ptrs_to.add(their_features);
203                 this.ptrs_to.add(msg);
204         }
205
206         public void handle_closing_signed(Uint8Array their_node_id, ClosingSigned msg) {
207                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
208                 this.ptrs_to.add(msg);
209         }
210
211         public void handle_update_add_htlc(Uint8Array their_node_id, UpdateAddHTLC msg) {
212                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
213                 this.ptrs_to.add(msg);
214         }
215
216         public void handle_update_fulfill_htlc(Uint8Array their_node_id, UpdateFulfillHTLC msg) {
217                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
218                 this.ptrs_to.add(msg);
219         }
220
221         public void handle_update_fail_htlc(Uint8Array their_node_id, UpdateFailHTLC msg) {
222                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
223                 this.ptrs_to.add(msg);
224         }
225
226         public void handle_update_fail_malformed_htlc(Uint8Array their_node_id, UpdateFailMalformedHTLC msg) {
227                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
228                 this.ptrs_to.add(msg);
229         }
230
231         public void handle_commitment_signed(Uint8Array their_node_id, CommitmentSigned msg) {
232                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
233                 this.ptrs_to.add(msg);
234         }
235
236         public void handle_revoke_and_ack(Uint8Array their_node_id, RevokeAndACK msg) {
237                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
238                 this.ptrs_to.add(msg);
239         }
240
241         public void handle_update_fee(Uint8Array their_node_id, UpdateFee msg) {
242                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
243                 this.ptrs_to.add(msg);
244         }
245
246         public void handle_announcement_signatures(Uint8Array their_node_id, AnnouncementSignatures msg) {
247                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
248                 this.ptrs_to.add(msg);
249         }
250
251         public void peer_disconnected(Uint8Array their_node_id, boolean no_connection_possible) {
252                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
253         }
254
255         public void peer_connected(Uint8Array their_node_id, Init msg) {
256                 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
257                 this.ptrs_to.add(msg);
258         }
259
260         public void handle_channel_reestablish(Uint8Array their_node_id, ChannelReestablish msg) {
261                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
262                 this.ptrs_to.add(msg);
263         }
264
265         public void handle_channel_update(Uint8Array their_node_id, ChannelUpdate msg) {
266                 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
267                 this.ptrs_to.add(msg);
268         }
269
270         public void handle_error(Uint8Array their_node_id, ErrorMessage msg) {
271                 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
272                 this.ptrs_to.add(msg);
273         }
274
275 }