Skip to content

Commit 8d952f2

Browse files
committed
Use native TCP handling logic
1 parent b57314c commit 8d952f2

26 files changed

+11506
-1679
lines changed

bindings/LDK/Bindings.swift

Lines changed: 377 additions & 375 deletions
Large diffs are not rendered by default.

bindings/LDK/options/ErrorAction.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ public class ErrorAction {
1111
/* OPTION_METHODS_START */
1212

1313
public enum ErrorActionValueType {
14-
case DisconnectPeer, SendErrorMessage
14+
case DisconnectPeer, IgnoreAndLog, SendErrorMessage
1515
}
1616

1717
public func getValueType() -> ErrorActionValueType? {
1818
switch self.cOpaqueStruct?.tag {
1919

2020
case LDKErrorAction_DisconnectPeer:
2121
return .DisconnectPeer
22+
case LDKErrorAction_IgnoreAndLog:
23+
return .IgnoreAndLog
2224
case LDKErrorAction_SendErrorMessage:
2325
return .SendErrorMessage
2426
default:
@@ -34,6 +36,13 @@ public class ErrorAction {
3436
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer)
3537
}
3638

39+
public func getValueAsIgnoreAndLog() -> LDKLevel? {
40+
if self.cOpaqueStruct?.tag != LDKErrorAction_IgnoreAndLog {
41+
return nil
42+
}
43+
return self.cOpaqueStruct!.ignore_and_log
44+
}
45+
3746
public func getValueAsSendErrorMessage() -> SendErrorMessage? {
3847
if self.cOpaqueStruct?.tag != LDKErrorAction_SendErrorMessage {
3948
return nil
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ {
2+
3+
public internal(set) var cOpaqueStruct: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ?;
4+
5+
/* DEFAULT_CONSTRUCTOR_START */
6+
7+
public init() {
8+
self.cOpaqueStruct = LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ(contents: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr(), result_ok: true)
9+
}
10+
11+
/* DEFAULT_CONSTRUCTOR_END */
12+
13+
public init(pointer: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ){
14+
self.cOpaqueStruct = pointer
15+
}
16+
17+
public func isOk() -> Bool {
18+
return self.cOpaqueStruct?.result_ok == true
19+
}
20+
21+
/* RESULT_METHODS_START */
22+
23+
public func getError() -> DecodeError? {
24+
if self.cOpaqueStruct?.result_ok == false {
25+
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
26+
}
27+
return nil
28+
}
29+
30+
public func getValue() -> DelayedPaymentOutputDescriptor? {
31+
if self.cOpaqueStruct?.result_ok == true {
32+
return DelayedPaymentOutputDescriptor(pointer: self.cOpaqueStruct!.contents.result.pointee)
33+
}
34+
return nil
35+
}
36+
37+
/* RESULT_METHODS_END */
38+
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
public class Result_NetAddressDecodeErrorZ {
2+
3+
public internal(set) var cOpaqueStruct: LDKCResult_NetAddressDecodeErrorZ?;
4+
5+
/* DEFAULT_CONSTRUCTOR_START */
6+
7+
public init() {
8+
self.cOpaqueStruct = LDKCResult_NetAddressDecodeErrorZ(contents: LDKCResult_NetAddressDecodeErrorZPtr(), result_ok: true)
9+
}
10+
11+
/* DEFAULT_CONSTRUCTOR_END */
12+
13+
public init(pointer: LDKCResult_NetAddressDecodeErrorZ){
14+
self.cOpaqueStruct = pointer
15+
}
16+
17+
public func isOk() -> Bool {
18+
return self.cOpaqueStruct?.result_ok == true
19+
}
20+
21+
/* RESULT_METHODS_START */
22+
23+
public func getError() -> DecodeError? {
24+
if self.cOpaqueStruct?.result_ok == false {
25+
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
26+
}
27+
return nil
28+
}
29+
30+
public func getValue() -> NetAddress? {
31+
if self.cOpaqueStruct?.result_ok == true {
32+
return NetAddress(pointer: self.cOpaqueStruct!.contents.result.pointee)
33+
}
34+
return nil
35+
}
36+
37+
/* RESULT_METHODS_END */
38+
39+
}

bindings/LDK/results/Result_RouteHintCreationErrorZ.swift renamed to bindings/LDK/results/Result_PrivateRouteCreationErrorZ.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
public class Result_RouteHintCreationErrorZ {
1+
public class Result_PrivateRouteCreationErrorZ {
22

3-
public internal(set) var cOpaqueStruct: LDKCResult_RouteHintCreationErrorZ?;
3+
public internal(set) var cOpaqueStruct: LDKCResult_PrivateRouteCreationErrorZ?;
44

55
/* DEFAULT_CONSTRUCTOR_START */
66

77
public init() {
8-
self.cOpaqueStruct = LDKCResult_RouteHintCreationErrorZ(contents: LDKCResult_RouteHintCreationErrorZPtr(), result_ok: true)
8+
self.cOpaqueStruct = LDKCResult_PrivateRouteCreationErrorZ(contents: LDKCResult_PrivateRouteCreationErrorZPtr(), result_ok: true)
99
}
1010

1111
/* DEFAULT_CONSTRUCTOR_END */
1212

13-
public init(pointer: LDKCResult_RouteHintCreationErrorZ){
13+
public init(pointer: LDKCResult_PrivateRouteCreationErrorZ){
1414
self.cOpaqueStruct = pointer
1515
}
1616

@@ -27,9 +27,9 @@ public class Result_RouteHintCreationErrorZ {
2727
return nil
2828
}
2929

30-
public func getValue() -> RouteHint? {
30+
public func getValue() -> PrivateRoute? {
3131
if self.cOpaqueStruct?.result_ok == true {
32-
return RouteHint(pointer: self.cOpaqueStruct!.contents.result.pointee)
32+
return PrivateRoute(pointer: self.cOpaqueStruct!.contents.result.pointee)
3333
}
3434
return nil
3535
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
public class Result_RouteHopDecodeErrorZ {
2+
3+
public internal(set) var cOpaqueStruct: LDKCResult_RouteHopDecodeErrorZ?;
4+
5+
/* DEFAULT_CONSTRUCTOR_START */
6+
7+
public init() {
8+
self.cOpaqueStruct = LDKCResult_RouteHopDecodeErrorZ(contents: LDKCResult_RouteHopDecodeErrorZPtr(), result_ok: true)
9+
}
10+
11+
/* DEFAULT_CONSTRUCTOR_END */
12+
13+
public init(pointer: LDKCResult_RouteHopDecodeErrorZ){
14+
self.cOpaqueStruct = pointer
15+
}
16+
17+
public func isOk() -> Bool {
18+
return self.cOpaqueStruct?.result_ok == true
19+
}
20+
21+
/* RESULT_METHODS_START */
22+
23+
public func getError() -> DecodeError? {
24+
if self.cOpaqueStruct?.result_ok == false {
25+
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
26+
}
27+
return nil
28+
}
29+
30+
public func getValue() -> RouteHop? {
31+
if self.cOpaqueStruct?.result_ok == true {
32+
return RouteHop(pointer: self.cOpaqueStruct!.contents.result.pointee)
33+
}
34+
return nil
35+
}
36+
37+
/* RESULT_METHODS_END */
38+
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
public class Result_StaticPaymentOutputDescriptorDecodeErrorZ {
2+
3+
public internal(set) var cOpaqueStruct: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ?;
4+
5+
/* DEFAULT_CONSTRUCTOR_START */
6+
7+
public init() {
8+
self.cOpaqueStruct = LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ(contents: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr(), result_ok: true)
9+
}
10+
11+
/* DEFAULT_CONSTRUCTOR_END */
12+
13+
public init(pointer: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ){
14+
self.cOpaqueStruct = pointer
15+
}
16+
17+
public func isOk() -> Bool {
18+
return self.cOpaqueStruct?.result_ok == true
19+
}
20+
21+
/* RESULT_METHODS_START */
22+
23+
public func getError() -> DecodeError? {
24+
if self.cOpaqueStruct?.result_ok == false {
25+
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
26+
}
27+
return nil
28+
}
29+
30+
public func getValue() -> StaticPaymentOutputDescriptor? {
31+
if self.cOpaqueStruct?.result_ok == true {
32+
return StaticPaymentOutputDescriptor(pointer: self.cOpaqueStruct!.contents.result.pointee)
33+
}
34+
return nil
35+
}
36+
37+
/* RESULT_METHODS_END */
38+
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
public class BackgroundProcessor {
2+
3+
public internal(set) var cOpaqueStruct: LDKBackgroundProcessor?;
4+
5+
/* DEFAULT_CONSTRUCTOR_START */
6+
public init(persister: ChannelManagerPersister, event_handler: EventHandler, chain_monitor: ChainMonitor, channel_manager: ChannelManager, peer_manager: PeerManager, logger: Logger) {
7+
8+
self.cOpaqueStruct = withUnsafePointer(to: chain_monitor.cOpaqueStruct!) { (chain_monitorPointer: UnsafePointer<LDKChainMonitor>) in
9+
withUnsafePointer(to: channel_manager.cOpaqueStruct!) { (channel_managerPointer: UnsafePointer<LDKChannelManager>) in
10+
withUnsafePointer(to: peer_manager.cOpaqueStruct!) { (peer_managerPointer: UnsafePointer<LDKPeerManager>) in
11+
BackgroundProcessor_start(persister.cOpaqueStruct!, event_handler.cOpaqueStruct!, chain_monitorPointer, channel_managerPointer, peer_managerPointer, logger.cOpaqueStruct!)
12+
}
13+
}
14+
}
15+
}
16+
/* DEFAULT_CONSTRUCTOR_END */
17+
18+
public init(pointer: LDKBackgroundProcessor){
19+
self.cOpaqueStruct = pointer
20+
}
21+
22+
/* STRUCT_METHODS_START */
23+
24+
public func stop() -> Result_NoneErrorZ {
25+
26+
return Result_NoneErrorZ(pointer: BackgroundProcessor_stop(self.cOpaqueStruct!));
27+
}
28+
29+
30+
deinit {
31+
if self.cOpaqueStruct?.is_owned == false {
32+
33+
34+
35+
BackgroundProcessor_free(self.cOpaqueStruct!)
36+
37+
}
38+
39+
}
40+
41+
/* STRUCT_METHODS_END */
42+
43+
}

bindings/LDK/structs/Invoice.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,17 @@ Invoice_min_final_cltv_expiry(this_argPointer)
9999
};
100100
}
101101

102-
public func routes() -> [LDKRouteHint] {
102+
public func private_routes() -> [LDKPrivateRoute] {
103+
104+
return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
105+
Invoice_private_routes(this_argPointer)
106+
});
107+
}
108+
109+
public func route_hints() -> [LDKRouteHint] {
103110

104111
return Bindings.LDKCVec_RouteHintZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
105-
Invoice_routes(this_argPointer)
112+
Invoice_route_hints(this_argPointer)
106113
});
107114
}
108115

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
public class PrivateRoute {
2+
3+
public internal(set) var cOpaqueStruct: LDKPrivateRoute?;
4+
5+
6+
7+
public init(pointer: LDKPrivateRoute){
8+
self.cOpaqueStruct = pointer
9+
}
10+
11+
/* STRUCT_METHODS_START */
12+
13+
public func eq(a: PrivateRoute, b: PrivateRoute) -> Bool {
14+
15+
return withUnsafePointer(to: a.cOpaqueStruct!) { (aPointer: UnsafePointer<LDKPrivateRoute>) in
16+
withUnsafePointer(to: b.cOpaqueStruct!) { (bPointer: UnsafePointer<LDKPrivateRoute>) in
17+
PrivateRoute_eq(aPointer, bPointer)
18+
}
19+
};
20+
}
21+
22+
public func clone(orig: PrivateRoute) -> PrivateRoute {
23+
24+
return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKPrivateRoute>) in
25+
PrivateRoute(pointer: PrivateRoute_clone(origPointer))
26+
};
27+
}
28+
29+
public func new(hops: RouteHint) -> Result_PrivateRouteCreationErrorZ {
30+
31+
return Result_PrivateRouteCreationErrorZ(pointer: PrivateRoute_new(hops.cOpaqueStruct!));
32+
}
33+
34+
public func into_inner() -> RouteHint {
35+
36+
return RouteHint(pointer: PrivateRoute_into_inner(self.cOpaqueStruct!));
37+
}
38+
39+
40+
deinit {
41+
if self.cOpaqueStruct?.is_owned == false {
42+
43+
44+
45+
PrivateRoute_free(self.cOpaqueStruct!)
46+
47+
}
48+
49+
}
50+
51+
/* STRUCT_METHODS_END */
52+
53+
}

0 commit comments

Comments
 (0)