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 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
71 export class SendAcceptChannel extends MessageSendEvent {
72 public node_id: Uint8Array;
73 public msg: AcceptChannel;
74 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAcceptChannel) {
76 this.node_id = obj.node_id;
77 const msg: number = obj.msg;
78 const msg_hu_conv: AcceptChannel = new AcceptChannel(null, msg);
79 msg_hu_conv.ptrs_to.add(this);
80 this.msg = msg_hu_conv;
83 export class SendOpenChannel extends MessageSendEvent {
84 public node_id: Uint8Array;
85 public msg: OpenChannel;
86 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendOpenChannel) {
88 this.node_id = obj.node_id;
89 const msg: number = obj.msg;
90 const msg_hu_conv: OpenChannel = new OpenChannel(null, msg);
91 msg_hu_conv.ptrs_to.add(this);
92 this.msg = msg_hu_conv;
95 export class SendFundingCreated extends MessageSendEvent {
96 public node_id: Uint8Array;
97 public msg: FundingCreated;
98 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingCreated) {
100 this.node_id = obj.node_id;
101 const msg: number = obj.msg;
102 const msg_hu_conv: FundingCreated = new FundingCreated(null, msg);
103 msg_hu_conv.ptrs_to.add(this);
104 this.msg = msg_hu_conv;
107 export class SendFundingSigned extends MessageSendEvent {
108 public node_id: Uint8Array;
109 public msg: FundingSigned;
110 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingSigned) {
112 this.node_id = obj.node_id;
113 const msg: number = obj.msg;
114 const msg_hu_conv: FundingSigned = new FundingSigned(null, msg);
115 msg_hu_conv.ptrs_to.add(this);
116 this.msg = msg_hu_conv;
119 export class SendFundingLocked extends MessageSendEvent {
120 public node_id: Uint8Array;
121 public msg: FundingLocked;
122 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendFundingLocked) {
124 this.node_id = obj.node_id;
125 const msg: number = obj.msg;
126 const msg_hu_conv: FundingLocked = new FundingLocked(null, msg);
127 msg_hu_conv.ptrs_to.add(this);
128 this.msg = msg_hu_conv;
131 export class SendAnnouncementSignatures extends MessageSendEvent {
132 public node_id: Uint8Array;
133 public msg: AnnouncementSignatures;
134 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendAnnouncementSignatures) {
136 this.node_id = obj.node_id;
137 const msg: number = obj.msg;
138 const msg_hu_conv: AnnouncementSignatures = new AnnouncementSignatures(null, msg);
139 msg_hu_conv.ptrs_to.add(this);
140 this.msg = msg_hu_conv;
143 export class UpdateHTLCs extends MessageSendEvent {
144 public node_id: Uint8Array;
145 public updates: CommitmentUpdate;
146 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.UpdateHTLCs) {
148 this.node_id = obj.node_id;
149 const updates: number = obj.updates;
150 const updates_hu_conv: CommitmentUpdate = new CommitmentUpdate(null, updates);
151 updates_hu_conv.ptrs_to.add(this);
152 this.updates = updates_hu_conv;
155 export class SendRevokeAndACK extends MessageSendEvent {
156 public node_id: Uint8Array;
157 public msg: RevokeAndACK;
158 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendRevokeAndACK) {
160 this.node_id = obj.node_id;
161 const msg: number = obj.msg;
162 const msg_hu_conv: RevokeAndACK = new RevokeAndACK(null, msg);
163 msg_hu_conv.ptrs_to.add(this);
164 this.msg = msg_hu_conv;
167 export class SendClosingSigned extends MessageSendEvent {
168 public node_id: Uint8Array;
169 public msg: ClosingSigned;
170 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendClosingSigned) {
172 this.node_id = obj.node_id;
173 const msg: number = obj.msg;
174 const msg_hu_conv: ClosingSigned = new ClosingSigned(null, msg);
175 msg_hu_conv.ptrs_to.add(this);
176 this.msg = msg_hu_conv;
179 export class SendShutdown extends MessageSendEvent {
180 public node_id: Uint8Array;
181 public msg: Shutdown;
182 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShutdown) {
184 this.node_id = obj.node_id;
185 const msg: number = obj.msg;
186 const msg_hu_conv: Shutdown = new Shutdown(null, msg);
187 msg_hu_conv.ptrs_to.add(this);
188 this.msg = msg_hu_conv;
191 export class SendChannelReestablish extends MessageSendEvent {
192 public node_id: Uint8Array;
193 public msg: ChannelReestablish;
194 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelReestablish) {
196 this.node_id = obj.node_id;
197 const msg: number = obj.msg;
198 const msg_hu_conv: ChannelReestablish = new ChannelReestablish(null, msg);
199 msg_hu_conv.ptrs_to.add(this);
200 this.msg = msg_hu_conv;
203 export class BroadcastChannelAnnouncement extends MessageSendEvent {
204 public msg: ChannelAnnouncement;
205 public update_msg: ChannelUpdate;
206 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement) {
208 const msg: number = obj.msg;
209 const msg_hu_conv: ChannelAnnouncement = new ChannelAnnouncement(null, msg);
210 msg_hu_conv.ptrs_to.add(this);
211 this.msg = msg_hu_conv;
212 const update_msg: number = obj.update_msg;
213 const update_msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, update_msg);
214 update_msg_hu_conv.ptrs_to.add(this);
215 this.update_msg = update_msg_hu_conv;
218 export class BroadcastNodeAnnouncement extends MessageSendEvent {
219 public msg: NodeAnnouncement;
220 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement) {
222 const msg: number = obj.msg;
223 const msg_hu_conv: NodeAnnouncement = new NodeAnnouncement(null, msg);
224 msg_hu_conv.ptrs_to.add(this);
225 this.msg = msg_hu_conv;
228 export class BroadcastChannelUpdate extends MessageSendEvent {
229 public msg: ChannelUpdate;
230 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.BroadcastChannelUpdate) {
232 const msg: number = obj.msg;
233 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
234 msg_hu_conv.ptrs_to.add(this);
235 this.msg = msg_hu_conv;
238 export class HandleError extends MessageSendEvent {
239 public node_id: Uint8Array;
240 public action: ErrorAction;
241 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.HandleError) {
243 this.node_id = obj.node_id;
244 const action: number = obj.action;
245 ErrorAction action_hu_conv = ErrorAction.constr_from_ptr(action);
246 action_hu_conv.ptrs_to.add(this);
247 this.action = action_hu_conv;
250 export class PaymentFailureNetworkUpdate extends MessageSendEvent {
251 public update: HTLCFailChannelUpdate;
252 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) {
254 const update: number = obj.update;
255 HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update);
256 update_hu_conv.ptrs_to.add(this);
257 this.update = update_hu_conv;
260 export class SendChannelRangeQuery extends MessageSendEvent {
261 public node_id: Uint8Array;
262 public msg: QueryChannelRange;
263 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelRangeQuery) {
265 this.node_id = obj.node_id;
266 const msg: number = obj.msg;
267 const msg_hu_conv: QueryChannelRange = new QueryChannelRange(null, msg);
268 msg_hu_conv.ptrs_to.add(this);
269 this.msg = msg_hu_conv;
272 export class SendShortIdsQuery extends MessageSendEvent {
273 public node_id: Uint8Array;
274 public msg: QueryShortChannelIds;
275 private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendShortIdsQuery) {
277 this.node_id = obj.node_id;
278 const msg: number = obj.msg;
279 const msg_hu_conv: QueryShortChannelIds = new QueryShortChannelIds(null, msg);
280 msg_hu_conv.ptrs_to.add(this);
281 this.msg = msg_hu_conv;