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.HandleError) {
56 return new HandleError(this.ptr, raw_val);
58 if (raw_val instanceof bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) {
59 return new PaymentFailureNetworkUpdate(this.ptr, raw_val);
61 if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelRangeQuery) {
62 return new SendChannelRangeQuery(this.ptr, raw_val);
64 if (raw_val instanceof bindings.LDKMessageSendEvent.SendShortIdsQuery) {
65 return new SendShortIdsQuery(this.ptr, raw_val);
67 if (raw_val instanceof bindings.LDKMessageSendEvent.SendReplyChannelRange) {
68 return new SendReplyChannelRange(this.ptr, raw_val);
70 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
74 export class SendAcceptChannel extends MessageSendEvent {
75 public node_id: Uint8Array;
76 public msg: AcceptChannel;
77 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAcceptChannel) {
79 this.node_id = obj.node_id;
80 const msg: number = obj.msg;
81 const msg_hu_conv: AcceptChannel = new AcceptChannel(null, msg);
82 msg_hu_conv.ptrs_to.add(this);
83 this.msg = msg_hu_conv;
86 export class SendOpenChannel extends MessageSendEvent {
87 public node_id: Uint8Array;
88 public msg: OpenChannel;
89 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendOpenChannel) {
91 this.node_id = obj.node_id;
92 const msg: number = obj.msg;
93 const msg_hu_conv: OpenChannel = new OpenChannel(null, msg);
94 msg_hu_conv.ptrs_to.add(this);
95 this.msg = msg_hu_conv;
98 export class SendFundingCreated extends MessageSendEvent {
99 public node_id: Uint8Array;
100 public msg: FundingCreated;
101 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingCreated) {
103 this.node_id = obj.node_id;
104 const msg: number = obj.msg;
105 const msg_hu_conv: FundingCreated = new FundingCreated(null, msg);
106 msg_hu_conv.ptrs_to.add(this);
107 this.msg = msg_hu_conv;
110 export class SendFundingSigned extends MessageSendEvent {
111 public node_id: Uint8Array;
112 public msg: FundingSigned;
113 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingSigned) {
115 this.node_id = obj.node_id;
116 const msg: number = obj.msg;
117 const msg_hu_conv: FundingSigned = new FundingSigned(null, msg);
118 msg_hu_conv.ptrs_to.add(this);
119 this.msg = msg_hu_conv;
122 export class SendFundingLocked extends MessageSendEvent {
123 public node_id: Uint8Array;
124 public msg: FundingLocked;
125 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingLocked) {
127 this.node_id = obj.node_id;
128 const msg: number = obj.msg;
129 const msg_hu_conv: FundingLocked = new FundingLocked(null, msg);
130 msg_hu_conv.ptrs_to.add(this);
131 this.msg = msg_hu_conv;
134 export class SendAnnouncementSignatures extends MessageSendEvent {
135 public node_id: Uint8Array;
136 public msg: AnnouncementSignatures;
137 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAnnouncementSignatures) {
139 this.node_id = obj.node_id;
140 const msg: number = obj.msg;
141 const msg_hu_conv: AnnouncementSignatures = new AnnouncementSignatures(null, msg);
142 msg_hu_conv.ptrs_to.add(this);
143 this.msg = msg_hu_conv;
146 export class UpdateHTLCs extends MessageSendEvent {
147 public node_id: Uint8Array;
148 public updates: CommitmentUpdate;
149 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.UpdateHTLCs) {
151 this.node_id = obj.node_id;
152 const updates: number = obj.updates;
153 const updates_hu_conv: CommitmentUpdate = new CommitmentUpdate(null, updates);
154 updates_hu_conv.ptrs_to.add(this);
155 this.updates = updates_hu_conv;
158 export class SendRevokeAndACK extends MessageSendEvent {
159 public node_id: Uint8Array;
160 public msg: RevokeAndACK;
161 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendRevokeAndACK) {
163 this.node_id = obj.node_id;
164 const msg: number = obj.msg;
165 const msg_hu_conv: RevokeAndACK = new RevokeAndACK(null, msg);
166 msg_hu_conv.ptrs_to.add(this);
167 this.msg = msg_hu_conv;
170 export class SendClosingSigned extends MessageSendEvent {
171 public node_id: Uint8Array;
172 public msg: ClosingSigned;
173 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendClosingSigned) {
175 this.node_id = obj.node_id;
176 const msg: number = obj.msg;
177 const msg_hu_conv: ClosingSigned = new ClosingSigned(null, msg);
178 msg_hu_conv.ptrs_to.add(this);
179 this.msg = msg_hu_conv;
182 export class SendShutdown extends MessageSendEvent {
183 public node_id: Uint8Array;
184 public msg: Shutdown;
185 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShutdown) {
187 this.node_id = obj.node_id;
188 const msg: number = obj.msg;
189 const msg_hu_conv: Shutdown = new Shutdown(null, msg);
190 msg_hu_conv.ptrs_to.add(this);
191 this.msg = msg_hu_conv;
194 export class SendChannelReestablish extends MessageSendEvent {
195 public node_id: Uint8Array;
196 public msg: ChannelReestablish;
197 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelReestablish) {
199 this.node_id = obj.node_id;
200 const msg: number = obj.msg;
201 const msg_hu_conv: ChannelReestablish = new ChannelReestablish(null, msg);
202 msg_hu_conv.ptrs_to.add(this);
203 this.msg = msg_hu_conv;
206 export class BroadcastChannelAnnouncement extends MessageSendEvent {
207 public msg: ChannelAnnouncement;
208 public update_msg: ChannelUpdate;
209 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement) {
211 const msg: number = obj.msg;
212 const msg_hu_conv: ChannelAnnouncement = new ChannelAnnouncement(null, msg);
213 msg_hu_conv.ptrs_to.add(this);
214 this.msg = msg_hu_conv;
215 const update_msg: number = obj.update_msg;
216 const update_msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, update_msg);
217 update_msg_hu_conv.ptrs_to.add(this);
218 this.update_msg = update_msg_hu_conv;
221 export class BroadcastNodeAnnouncement extends MessageSendEvent {
222 public msg: NodeAnnouncement;
223 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement) {
225 const msg: number = obj.msg;
226 const msg_hu_conv: NodeAnnouncement = new NodeAnnouncement(null, msg);
227 msg_hu_conv.ptrs_to.add(this);
228 this.msg = msg_hu_conv;
231 export class BroadcastChannelUpdate extends MessageSendEvent {
232 public msg: ChannelUpdate;
233 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelUpdate) {
235 const msg: number = obj.msg;
236 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
237 msg_hu_conv.ptrs_to.add(this);
238 this.msg = msg_hu_conv;
241 export class HandleError extends MessageSendEvent {
242 public node_id: Uint8Array;
243 public action: ErrorAction;
244 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.HandleError) {
246 this.node_id = obj.node_id;
247 const action: number = obj.action;
248 ErrorAction action_hu_conv = ErrorAction.constr_from_ptr(action);
249 action_hu_conv.ptrs_to.add(this);
250 this.action = action_hu_conv;
253 export class PaymentFailureNetworkUpdate extends MessageSendEvent {
254 public update: HTLCFailChannelUpdate;
255 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) {
257 const update: number = obj.update;
258 HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update);
259 update_hu_conv.ptrs_to.add(this);
260 this.update = update_hu_conv;
263 export class SendChannelRangeQuery extends MessageSendEvent {
264 public node_id: Uint8Array;
265 public msg: QueryChannelRange;
266 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelRangeQuery) {
268 this.node_id = obj.node_id;
269 const msg: number = obj.msg;
270 const msg_hu_conv: QueryChannelRange = new QueryChannelRange(null, msg);
271 msg_hu_conv.ptrs_to.add(this);
272 this.msg = msg_hu_conv;
275 export class SendShortIdsQuery extends MessageSendEvent {
276 public node_id: Uint8Array;
277 public msg: QueryShortChannelIds;
278 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShortIdsQuery) {
280 this.node_id = obj.node_id;
281 const msg: number = obj.msg;
282 const msg_hu_conv: QueryShortChannelIds = new QueryShortChannelIds(null, msg);
283 msg_hu_conv.ptrs_to.add(this);
284 this.msg = msg_hu_conv;
287 export class SendReplyChannelRange extends MessageSendEvent {
288 public node_id: Uint8Array;
289 public msg: ReplyChannelRange;
290 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendReplyChannelRange) {
292 this.node_id = obj.node_id;
293 const msg: number = obj.msg;
294 const msg_hu_conv: ReplyChannelRange = new ReplyChannelRange(null, msg);
295 msg_hu_conv.ptrs_to.add(this);
296 this.msg = msg_hu_conv;