Skip to content

Commit

Permalink
Use native TCP handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Jul 9, 2021
1 parent b57314c commit 8d952f2
Show file tree
Hide file tree
Showing 26 changed files with 11,506 additions and 1,679 deletions.
752 changes: 377 additions & 375 deletions bindings/LDK/Bindings.swift

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion bindings/LDK/options/ErrorAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ public class ErrorAction {
/* OPTION_METHODS_START */

public enum ErrorActionValueType {
case DisconnectPeer, SendErrorMessage
case DisconnectPeer, IgnoreAndLog, SendErrorMessage
}

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

case LDKErrorAction_DisconnectPeer:
return .DisconnectPeer
case LDKErrorAction_IgnoreAndLog:
return .IgnoreAndLog
case LDKErrorAction_SendErrorMessage:
return .SendErrorMessage
default:
Expand All @@ -34,6 +36,13 @@ public class ErrorAction {
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer)
}

public func getValueAsIgnoreAndLog() -> LDKLevel? {
if self.cOpaqueStruct?.tag != LDKErrorAction_IgnoreAndLog {
return nil
}
return self.cOpaqueStruct!.ignore_and_log
}

public func getValueAsSendErrorMessage() -> SendErrorMessage? {
if self.cOpaqueStruct?.tag != LDKErrorAction_SendErrorMessage {
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ {

public internal(set) var cOpaqueStruct: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ?;

/* DEFAULT_CONSTRUCTOR_START */

public init() {
self.cOpaqueStruct = LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ(contents: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr(), result_ok: true)
}

/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ){
self.cOpaqueStruct = pointer
}

public func isOk() -> Bool {
return self.cOpaqueStruct?.result_ok == true
}

/* RESULT_METHODS_START */

public func getError() -> DecodeError? {
if self.cOpaqueStruct?.result_ok == false {
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
}
return nil
}

public func getValue() -> DelayedPaymentOutputDescriptor? {
if self.cOpaqueStruct?.result_ok == true {
return DelayedPaymentOutputDescriptor(pointer: self.cOpaqueStruct!.contents.result.pointee)
}
return nil
}

/* RESULT_METHODS_END */

}
39 changes: 39 additions & 0 deletions bindings/LDK/results/Result_NetAddressDecodeErrorZ.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Result_NetAddressDecodeErrorZ {

public internal(set) var cOpaqueStruct: LDKCResult_NetAddressDecodeErrorZ?;

/* DEFAULT_CONSTRUCTOR_START */

public init() {
self.cOpaqueStruct = LDKCResult_NetAddressDecodeErrorZ(contents: LDKCResult_NetAddressDecodeErrorZPtr(), result_ok: true)
}

/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKCResult_NetAddressDecodeErrorZ){
self.cOpaqueStruct = pointer
}

public func isOk() -> Bool {
return self.cOpaqueStruct?.result_ok == true
}

/* RESULT_METHODS_START */

public func getError() -> DecodeError? {
if self.cOpaqueStruct?.result_ok == false {
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
}
return nil
}

public func getValue() -> NetAddress? {
if self.cOpaqueStruct?.result_ok == true {
return NetAddress(pointer: self.cOpaqueStruct!.contents.result.pointee)
}
return nil
}

/* RESULT_METHODS_END */

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
public class Result_RouteHintCreationErrorZ {
public class Result_PrivateRouteCreationErrorZ {

public internal(set) var cOpaqueStruct: LDKCResult_RouteHintCreationErrorZ?;
public internal(set) var cOpaqueStruct: LDKCResult_PrivateRouteCreationErrorZ?;

/* DEFAULT_CONSTRUCTOR_START */

public init() {
self.cOpaqueStruct = LDKCResult_RouteHintCreationErrorZ(contents: LDKCResult_RouteHintCreationErrorZPtr(), result_ok: true)
self.cOpaqueStruct = LDKCResult_PrivateRouteCreationErrorZ(contents: LDKCResult_PrivateRouteCreationErrorZPtr(), result_ok: true)
}

/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKCResult_RouteHintCreationErrorZ){
public init(pointer: LDKCResult_PrivateRouteCreationErrorZ){
self.cOpaqueStruct = pointer
}

Expand All @@ -27,9 +27,9 @@ public class Result_RouteHintCreationErrorZ {
return nil
}

public func getValue() -> RouteHint? {
public func getValue() -> PrivateRoute? {
if self.cOpaqueStruct?.result_ok == true {
return RouteHint(pointer: self.cOpaqueStruct!.contents.result.pointee)
return PrivateRoute(pointer: self.cOpaqueStruct!.contents.result.pointee)
}
return nil
}
Expand Down
39 changes: 39 additions & 0 deletions bindings/LDK/results/Result_RouteHopDecodeErrorZ.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Result_RouteHopDecodeErrorZ {

public internal(set) var cOpaqueStruct: LDKCResult_RouteHopDecodeErrorZ?;

/* DEFAULT_CONSTRUCTOR_START */

public init() {
self.cOpaqueStruct = LDKCResult_RouteHopDecodeErrorZ(contents: LDKCResult_RouteHopDecodeErrorZPtr(), result_ok: true)
}

/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKCResult_RouteHopDecodeErrorZ){
self.cOpaqueStruct = pointer
}

public func isOk() -> Bool {
return self.cOpaqueStruct?.result_ok == true
}

/* RESULT_METHODS_START */

public func getError() -> DecodeError? {
if self.cOpaqueStruct?.result_ok == false {
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
}
return nil
}

public func getValue() -> RouteHop? {
if self.cOpaqueStruct?.result_ok == true {
return RouteHop(pointer: self.cOpaqueStruct!.contents.result.pointee)
}
return nil
}

/* RESULT_METHODS_END */

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Result_StaticPaymentOutputDescriptorDecodeErrorZ {

public internal(set) var cOpaqueStruct: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ?;

/* DEFAULT_CONSTRUCTOR_START */

public init() {
self.cOpaqueStruct = LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ(contents: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr(), result_ok: true)
}

/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ){
self.cOpaqueStruct = pointer
}

public func isOk() -> Bool {
return self.cOpaqueStruct?.result_ok == true
}

/* RESULT_METHODS_START */

public func getError() -> DecodeError? {
if self.cOpaqueStruct?.result_ok == false {
return DecodeError(pointer: self.cOpaqueStruct!.contents.err.pointee)
}
return nil
}

public func getValue() -> StaticPaymentOutputDescriptor? {
if self.cOpaqueStruct?.result_ok == true {
return StaticPaymentOutputDescriptor(pointer: self.cOpaqueStruct!.contents.result.pointee)
}
return nil
}

/* RESULT_METHODS_END */

}
43 changes: 43 additions & 0 deletions bindings/LDK/structs/BackgroundProcessor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public class BackgroundProcessor {

public internal(set) var cOpaqueStruct: LDKBackgroundProcessor?;

/* DEFAULT_CONSTRUCTOR_START */
public init(persister: ChannelManagerPersister, event_handler: EventHandler, chain_monitor: ChainMonitor, channel_manager: ChannelManager, peer_manager: PeerManager, logger: Logger) {

self.cOpaqueStruct = withUnsafePointer(to: chain_monitor.cOpaqueStruct!) { (chain_monitorPointer: UnsafePointer<LDKChainMonitor>) in
withUnsafePointer(to: channel_manager.cOpaqueStruct!) { (channel_managerPointer: UnsafePointer<LDKChannelManager>) in
withUnsafePointer(to: peer_manager.cOpaqueStruct!) { (peer_managerPointer: UnsafePointer<LDKPeerManager>) in
BackgroundProcessor_start(persister.cOpaqueStruct!, event_handler.cOpaqueStruct!, chain_monitorPointer, channel_managerPointer, peer_managerPointer, logger.cOpaqueStruct!)
}
}
}
}
/* DEFAULT_CONSTRUCTOR_END */

public init(pointer: LDKBackgroundProcessor){
self.cOpaqueStruct = pointer
}

/* STRUCT_METHODS_START */

public func stop() -> Result_NoneErrorZ {

return Result_NoneErrorZ(pointer: BackgroundProcessor_stop(self.cOpaqueStruct!));
}


deinit {
if self.cOpaqueStruct?.is_owned == false {



BackgroundProcessor_free(self.cOpaqueStruct!)

}

}

/* STRUCT_METHODS_END */

}
11 changes: 9 additions & 2 deletions bindings/LDK/structs/Invoice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ Invoice_min_final_cltv_expiry(this_argPointer)
};
}

public func routes() -> [LDKRouteHint] {
public func private_routes() -> [LDKPrivateRoute] {

return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
Invoice_private_routes(this_argPointer)
});
}

