2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class MessageSendEvent extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.MessageSendEvent_free(this.ptr); }
11 static constr_from_ptr(ptr: number): MessageSendEvent {
12 const raw_val: bindings.LDKMessageSendEvent = bindings.LDKMessageSendEvent_ref_from_ptr(ptr);
13 if (raw_val instanceof bindings.LDKMessageSendEvent.SendAcceptChannel) {
14 return new SendAcceptChannel(this.ptr, raw_val);
16 if (raw_val instanceof bindings.LDKMessageSendEvent.SendOpenChannel) {
17 return new SendOpenChannel(this.ptr, raw_val);
19 if (raw_val instanceof bindings.LDKMessageSendEvent.SendFundingCreated) {
20 return new SendFundingCreated(this.ptr, raw_val);
22 if (raw_val instanceof bindings.LDKMessageSendEvent.SendFundingSigned) {
23 return new SendFundingSigned(this.ptr, raw_val);
25 if (raw_val instanceof bindings.LDKMessageSendEvent.SendFundingLocked) {
26 return new SendFundingLocked(this.ptr, raw_val);
28 if (raw_val instanceof bindings.LDKMessageSendEvent.SendAnnouncementSignatures) {
29 return new SendAnnouncementSignatures(this.ptr, raw_val);
31 if (raw_val instanceof bindings.LDKMessageSendEvent.UpdateHTLCs) {
32 return new UpdateHTLCs(this.ptr, raw_val);
34 if (raw_val instanceof bindings.LDKMessageSendEvent.SendRevokeAndACK) {
35 return new SendRevokeAndACK(this.ptr, raw_val);
37 if (raw_val instanceof bindings.LDKMessageSendEvent.SendClosingSigned) {
38 return new SendClosingSigned(this.ptr, raw_val);
40 if (raw_val instanceof bindings.LDKMessageSendEvent.SendShutdown) {
41 return new SendShutdown(this.ptr, raw_val);
43 if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelReestablish) {
44 return new SendChannelReestablish(this.ptr, raw_val);
46 if (raw_val instanceof bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement) {
47 return new BroadcastChannelAnnouncement(this.ptr, raw_val);
49 if (raw_val instanceof bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement) {
50 return new BroadcastNodeAnnouncement(this.ptr, raw_val);
52 if (raw_val instanceof bindings.LDKMessageSendEvent.BroadcastChannelUpdate) {
53 return new BroadcastChannelUpdate(this.ptr, raw_val);
55 if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelUpdate) {
56 return new SendChannelUpdate(this.ptr, raw_val);
58 if (raw_val instanceof bindings.LDKMessageSendEvent.HandleError) {
59 return new HandleError(this.ptr, raw_val);
61 if (raw_val instanceof bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) {
62 return new PaymentFailureNetworkUpdate(this.ptr, raw_val);
64 if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelRangeQuery) {
65 return new SendChannelRangeQuery(this.ptr, raw_val);
67 if (raw_val instanceof bindings.LDKMessageSendEvent.SendShortIdsQuery) {
68 return new SendShortIdsQuery(this.ptr, raw_val);
70 if (raw_val instanceof bindings.LDKMessageSendEvent.SendReplyChannelRange) {
71 return new SendReplyChannelRange(this.ptr, raw_val);
73 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
77 export class SendAcceptChannel extends MessageSendEvent {
78 public node_id: Uint8Array;
79 public msg: AcceptChannel;
80 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAcceptChannel) {
82 this.node_id = obj.node_id;
83 const msg: number = obj.msg;
84 const msg_hu_conv: AcceptChannel = new AcceptChannel(null, msg);
85 msg_hu_conv.ptrs_to.add(this);
86 this.msg = msg_hu_conv;
89 export class SendOpenChannel extends MessageSendEvent {
90 public node_id: Uint8Array;
91 public msg: OpenChannel;
92 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendOpenChannel) {
94 this.node_id = obj.node_id;
95 const msg: number = obj.msg;
96 const msg_hu_conv: OpenChannel = new OpenChannel(null, msg);
97 msg_hu_conv.ptrs_to.add(this);
98 this.msg = msg_hu_conv;
101 export class SendFundingCreated extends MessageSendEvent {
102 public node_id: Uint8Array;
103 public msg: FundingCreated;
104 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingCreated) {
106 this.node_id = obj.node_id;
107 const msg: number = obj.msg;
108 const msg_hu_conv: FundingCreated = new FundingCreated(null, msg);
109 msg_hu_conv.ptrs_to.add(this);
110 this.msg = msg_hu_conv;
113 export class SendFundingSigned extends MessageSendEvent {
114 public node_id: Uint8Array;
115 public msg: FundingSigned;
116 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingSigned) {
118 this.node_id = obj.node_id;
119 const msg: number = obj.msg;
120 const msg_hu_conv: FundingSigned = new FundingSigned(null, msg);
121 msg_hu_conv.ptrs_to.add(this);
122 this.msg = msg_hu_conv;
125 export class SendFundingLocked extends MessageSendEvent {
126 public node_id: Uint8Array;
127 public msg: FundingLocked;
128 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingLocked) {
130 this.node_id = obj.node_id;
131 const msg: number = obj.msg;
132 const msg_hu_conv: FundingLocked = new FundingLocked(null, msg);
133 msg_hu_conv.ptrs_to.add(this);
134 this.msg = msg_hu_conv;
137 export class SendAnnouncementSignatures extends MessageSendEvent {
138 public node_id: Uint8Array;
139 public msg: AnnouncementSignatures;
140 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAnnouncementSignatures) {
142 this.node_id = obj.node_id;
143 const msg: number = obj.msg;
144 const msg_hu_conv: AnnouncementSignatures = new AnnouncementSignatures(null, msg);
145 msg_hu_conv.ptrs_to.add(this);
146 this.msg = msg_hu_conv;
149 export class UpdateHTLCs extends MessageSendEvent {
150 public node_id: Uint8Array;
151 public updates: CommitmentUpdate;
152 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.UpdateHTLCs) {
154 this.node_id = obj.node_id;
155 const updates: number = obj.updates;
156 const updates_hu_conv: CommitmentUpdate = new CommitmentUpdate(null, updates);
157 updates_hu_conv.ptrs_to.add(this);
158 this.updates = updates_hu_conv;
161 export class SendRevokeAndACK extends MessageSendEvent {
162 public node_id: Uint8Array;
163 public msg: RevokeAndACK;
164 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendRevokeAndACK) {
166 this.node_id = obj.node_id;
167 const msg: number = obj.msg;
168 const msg_hu_conv: RevokeAndACK = new RevokeAndACK(null, msg);
169 msg_hu_conv.ptrs_to.add(this);
170 this.msg = msg_hu_conv;
173 export class SendClosingSigned extends MessageSendEvent {
174 public node_id: Uint8Array;
175 public msg: ClosingSigned;
176 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendClosingSigned) {
178 this.node_id = obj.node_id;
179 const msg: number = obj.msg;
180 const msg_hu_conv: ClosingSigned = new ClosingSigned(null, msg);
181 msg_hu_conv.ptrs_to.add(this);
182 this.msg = msg_hu_conv;
185 export class SendShutdown extends MessageSendEvent {
186 public node_id: Uint8Array;
187 public msg: Shutdown;
188 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShutdown) {
190 this.node_id = obj.node_id;
191 const msg: number = obj.msg;
192 const msg_hu_conv: Shutdown = new Shutdown(null, msg);
193 msg_hu_conv.ptrs_to.add(this);
194 this.msg = msg_hu_conv;
197 export class SendChannelReestablish extends MessageSendEvent {
198 public node_id: Uint8Array;
199 public msg: ChannelReestablish;
200 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelReestablish) {
202 this.node_id = obj.node_id;
203 const msg: number = obj.msg;
204 const msg_hu_conv: ChannelReestablish = new ChannelReestablish(null, msg);
205 msg_hu_conv.ptrs_to.add(this);
206 this.msg = msg_hu_conv;
209 export class BroadcastChannelAnnouncement extends MessageSendEvent {
210 public msg: ChannelAnnouncement;
211 public update_msg: ChannelUpdate;
212 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement) {
214 const msg: number = obj.msg;
215 const msg_hu_conv: ChannelAnnouncement = new ChannelAnnouncement(null, msg);
216 msg_hu_conv.ptrs_to.add(this);
217 this.msg = msg_hu_conv;
218 const update_msg: number = obj.update_msg;
219 const update_msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, update_msg);
220 update_msg_hu_conv.ptrs_to.add(this);
221 this.update_msg = update_msg_hu_conv;
224 export class BroadcastNodeAnnouncement extends MessageSendEvent {
225 public msg: NodeAnnouncement;
226 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement) {
228 const msg: number = obj.msg;
229 const msg_hu_conv: NodeAnnouncement = new NodeAnnouncement(null, msg);
230 msg_hu_conv.ptrs_to.add(this);
231 this.msg = msg_hu_conv;
234 export class BroadcastChannelUpdate extends MessageSendEvent {
235 public msg: ChannelUpdate;
236 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelUpdate) {
238 const msg: number = obj.msg;
239 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
240 msg_hu_conv.ptrs_to.add(this);
241 this.msg = msg_hu_conv;
244 export class SendChannelUpdate extends MessageSendEvent {
245 public node_id: Uint8Array;
246 public msg: ChannelUpdate;
247 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelUpdate) {
249 this.node_id = obj.node_id;
250 const msg: number = obj.msg;
251 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
252 msg_hu_conv.ptrs_to.add(this);
253 this.msg = msg_hu_conv;
256 export class HandleError extends MessageSendEvent {
257 public node_id: Uint8Array;
258 public action: ErrorAction;
259 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.HandleError) {
261 this.node_id = obj.node_id;
262 const action: number = obj.action;
263 ErrorAction action_hu_conv = ErrorAction.constr_from_ptr(action);
264 action_hu_conv.ptrs_to.add(this);
265 this.action = action_hu_conv;
268 export class PaymentFailureNetworkUpdate extends MessageSendEvent {
269 public update: HTLCFailChannelUpdate;
270 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) {
272 const update: number = obj.update;
273 HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update);
274 update_hu_conv.ptrs_to.add(this);
275 this.update = update_hu_conv;
278 export class SendChannelRangeQuery extends MessageSendEvent {
279 public node_id: Uint8Array;
280 public msg: QueryChannelRange;
281 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelRangeQuery) {
283 this.node_id = obj.node_id;
284 const msg: number = obj.msg;
285 const msg_hu_conv: QueryChannelRange = new QueryChannelRange(null, msg);
286 msg_hu_conv.ptrs_to.add(this);
287 this.msg = msg_hu_conv;
290 export class SendShortIdsQuery extends MessageSendEvent {
291 public node_id: Uint8Array;
292 public msg: QueryShortChannelIds;
293 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShortIdsQuery) {
295 this.node_id = obj.node_id;
296 const msg: number = obj.msg;
297 const msg_hu_conv: QueryShortChannelIds = new QueryShortChannelIds(null, msg);
298 msg_hu_conv.ptrs_to.add(this);
299 this.msg = msg_hu_conv;
302 export class SendReplyChannelRange extends MessageSendEvent {
303 public node_id: Uint8Array;
304 public msg: ReplyChannelRange;
305 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendReplyChannelRange) {
307 this.node_id = obj.node_id;
308 const msg: number = obj.msg;
309 const msg_hu_conv: ReplyChannelRange = new ReplyChannelRange(null, msg);
310 msg_hu_conv.ptrs_to.add(this);
311 this.msg = msg_hu_conv;
314 public MessageSendEvent clone() {
315 number ret = bindings.MessageSendEvent_clone(this.ptr);
316 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
317 ret_hu_conv.ptrs_to.add(this);