3 open class RoutingMessageHandler {
5 public var cOpaqueStruct: LDKRoutingMessageHandler?;
9 /* NATIVE_CALLBACKS_START */
11 func handle_node_announcementCallback(pointer: UnsafeRawPointer?, msgPointer: UnsafePointer<LDKNodeAnnouncement>) -> LDKCResult_boolLightningErrorZ {
12 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_node_announcement")
13 let msg = NodeAnnouncement(pointer: msgPointer.pointee);
15 return instance.handle_node_announcement(msg: msg).cOpaqueStruct!;
18 func handle_channel_announcementCallback(pointer: UnsafeRawPointer?, msgPointer: UnsafePointer<LDKChannelAnnouncement>) -> LDKCResult_boolLightningErrorZ {
19 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_channel_announcement")
20 let msg = ChannelAnnouncement(pointer: msgPointer.pointee);
22 return instance.handle_channel_announcement(msg: msg).cOpaqueStruct!;
25 func handle_channel_updateCallback(pointer: UnsafeRawPointer?, msgPointer: UnsafePointer<LDKChannelUpdate>) -> LDKCResult_boolLightningErrorZ {
26 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_channel_update")
27 let msg = ChannelUpdate(pointer: msgPointer.pointee);
29 return instance.handle_channel_update(msg: msg).cOpaqueStruct!;
32 func handle_htlc_fail_channel_updateCallback(pointer: UnsafeRawPointer?, updatePointer: UnsafePointer<LDKHTLCFailChannelUpdate>) -> Void {
33 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_htlc_fail_channel_update")
34 let update = HTLCFailChannelUpdate(pointer: updatePointer.pointee);
36 return instance.handle_htlc_fail_channel_update(update: update);
39 func get_next_channel_announcementsCallback(pointer: UnsafeRawPointer?, starting_point: UInt64, batch_amount: UInt8) -> LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
40 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::get_next_channel_announcements")
42 return Bindings.new_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(array: instance.get_next_channel_announcements(starting_point: starting_point, batch_amount: batch_amount));
45 func get_next_node_announcementsCallback(pointer: UnsafeRawPointer?, starting_point: LDKPublicKey, batch_amount: UInt8) -> LDKCVec_NodeAnnouncementZ {
46 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::get_next_node_announcements")
48 return Bindings.new_LDKCVec_NodeAnnouncementZ(array: instance.get_next_node_announcements(starting_point: Bindings.tuple33_to_array(nativeType: starting_point.compressed_form), batch_amount: batch_amount));
51 func sync_routing_tableCallback(pointer: UnsafeRawPointer?, their_node_id: LDKPublicKey, initValuePointer: UnsafePointer<LDKInit>) -> Void {
52 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::sync_routing_table")
53 let initValue = Init(pointer: initValuePointer.pointee);
55 return instance.sync_routing_table(their_node_id: Bindings.tuple33_to_array(nativeType: their_node_id.compressed_form), initValue: initValue);
58 func handle_reply_channel_rangeCallback(pointer: UnsafeRawPointer?, their_node_id: LDKPublicKey, msg: LDKReplyChannelRange) -> LDKCResult_NoneLightningErrorZ {
59 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_reply_channel_range")
61 return instance.handle_reply_channel_range(their_node_id: Bindings.tuple33_to_array(nativeType: their_node_id.compressed_form), msg: ReplyChannelRange(pointer: msg)).cOpaqueStruct!;
64 func handle_reply_short_channel_ids_endCallback(pointer: UnsafeRawPointer?, their_node_id: LDKPublicKey, msg: LDKReplyShortChannelIdsEnd) -> LDKCResult_NoneLightningErrorZ {
65 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_reply_short_channel_ids_end")
67 return instance.handle_reply_short_channel_ids_end(their_node_id: Bindings.tuple33_to_array(nativeType: their_node_id.compressed_form), msg: ReplyShortChannelIdsEnd(pointer: msg)).cOpaqueStruct!;
70 func handle_query_channel_rangeCallback(pointer: UnsafeRawPointer?, their_node_id: LDKPublicKey, msg: LDKQueryChannelRange) -> LDKCResult_NoneLightningErrorZ {
71 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_query_channel_range")
73 return instance.handle_query_channel_range(their_node_id: Bindings.tuple33_to_array(nativeType: their_node_id.compressed_form), msg: QueryChannelRange(pointer: msg)).cOpaqueStruct!;
76 func handle_query_short_channel_idsCallback(pointer: UnsafeRawPointer?, their_node_id: LDKPublicKey, msg: LDKQueryShortChannelIds) -> LDKCResult_NoneLightningErrorZ {
77 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::handle_query_short_channel_ids")
79 return instance.handle_query_short_channel_ids(their_node_id: Bindings.tuple33_to_array(nativeType: their_node_id.compressed_form), msg: QueryShortChannelIds(pointer: msg)).cOpaqueStruct!;
82 func freeCallback(pointer: UnsafeMutableRawPointer?) -> Void {
83 let instance: RoutingMessageHandler = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "RoutingMessageHandler.swift::free")
85 return instance.free();
88 /* NATIVE_CALLBACKS_END */
90 self.cOpaqueStruct = LDKRoutingMessageHandler(this_arg: Bindings.instanceToPointer(instance: self),
91 handle_node_announcement: handle_node_announcementCallback,
92 handle_channel_announcement: handle_channel_announcementCallback,
93 handle_channel_update: handle_channel_updateCallback,
94 handle_htlc_fail_channel_update: handle_htlc_fail_channel_updateCallback,
95 get_next_channel_announcements: get_next_channel_announcementsCallback,
96 get_next_node_announcements: get_next_node_announcementsCallback,
97 sync_routing_table: sync_routing_tableCallback,
98 handle_reply_channel_range: handle_reply_channel_rangeCallback,
99 handle_reply_short_channel_ids_end: handle_reply_short_channel_ids_endCallback,
100 handle_query_channel_range: handle_query_channel_rangeCallback,
101 handle_query_short_channel_ids: handle_query_short_channel_idsCallback,
102 MessageSendEventsProvider: LDKMessageSendEventsProvider(),
106 public init(pointer: LDKRoutingMessageHandler){
107 self.cOpaqueStruct = pointer
110 /* SWIFT_CALLBACKS_START */
112 open func handle_node_announcement(msg: NodeAnnouncement) -> Result_boolLightningErrorZ {
114 return Result_boolLightningErrorZ(pointer: LDKCResult_boolLightningErrorZ())
117 open func handle_channel_announcement(msg: ChannelAnnouncement) -> Result_boolLightningErrorZ {
119 return Result_boolLightningErrorZ(pointer: LDKCResult_boolLightningErrorZ())
122 open func handle_channel_update(msg: ChannelUpdate) -> Result_boolLightningErrorZ {
124 return Result_boolLightningErrorZ(pointer: LDKCResult_boolLightningErrorZ())
127 open func handle_htlc_fail_channel_update(update: HTLCFailChannelUpdate) -> Void {
132 open func get_next_channel_announcements(starting_point: UInt64, batch_amount: UInt8) -> [LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] {
134 return [LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ]()
137 open func get_next_node_announcements(starting_point: [UInt8], batch_amount: UInt8) -> [LDKNodeAnnouncement] {
139 return [LDKNodeAnnouncement]()
142 open func sync_routing_table(their_node_id: [UInt8], initValue: Init) -> Void {
147 open func handle_reply_channel_range(their_node_id: [UInt8], msg: ReplyChannelRange) -> Result_NoneLightningErrorZ {
149 return Result_NoneLightningErrorZ(pointer: LDKCResult_NoneLightningErrorZ())
152 open func handle_reply_short_channel_ids_end(their_node_id: [UInt8], msg: ReplyShortChannelIdsEnd) -> Result_NoneLightningErrorZ {
154 return Result_NoneLightningErrorZ(pointer: LDKCResult_NoneLightningErrorZ())
157 open func handle_query_channel_range(their_node_id: [UInt8], msg: QueryChannelRange) -> Result_NoneLightningErrorZ {
159 return Result_NoneLightningErrorZ(pointer: LDKCResult_NoneLightningErrorZ())
162 open func handle_query_short_channel_ids(their_node_id: [UInt8], msg: QueryShortChannelIds) -> Result_NoneLightningErrorZ {
164 return Result_NoneLightningErrorZ(pointer: LDKCResult_NoneLightningErrorZ())
167 open func free() -> Void {
172 /* SWIFT_CALLBACKS_END */
177 public class NativelyImplementedRoutingMessageHandler: RoutingMessageHandler {
178 /* SWIFT_DEFAULT_CALLBACKS_START */
180 public override func handle_node_announcement(msg: NodeAnnouncement) -> Result_boolLightningErrorZ {
182 return withUnsafePointer(to: msg.cOpaqueStruct!) { (msgPointer: UnsafePointer<LDKNodeAnnouncement>) in
184 Result_boolLightningErrorZ(pointer: self.cOpaqueStruct!.handle_node_announcement(self.cOpaqueStruct!.this_arg, msgPointer))
190 public override func handle_channel_announcement(msg: ChannelAnnouncement) -> Result_boolLightningErrorZ {
192 return withUnsafePointer(to: msg.cOpaqueStruct!) { (msgPointer: UnsafePointer<LDKChannelAnnouncement>) in
194 Result_boolLightningErrorZ(pointer: self.cOpaqueStruct!.handle_channel_announcement(self.cOpaqueStruct!.this_arg, msgPointer))
200 public override func handle_channel_update(msg: ChannelUpdate) -> Result_boolLightningErrorZ {
202 return withUnsafePointer(to: msg.cOpaqueStruct!) { (msgPointer: UnsafePointer<LDKChannelUpdate>) in
204 Result_boolLightningErrorZ(pointer: self.cOpaqueStruct!.handle_channel_update(self.cOpaqueStruct!.this_arg, msgPointer))
210 public override func handle_htlc_fail_channel_update(update: HTLCFailChannelUpdate) -> Void {
212 withUnsafePointer(to: update.cOpaqueStruct!) { (updatePointer: UnsafePointer<LDKHTLCFailChannelUpdate>) in
214 self.cOpaqueStruct!.handle_htlc_fail_channel_update(self.cOpaqueStruct!.this_arg, updatePointer)
220 public override func get_next_channel_announcements(starting_point: UInt64, batch_amount: UInt8) -> [LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] {
223 Bindings.LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_to_array(nativeType: self.cOpaqueStruct!.get_next_channel_announcements(self.cOpaqueStruct!.this_arg, starting_point, batch_amount))
228 public override func get_next_node_announcements(starting_point: [UInt8], batch_amount: UInt8) -> [LDKNodeAnnouncement] {
231 Bindings.LDKCVec_NodeAnnouncementZ_to_array(nativeType: self.cOpaqueStruct!.get_next_node_announcements(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: starting_point), batch_amount))
236 public override func sync_routing_table(their_node_id: [UInt8], initValue: Init) -> Void {
238 withUnsafePointer(to: initValue.cOpaqueStruct!) { (initPointer: UnsafePointer<LDKInit>) in
240 self.cOpaqueStruct!.sync_routing_table(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: their_node_id), initPointer)
246 public override func handle_reply_channel_range(their_node_id: [UInt8], msg: ReplyChannelRange) -> Result_NoneLightningErrorZ {
249 Result_NoneLightningErrorZ(pointer: self.cOpaqueStruct!.handle_reply_channel_range(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: their_node_id), msg.cOpaqueStruct!))
254 public override func handle_reply_short_channel_ids_end(their_node_id: [UInt8], msg: ReplyShortChannelIdsEnd) -> Result_NoneLightningErrorZ {
257 Result_NoneLightningErrorZ(pointer: self.cOpaqueStruct!.handle_reply_short_channel_ids_end(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: their_node_id), msg.cOpaqueStruct!))
262 public override func handle_query_channel_range(their_node_id: [UInt8], msg: QueryChannelRange) -> Result_NoneLightningErrorZ {
265 Result_NoneLightningErrorZ(pointer: self.cOpaqueStruct!.handle_query_channel_range(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: their_node_id), msg.cOpaqueStruct!))
270 public override func handle_query_short_channel_ids(their_node_id: [UInt8], msg: QueryShortChannelIds) -> Result_NoneLightningErrorZ {
273 Result_NoneLightningErrorZ(pointer: self.cOpaqueStruct!.handle_query_short_channel_ids(self.cOpaqueStruct!.this_arg, Bindings.new_LDKPublicKey(array: their_node_id), msg.cOpaqueStruct!))
278 public override func free() -> Void {
281 self.cOpaqueStruct!.free(self.cOpaqueStruct!.this_arg)
286 /* SWIFT_DEFAULT_CALLBACKS_END */