public func route_hints() -> [LDKRouteHint] {

return Bindings.LDKCVec_RouteHintZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
Invoice_routes(this_argPointer)
Invoice_route_hints(this_argPointer)
});
}

Expand Down
53 changes: 53 additions & 0 deletions bindings/LDK/structs/PrivateRoute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
public class PrivateRoute {

public internal(set) var cOpaqueStruct: LDKPrivateRoute?;



public init(pointer: LDKPrivateRoute){
self.cOpaqueStruct = pointer
}

/* STRUCT_METHODS_START */

public func eq(a: PrivateRoute, b: PrivateRoute) -> Bool {

return withUnsafePointer(to: a.cOpaqueStruct!) { (aPointer: UnsafePointer<LDKPrivateRoute>) in
withUnsafePointer(to: b.cOpaqueStruct!) { (bPointer: UnsafePointer<LDKPrivateRoute>) in
PrivateRoute_eq(aPointer, bPointer)
}
};
}

public func clone(orig: PrivateRoute) -> PrivateRoute {

return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKPrivateRoute>) in
PrivateRoute(pointer: PrivateRoute_clone(origPointer))
};
}

public func new(hops: RouteHint) -> Result_PrivateRouteCreationErrorZ {

return Result_PrivateRouteCreationErrorZ(pointer: PrivateRoute_new(hops.cOpaqueStruct!));
}

