Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / structs / ChannelManager.swift
1 import LDKCHeaders
2
3 public class ChannelManager {
4
5     public internal(set) var cOpaqueStruct: LDKChannelManager?;
6
7         /* DEFAULT_CONSTRUCTOR_START */
8     public init(fee_est: FeeEstimator, chain_monitor: Watch, tx_broadcaster: BroadcasterInterface, logger: Logger, keys_manager: KeysInterface, config: UserConfig, params: ChainParameters) {
9         
10         self.cOpaqueStruct = ChannelManager_new(fee_est.cOpaqueStruct!, chain_monitor.cOpaqueStruct!, tx_broadcaster.cOpaqueStruct!, logger.cOpaqueStruct!, keys_manager.cOpaqueStruct!, config.cOpaqueStruct!, params.cOpaqueStruct!)
11     }
12     /* DEFAULT_CONSTRUCTOR_END */
13
14     public init(pointer: LDKChannelManager){
15                 self.cOpaqueStruct = pointer
16         }
17
18     /* STRUCT_METHODS_START */
19
20     public func get_current_default_configuration() -> UserConfig {
21         
22         return UserConfig(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
23 ChannelManager_get_current_default_configuration(this_argPointer)
24 });
25     }
26
27     public func create_channel(their_network_key: [UInt8], channel_value_satoshis: UInt64, push_msat: UInt64, user_id: UInt64, override_config: UserConfig) -> Result_NoneAPIErrorZ {
28         
29         return Result_NoneAPIErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
30 ChannelManager_create_channel(this_argPointer, Bindings.new_LDKPublicKey(array: their_network_key), channel_value_satoshis, push_msat, user_id, override_config.cOpaqueStruct!)
31 });
32     }
33
34     public func list_channels() -> [LDKChannelDetails] {
35         
36         return Bindings.LDKCVec_ChannelDetailsZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
37 ChannelManager_list_channels(this_argPointer)
38 });
39     }
40
41     public func list_usable_channels() -> [LDKChannelDetails] {
42         
43         return Bindings.LDKCVec_ChannelDetailsZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
44 ChannelManager_list_usable_channels(this_argPointer)
45 });
46     }
47
48     public func close_channel(channel_id: [UInt8]) -> Result_NoneAPIErrorZ {
49         
50         return Result_NoneAPIErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
51 withUnsafePointer(to: Bindings.array_to_tuple32(array: channel_id)) { (channel_idPointer: 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
52 ChannelManager_close_channel(this_argPointer, channel_idPointer)
53 }
54 });
55     }
56
57     public func force_close_channel(channel_id: [UInt8]) -> Result_NoneAPIErrorZ {
58         
59         return Result_NoneAPIErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
60 withUnsafePointer(to: Bindings.array_to_tuple32(array: channel_id)) { (channel_idPointer: 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
61 ChannelManager_force_close_channel(this_argPointer, channel_idPointer)
62 }
63 });
64     }
65
66     public func force_close_all_channels() -> Void {
67         
68         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
69 ChannelManager_force_close_all_channels(this_argPointer)
70 };
71     }
72
73     public func send_payment(route: Route, payment_hash: [UInt8], payment_secret: [UInt8]) -> Result_NonePaymentSendFailureZ {
74         
75         return Result_NonePaymentSendFailureZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
76 withUnsafePointer(to: route.cOpaqueStruct!) { (routePointer: UnsafePointer<LDKRoute>) in
77 ChannelManager_send_payment(this_argPointer, routePointer, Bindings.new_LDKThirtyTwoBytes(array: payment_hash), Bindings.new_LDKThirtyTwoBytes(array: payment_secret))
78 }
79 });
80     }
81
82     public func funding_transaction_generated(temporary_channel_id: [UInt8], funding_transaction: [UInt8]) -> Result_NoneAPIErrorZ {
83         
84         return Result_NoneAPIErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
85 withUnsafePointer(to: Bindings.array_to_tuple32(array: temporary_channel_id)) { (temporary_channel_idPointer: 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
86 ChannelManager_funding_transaction_generated(this_argPointer, temporary_channel_idPointer, Bindings.new_LDKTransaction(array: funding_transaction))
87 }
88 });
89     }
90
91     public func broadcast_node_announcement(rgb: [UInt8], alias: [UInt8], addresses: [LDKNetAddress]) -> Void {
92         
93         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
94 ChannelManager_broadcast_node_announcement(this_argPointer, Bindings.new_LDKThreeBytes(array: rgb), Bindings.new_LDKThirtyTwoBytes(array: alias), Bindings.new_LDKCVec_NetAddressZ(array: addresses))
95 };
96     }
97
98     public func process_pending_htlc_forwards() -> Void {
99         
100         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
101 ChannelManager_process_pending_htlc_forwards(this_argPointer)
102 };
103     }
104
105     public func timer_tick_occurred() -> Void {
106         
107         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
108 ChannelManager_timer_tick_occurred(this_argPointer)
109 };
110     }
111
112     public func fail_htlc_backwards(payment_hash: [UInt8]) -> Bool {
113         
114         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
115 withUnsafePointer(to: Bindings.array_to_tuple32(array: payment_hash)) { (payment_hashPointer: 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
116 ChannelManager_fail_htlc_backwards(this_argPointer, payment_hashPointer)
117 }
118 };
119     }
120
121     public func claim_funds(payment_preimage: [UInt8]) -> Bool {
122         
123         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
124 ChannelManager_claim_funds(this_argPointer, Bindings.new_LDKThirtyTwoBytes(array: payment_preimage))
125 };
126     }
127
128     public func get_our_node_id() -> [UInt8] {
129         
130         return Bindings.LDKPublicKey_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
131 ChannelManager_get_our_node_id(this_argPointer)
132 });
133     }
134
135     public func channel_monitor_updated(funding_txo: OutPoint, highest_applied_update_id: UInt64) -> Void {
136         
137         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
138 withUnsafePointer(to: funding_txo.cOpaqueStruct!) { (funding_txoPointer: UnsafePointer<LDKOutPoint>) in
139 ChannelManager_channel_monitor_updated(this_argPointer, funding_txoPointer, highest_applied_update_id)
140 }
141 };
142     }
143
144     public func create_inbound_payment(min_value_msat: Option_u64Z, invoice_expiry_delta_secs: UInt32, user_payment_id: UInt64) -> C2Tuple_PaymentHashPaymentSecretZ {
145         
146         return C2Tuple_PaymentHashPaymentSecretZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
147 ChannelManager_create_inbound_payment(this_argPointer, min_value_msat.cOpaqueStruct!, invoice_expiry_delta_secs, user_payment_id)
148 });
149     }
150
151     public func create_inbound_payment_for_hash(payment_hash: [UInt8], min_value_msat: Option_u64Z, invoice_expiry_delta_secs: UInt32, user_payment_id: UInt64) -> Result_PaymentSecretAPIErrorZ {
152         
153         return Result_PaymentSecretAPIErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
154 ChannelManager_create_inbound_payment_for_hash(this_argPointer, Bindings.new_LDKThirtyTwoBytes(array: payment_hash), min_value_msat.cOpaqueStruct!, invoice_expiry_delta_secs, user_payment_id)
155 });
156     }
157
158     public func as_MessageSendEventsProvider() -> MessageSendEventsProvider {
159         
160         return NativelyImplementedMessageSendEventsProvider(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
161 ChannelManager_as_MessageSendEventsProvider(this_argPointer)
162 });
163     }
164
165     public func as_EventsProvider() -> EventsProvider {
166         
167         return NativelyImplementedEventsProvider(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
168 ChannelManager_as_EventsProvider(this_argPointer)
169 });
170     }
171
172     public func as_Listen() -> Listen {
173         
174         return NativelyImplementedListen(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
175 ChannelManager_as_Listen(this_argPointer)
176 });
177     }
178
179     public func as_Confirm() -> Confirm {
180         
181         return NativelyImplementedConfirm(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
182 ChannelManager_as_Confirm(this_argPointer)
183 });
184     }
185
186     public func await_persistable_update_timeout(max_wait: UInt64) -> Bool {
187         
188         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
189 ChannelManager_await_persistable_update_timeout(this_argPointer, max_wait)
190 };
191     }
192
193     public func await_persistable_update() -> Void {
194         
195         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
196 ChannelManager_await_persistable_update(this_argPointer)
197 };
198     }
199
200     public func current_best_block() -> BestBlock {
201         
202         return BestBlock(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
203 ChannelManager_current_best_block(this_argPointer)
204 });
205     }
206
207     public func as_ChannelMessageHandler() -> ChannelMessageHandler {
208         
209         return NativelyImplementedChannelMessageHandler(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
210 ChannelManager_as_ChannelMessageHandler(this_argPointer)
211 });
212     }
213
214     public func write(obj: ChannelManager) -> [UInt8] {
215         
216         return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: obj.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKChannelManager>) in
217 ChannelManager_write(objPointer)
218 });
219     }
220
221                                 
222         deinit {
223                                         if self.cOpaqueStruct?.is_owned == false {
224
225                                         
226                                         
227                 ChannelManager_free(self.cOpaqueStruct!)
228                                         
229 }
230                                 
231         }
232                         
233     /* STRUCT_METHODS_END */
234
235 }