Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / traits / Filter.swift
1 import LDKCHeaders
2 import LDKCHeaders
3 open class Filter {
4
5     public var cOpaqueStruct: LDKFilter?;
6
7     public init() {
8
9         /* NATIVE_CALLBACKS_START */
10
11                 func register_txCallback(pointer: UnsafeRawPointer?, txidPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>?, script_pubkey: LDKu8slice) -> Void {
12                         let instance: Filter = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Filter.swift::register_tx")
13                         
14                                                                 var txid: [UInt8]? = nil
15                                                                 if let txidUnwrapped = txidPointer {
16                                                                         txid = Bindings.tuple32_to_array(nativeType: txidUnwrapped.pointee)
17                                                                 }
18                                                         
19                         return instance.register_tx(txid: txid, script_pubkey: Bindings.LDKu8slice_to_array(nativeType: script_pubkey));
20                 }
21
22                 func register_outputCallback(pointer: UnsafeRawPointer?, output: LDKWatchedOutput) -> LDKCOption_C2Tuple_usizeTransactionZZ {
23                         let instance: Filter = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Filter.swift::register_output")
24                         
25                         return instance.register_output(output: WatchedOutput(pointer: output)).cOpaqueStruct!;
26                 }
27
28                 func freeCallback(pointer: UnsafeMutableRawPointer?) -> Void {
29                         let instance: Filter = Bindings.pointerToInstance(pointer: pointer!, sourceMarker: "Filter.swift::free")
30                         
31                         return instance.free();
32                 }
33
34                 /* NATIVE_CALLBACKS_END */
35
36         self.cOpaqueStruct = LDKFilter(this_arg: Bindings.instanceToPointer(instance: self), 
37                         register_tx: register_txCallback,
38                         register_output: register_outputCallback,
39                         free: freeCallback)
40     }
41
42     public init(pointer: LDKFilter){
43                 self.cOpaqueStruct = pointer
44         }
45
46     /* SWIFT_CALLBACKS_START */
47
48     open func register_tx(txid: [UInt8]?, script_pubkey: [UInt8]) -> Void {
49         /* EDIT ME */
50                 
51     }
52
53     open func register_output(output: WatchedOutput) -> Option_C2Tuple_usizeTransactionZZ {
54         /* EDIT ME */
55                 return Option_C2Tuple_usizeTransactionZZ(pointer: LDKCOption_C2Tuple_usizeTransactionZZ())
56     }
57
58     open func free() -> Void {
59         /* EDIT ME */
60                 
61     }
62
63     /* SWIFT_CALLBACKS_END */
64
65 }
66
67
68 public class NativelyImplementedFilter: Filter {
69         /* SWIFT_DEFAULT_CALLBACKS_START */
70
71         public override func register_tx(txid: [UInt8]?, script_pubkey: [UInt8]) -> Void {
72                 
73                                 withUnsafePointer(to: Bindings.array_to_tuple32(array: txid!)) { (txidPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
74
75                                 self.cOpaqueStruct!.register_tx(self.cOpaqueStruct!.this_arg, txidPointer, Bindings.new_LDKu8slice(array: script_pubkey))
76                                 
77 }
78                         
79         }
80
81         public override func register_output(output: WatchedOutput) -> Option_C2Tuple_usizeTransactionZZ {
82                 
83                                 return 
84                                 Option_C2Tuple_usizeTransactionZZ(pointer: self.cOpaqueStruct!.register_output(self.cOpaqueStruct!.this_arg, output.cOpaqueStruct!))
85                                 
86                         
87         }
88
89         public override func free() -> Void {
90                 
91                                 
92                                 self.cOpaqueStruct!.free(self.cOpaqueStruct!.this_arg)
93                                 
94                         
95         }
96
97         /* SWIFT_DEFAULT_CALLBACKS_END */
98 }