public func into_inner() -> RouteHint {

return RouteHint(pointer: PrivateRoute_into_inner(self.cOpaqueStruct!));
}


deinit {
if self.cOpaqueStruct?.is_owned == false {



PrivateRoute_free(self.cOpaqueStruct!)

}

}

/* STRUCT_METHODS_END */

}
6 changes: 3 additions & 3 deletions bindings/LDK/structs/RawInvoice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ RawInvoice_features(this_argPointer)
});
}

public func routes() -> [LDKRouteHint] {
public func private_routes() -> [LDKPrivateRoute] {

return Bindings.LDKCVec_RouteHintZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKRawInvoice>) in
RawInvoice_routes(this_argPointer)
return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKRawInvoice>) in
RawInvoice_private_routes(this_argPointer)
});
}

Expand Down
10 changes: 0 additions & 10 deletions bindings/LDK/structs/RouteHint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ RouteHint(pointer: RouteHint_clone(origPointer))
};
}

public func new(hops: [LDKRouteHintHop]) -> Result_RouteHintCreationErrorZ {

return Result_RouteHintCreationErrorZ(pointer: RouteHint_new(Bindings.new_LDKCVec_RouteHintHopZ(array: hops)));
}

public func into_inner() -> [LDKRouteHintHop] {

return Bindings.LDKCVec_RouteHintHopZ_to_array(nativeType: RouteHint_into_inner(self.cOpaqueStruct!));
}


deinit {
if self.cOpaqueStruct?.is_owned == false {
Expand Down
Loading

0 comments on commit 8d952f2

Please sign in to comment.