Update bindings to latest upstream.
[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_error (their_node_id: Uint8Array, msg: number): void {
131                                                         const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
132                                                         arg.handle_error(their_node_id, msg_hu_conv);
133                                                 },
134
135                                                 
136                     };
137                     impl_holder.held = new ChannelMessageHandler (null, structImplementation, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
138                 }
139             }
140
141             export interface ChannelMessageHandlerInterface {
142                 handle_open_channel(their_node_id: Uint8Array, their_features: InitFeatures, msg: OpenChannel): void;
143                                 handle_accept_channel(their_node_id: Uint8Array, their_features: InitFeatures, msg: AcceptChannel): void;
144                                 handle_funding_created(their_node_id: Uint8Array, msg: FundingCreated): void;
145                                 handle_funding_signed(their_node_id: Uint8Array, msg: FundingSigned): void;
146                                 handle_funding_locked(their_node_id: Uint8Array, msg: FundingLocked): void;
147                                 handle_shutdown(their_node_id: Uint8Array, their_features: InitFeatures, msg: Shutdown): void;
148                                 handle_closing_signed(their_node_id: Uint8Array, msg: ClosingSigned): void;
149                                 handle_update_add_htlc(their_node_id: Uint8Array, msg: UpdateAddHTLC): void;
150                                 handle_update_fulfill_htlc(their_node_id: Uint8Array, msg: UpdateFulfillHTLC): void;
151                                 handle_update_fail_htlc(their_node_id: Uint8Array, msg: UpdateFailHTLC): void;
152                                 handle_update_fail_malformed_htlc(their_node_id: Uint8Array, msg: UpdateFailMalformedHTLC): void;
153                                 handle_commitment_signed(their_node_id: Uint8Array, msg: CommitmentSigned): void;
154                                 handle_revoke_and_ack(their_node_id: Uint8Array, msg: RevokeAndACK): void;
155                                 handle_update_fee(their_node_id: Uint8Array, msg: UpdateFee): void;
156                                 handle_announcement_signatures(their_node_id: Uint8Array, msg: AnnouncementSignatures): void;
157                                 peer_disconnected(their_node_id: Uint8Array, no_connection_possible: boolean): void;
158                                 peer_connected(their_node_id: Uint8Array, msg: Init): void;
159                                 handle_channel_reestablish(their_node_id: Uint8Array, msg: ChannelReestablish): void;
160                                 handle_error(their_node_id: Uint8Array, msg: ErrorMessage): void;
161                                 
162             }
163
164             class LDKChannelMessageHandlerHolder {
165                 held: ChannelMessageHandler;
166             }
167         public void handle_open_channel(Uint8Array their_node_id, InitFeatures their_features, OpenChannel msg) {
168                 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
169                 this.ptrs_to.add(their_features);
170                 this.ptrs_to.add(msg);
171         }
172
173         public void handle_accept_channel(Uint8Array their_node_id, InitFeatures their_features, AcceptChannel msg) {
174                 bindings.ChannelMessageHandler_handle_accept_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_funding_created(Uint8Array their_node_id, FundingCreated msg) {
180                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
181                 this.ptrs_to.add(msg);
182         }
183
184         public void handle_funding_signed(Uint8Array their_node_id, FundingSigned msg) {
185                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
186                 this.ptrs_to.add(msg);
187         }
188
189         public void handle_funding_locked(Uint8Array their_node_id, FundingLocked msg) {
190                 bindings.ChannelMessageHandler_handle_funding_locked(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
191                 this.ptrs_to.add(msg);
192         }
193
194         public void handle_shutdown(Uint8Array their_node_id, InitFeatures their_features, Shutdown msg) {
195                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1);
196                 this.ptrs_to.add(their_features);
197                 this.ptrs_to.add(msg);
198         }
199
200         public void handle_closing_signed(Uint8Array their_node_id, ClosingSigned msg) {
201                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
202                 this.ptrs_to.add(msg);
203         }
204
205         public void handle_update_add_htlc(Uint8Array their_node_id, UpdateAddHTLC msg) {
206                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
207                 this.ptrs_to.add(msg);
208         }
209
210         public void handle_update_fulfill_htlc(Uint8Array their_node_id, UpdateFulfillHTLC msg) {
211                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
212                 this.ptrs_to.add(msg);
213         }
214
215         public void handle_update_fail_htlc(Uint8Array their_node_id, UpdateFailHTLC msg) {
216                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
217                 this.ptrs_to.add(msg);
218         }
219
220         public void handle_update_fail_malformed_htlc(Uint8Array their_node_id, UpdateFailMalformedHTLC msg) {
221                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
222                 this.ptrs_to.add(msg);
223         }
224
225         public void handle_commitment_signed(Uint8Array their_node_id, CommitmentSigned msg) {
226                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
227                 this.ptrs_to.add(msg);
228         }
229
230         public void handle_revoke_and_ack(Uint8Array their_node_id, RevokeAndACK msg) {
231                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
232                 this.ptrs_to.add(msg);
233         }
234
235         public void handle_update_fee(Uint8Array their_node_id, UpdateFee msg) {
236                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
237                 this.ptrs_to.add(msg);
238         }
239
240         public void handle_announcement_signatures(Uint8Array their_node_id, AnnouncementSignatures msg) {
241                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
242                 this.ptrs_to.add(msg);
243         }
244
245         public void peer_disconnected(Uint8Array their_node_id, boolean no_connection_possible) {
246                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, their_node_id, no_connection_possible);
247         }
248
249         public void peer_connected(Uint8Array their_node_id, Init msg) {
250                 bindings.ChannelMessageHandler_peer_connected(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
251                 this.ptrs_to.add(msg);
252         }
253
254         public void handle_channel_reestablish(Uint8Array their_node_id, ChannelReestablish msg) {
255                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
256                 this.ptrs_to.add(msg);
257         }
258
259         public void handle_error(Uint8Array their_node_id, ErrorMessage msg) {
260                 bindings.ChannelMessageHandler_handle_error(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
261                 this.ptrs_to.add(msg);
262         }
263
264 }