Skip to content

Commit

Permalink
Merge pull request #31 from lightningdevkit/regtest_monitor_tooling
Browse files Browse the repository at this point in the history
Create version 0.0.106.2
  • Loading branch information
arik-so authored Apr 18, 2022
2 parents c62b596 + 1f52fcb commit 147518f
Show file tree
Hide file tree
Showing 23 changed files with 1,482 additions and 282 deletions.
2 changes: 1 addition & 1 deletion bindings/LDK/Bindings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6490,7 +6490,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
*/

public class func get_ldk_swift_bindings_version() -> String {
return "8e00d9af56a2d5df10febaa37026399f925b414b"
return "fe0ea5b41ca6eb7ef88a4d2fbd7dc1f647c89112"
}

}
Expand Down
34 changes: 34 additions & 0 deletions bindings/LDK/options/Bech32Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,40 @@ public class Bech32Error: NativeTypeWrapper {
}


public func clone() -> Bech32Error {

return Bech32Error(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKBech32Error>) in
Bech32Error_clone(origPointer)
});
}

internal func danglingClone() -> Bech32Error {
let dangledClone = self.clone()
dangledClone.dangling = true
return dangledClone
}


internal func free() -> Void {

return Bech32Error_free(self.cOpaqueStruct!);
}

internal func dangle() -> Bech32Error {
self.dangling = true
return self
}

deinit {
if !self.dangling {
Bindings.print("Freeing Bech32Error \(self.instanceNumber).")
self.free()
} else {
Bindings.print("Not freeing Bech32Error \(self.instanceNumber) due to dangle.")
}
}


/* OPTION_METHODS_END */

/* TYPE_CLASSES */
Expand Down
2 changes: 1 addition & 1 deletion bindings/LDK/options/ParseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ParseError_clone(origPointer)

public class func bech32_error(a: Bech32Error) -> ParseError {

return ParseError(pointer: ParseError_bech32_error(a.cOpaqueStruct!));
return ParseError(pointer: ParseError_bech32_error(a.danglingClone().cOpaqueStruct!));
}

public class func malformed_signature(a: LDKSecp256k1Error) -> ParseError {
Expand Down
23 changes: 17 additions & 6 deletions bindings/batteries/ChannelManagerConstructor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
enum InvalidSerializedDataError: Error {
case invalidSerializedChannelMonitor
case invalidSerializedChannelManager
case invalidSerializedNetworkGraph
case duplicateSerializedChannelMonitor
case badNodeSecret
}
Expand All @@ -30,11 +31,11 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
let logger: Logger
fileprivate var customPersister: CustomChannelManagerPersister?
fileprivate var customEventHandler: EventHandler?
fileprivate var net_graph: NetworkGraph?
public private(set) var net_graph: NetworkGraph?
fileprivate var graph_msg_handler: NetGraphMsgHandler?
fileprivate var scorer: MultiThreadedLockableScore?
fileprivate let keysInterface: KeysInterface!
public var payer: InvoicePayer?
public private(set) var payer: InvoicePayer?
public let peerManager: PeerManager


Expand All @@ -49,7 +50,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
private let chain_monitor: ChainMonitor


public init(channel_manager_serialized: [UInt8], channel_monitors_serialized: [[UInt8]], keys_interface: KeysInterface, fee_estimator: FeeEstimator, chain_monitor: ChainMonitor, filter: Filter?, net_graph: NetworkGraph?, tx_broadcaster: BroadcasterInterface, logger: Logger) throws {
public init(channel_manager_serialized: [UInt8], channel_monitors_serialized: [[UInt8]], keys_interface: KeysInterface, fee_estimator: FeeEstimator, chain_monitor: ChainMonitor, filter: Filter?, net_graph_serialized: [UInt8]?, tx_broadcaster: BroadcasterInterface, logger: Logger) throws {

var monitors: [LDKChannelMonitor] = []
self.channel_monitors = []
Expand Down Expand Up @@ -104,7 +105,14 @@ public class ChannelManagerConstructor: NativeTypeWrapper {

let random_data = keys_interface.get_secure_random_bytes();

self.net_graph = net_graph
if let serializedNetworkGraph = net_graph_serialized {
let netGraphResult = NetworkGraph.read(ser: serializedNetworkGraph)
if !netGraphResult.isOk(){
throw InvalidSerializedDataError.invalidSerializedNetworkGraph
}
self.net_graph = netGraphResult.getValue()
}

let noCustomMessages = IgnoringMessageHandler()
var messageHandler: MessageHandler!
if let netGraph = net_graph {
Expand Down Expand Up @@ -263,6 +271,10 @@ fileprivate class CustomChannelManagerPersister: Persister {
override func persist_manager(channel_manager: ChannelManager) -> Result_NoneErrorZ {
return self.handler.persist_manager(channel_manager: channel_manager)
}

override func persist_graph(network_graph: NetworkGraph) -> Result_NoneErrorZ {
return self.handler.persist_graph(network_graph: network_graph)
}
}

fileprivate class CustomEventHandler: EventHandler {
Expand All @@ -275,10 +287,9 @@ fileprivate class CustomEventHandler: EventHandler {
}

override func handle_event(event: Event) {
self.handler.handle_event(event: event)
self.handler.handle_event(event: event.clone())
}


}

public protocol ExtendedChannelManagerPersister: Persister {
Expand Down
2 changes: 1 addition & 1 deletion ci/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LDKSwiftTest: XCTestCase {
fee_estimator: feeEstimator,
chain_monitor: chainMonitor,
filter: filter,
net_graph: nil,
net_graph_serialized: nil,
tx_broadcaster: broadcaster,
logger: logger
)
Expand Down
36 changes: 26 additions & 10 deletions xcode/DirectBindingsApp/DirectBindingsApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
071041C427DA763F00AE1175 /* PolarConnectionExperiment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07C753E826D954B100081BF8 /* PolarConnectionExperiment.swift */; };
074A2DC426D957BC00370D0B /* RegtestBlockchainObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserver.swift */; };
074A2DC426D957BC00370D0B /* RegtestBlockchainObserverOld.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserverOld.swift */; };
074A2DCD26D970D500370D0B /* RegtestBroadcasterInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 074A2DCB26D970D400370D0B /* RegtestBroadcasterInterface.swift */; };
074A2DCE26D970D500370D0B /* RegtestChannelManagerPersister.swift in Sources */ = {isa = PBXBuildFile; fileRef = 074A2DCC26D970D500370D0B /* RegtestChannelManagerPersister.swift */; };
075E22A226FEF8540000A76B /* NetGraphMsgHandlerConstructor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 075E22A126FEF8540000A76B /* NetGraphMsgHandlerConstructor.swift */; };
Expand Down Expand Up @@ -693,6 +693,8 @@
076D251827FC219300970AFC /* InvoicePayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D227727FC219000970AFC /* InvoicePayer.swift */; };
076D251927FC219300970AFC /* DelayedPaymentOutputDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D227827FC219000970AFC /* DelayedPaymentOutputDescriptor.swift */; };
076D251A27FC219300970AFC /* DelayedPaymentOutputDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D227827FC219000970AFC /* DelayedPaymentOutputDescriptor.swift */; };
076D2A6C280399F500970AFC /* RegtestBlockchainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D2A6B280399F500970AFC /* RegtestBlockchainManager.swift */; };
076D2A6E28039ACB00970AFC /* BlockchainObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D2A6D28039ACB00970AFC /* BlockchainObserver.swift */; };
0780F9C7272865260095FD6A /* LNSyncHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0780F9C6272865260095FD6A /* LNSyncHandler.swift */; };
07BBC76A26D02727000D96C4 /* DirectBindingsAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BBC76926D02727000D96C4 /* DirectBindingsAppApp.swift */; };
07BBC76C26D02727000D96C4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BBC76B26D02727000D96C4 /* ContentView.swift */; };
Expand Down Expand Up @@ -727,6 +729,9 @@
07BBCE7726D03B49000D96C4 /* TestBroadcasterInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07BBCE6726D03B49000D96C4 /* TestBroadcasterInterface.swift */; };
07C753E126D6BE4E00081BF8 /* HumanObjectPeerTestInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07C753DF26D6BE4E00081BF8 /* HumanObjectPeerTestInstance.swift */; };
07C753F326D9560200081BF8 /* PromiseKit in Frameworks */ = {isa = PBXBuildFile; productRef = 07C753F226D9560200081BF8 /* PromiseKit */; };
2DD11C86114C6827D6E338A2 /* BlockchainObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D2A6D28039ACB00970AFC /* BlockchainObserver.swift */; };
2DD11F1338488839D8955B7A /* PolarIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DD1172C8DF0B244CF69B0FA /* PolarIntegrationTest.swift */; };
2DD11F99CF6E547FA7FB9225 /* RegtestBlockchainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 076D2A6B280399F500970AFC /* RegtestBlockchainManager.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -1092,6 +1097,8 @@
076D227627FC219000970AFC /* OutPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutPoint.swift; sourceTree = "<group>"; };
076D227727FC219000970AFC /* InvoicePayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InvoicePayer.swift; sourceTree = "<group>"; };
076D227827FC219000970AFC /* DelayedPaymentOutputDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelayedPaymentOutputDescriptor.swift; sourceTree = "<group>"; };
076D2A6B280399F500970AFC /* RegtestBlockchainManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegtestBlockchainManager.swift; sourceTree = "<group>"; };
076D2A6D28039ACB00970AFC /* BlockchainObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockchainObserver.swift; sourceTree = "<group>"; };
0780F9C6272865260095FD6A /* LNSyncHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LNSyncHandler.swift; sourceTree = "<group>"; };
07BBC76626D02727000D96C4 /* DirectBindingsApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DirectBindingsApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
07BBC76926D02727000D96C4 /* DirectBindingsAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectBindingsAppApp.swift; sourceTree = "<group>"; };
Expand All @@ -1115,7 +1122,7 @@
07BBCB1826D034B1000D96C4 /* libldk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libldk.a; sourceTree = "<group>"; };
07BBCB1A26D03571000D96C4 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
07BBCB2726D0369F000D96C4 /* SwiftSocketPeerHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSocketPeerHandler.swift; sourceTree = "<group>"; };
07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegtestBlockchainObserver.swift; sourceTree = "<group>"; };
07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserverOld.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegtestBlockchainObserverOld.swift; sourceTree = "<group>"; };
07BBCB2926D0369F000D96C4 /* SwiftSocketEchoHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSocketEchoHandler.swift; sourceTree = "<group>"; };
07BBCB3426D036AC000D96C4 /* TCPPeerHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TCPPeerHandler.swift; sourceTree = "<group>"; };
07BBCB3526D036AC000D96C4 /* ChannelManagerConstructor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChannelManagerConstructor.swift; sourceTree = "<group>"; };
Expand All @@ -1130,6 +1137,7 @@
07BBCE6726D03B49000D96C4 /* TestBroadcasterInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestBroadcasterInterface.swift; sourceTree = "<group>"; };
07C753DF26D6BE4E00081BF8 /* HumanObjectPeerTestInstance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HumanObjectPeerTestInstance.swift; sourceTree = "<group>"; };
07C753E826D954B100081BF8 /* PolarConnectionExperiment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolarConnectionExperiment.swift; sourceTree = "<group>"; };
2DD1172C8DF0B244CF69B0FA /* PolarIntegrationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PolarIntegrationTest.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -1168,6 +1176,7 @@
076D1D2227F3828E00970AFC /* BTCVarInt.swift */,
076D1D2527F38FDD00970AFC /* BitcoinTests.swift */,
076D1D2727F397E600970AFC /* BTCHashing.swift */,
2DD1172C8DF0B244CF69B0FA /* PolarIntegrationTest.swift */,
);
path = bitcoin;
sourceTree = "<group>";
Expand Down Expand Up @@ -1652,9 +1661,11 @@
074A2DCB26D970D400370D0B /* RegtestBroadcasterInterface.swift */,
074A2DCC26D970D500370D0B /* RegtestChannelManagerPersister.swift */,
07BBCB2726D0369F000D96C4 /* SwiftSocketPeerHandler.swift */,
07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserver.swift */,
07BBCB2826D0369F000D96C4 /* RegtestBlockchainObserverOld.swift */,
07BBCB2926D0369F000D96C4 /* SwiftSocketEchoHandler.swift */,
0780F9C6272865260095FD6A /* LNSyncHandler.swift */,
076D2A6D28039ACB00970AFC /* BlockchainObserver.swift */,
076D2A6B280399F500970AFC /* RegtestBlockchainManager.swift */,
);
path = "app-batteries";
sourceTree = "<group>";
Expand Down Expand Up @@ -1781,8 +1792,8 @@
);
mainGroup = 07BBC75D26D02727000D96C4;
packageReferences = (
07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit" */,
076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto" */,
07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit.git" */,
076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto.git" */,
);
productRefGroup = 07BBC76726D02727000D96C4 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1909,11 +1920,12 @@
076D23EB27FC219100970AFC /* Result_PositiveTimestampCreationErrorZ.swift in Sources */,
076D244927FC219200970AFC /* InvoiceFeatures.swift in Sources */,
076D23A127FC219100970AFC /* Result_COption_EventZDecodeErrorZ.swift in Sources */,
076D2A6E28039ACB00970AFC /* BlockchainObserver.swift in Sources */,
076D23DD27FC219100970AFC /* Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.swift in Sources */,
076D230127FC219000970AFC /* C2Tuple_SignatureSignatureZ.swift in Sources */,
076D22A327FC219000970AFC /* Option_u16Z.swift in Sources */,
076D24FB27FC219200970AFC /* LockedChannelMonitor.swift in Sources */,
074A2DC426D957BC00370D0B /* RegtestBlockchainObserver.swift in Sources */,
074A2DC426D957BC00370D0B /* RegtestBlockchainObserverOld.swift in Sources */,
076D231B27FC219000970AFC /* Result_ScorerDecodeErrorZ.swift in Sources */,
076D241327FC219100970AFC /* Result_ReplyShortChannelIdsEndDecodeErrorZ.swift in Sources */,
076D249D27FC219200970AFC /* HolderCommitmentTransaction.swift in Sources */,
Expand Down Expand Up @@ -2155,6 +2167,7 @@
076D22DF27FC219000970AFC /* Filter.swift in Sources */,
076D23EF27FC219100970AFC /* Result_NodeAnnouncementDecodeErrorZ.swift in Sources */,
076D23AB27FC219100970AFC /* Result_HTLCUpdateDecodeErrorZ.swift in Sources */,
076D2A6C280399F500970AFC /* RegtestBlockchainManager.swift in Sources */,
07BBCB1B26D03578000D96C4 /* ldk_net.c in Sources */,
076D245327FC219200970AFC /* BestBlock.swift in Sources */,
076D229D27FC219000970AFC /* Option_MonitorEventZ.swift in Sources */,
Expand Down Expand Up @@ -2547,6 +2560,9 @@
076D230C27FC219000970AFC /* C2Tuple_PaymentHashPaymentIdZ.swift in Sources */,
076D24C827FC219200970AFC /* ChannelDetails.swift in Sources */,
076D237227FC219100970AFC /* Result_NoneAPIErrorZ.swift in Sources */,
2DD11F99CF6E547FA7FB9225 /* RegtestBlockchainManager.swift in Sources */,
2DD11C86114C6827D6E338A2 /* BlockchainObserver.swift in Sources */,
2DD11F1338488839D8955B7A /* PolarIntegrationTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2874,15 +2890,15 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto" */ = {
076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto.git" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-crypto.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit" */ = {
07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit.git" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/mxcl/PromiseKit.git";
requirement = {
Expand All @@ -2895,12 +2911,12 @@
/* Begin XCSwiftPackageProductDependency section */
076D1D2A27F5163500970AFC /* Crypto */ = {
isa = XCSwiftPackageProductDependency;
package = 076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto" */;
package = 076D1D2927F5163500970AFC /* XCRemoteSwiftPackageReference "swift-crypto.git" */;
productName = Crypto;
};
07C753F226D9560200081BF8 /* PromiseKit */ = {
isa = XCSwiftPackageProductDependency;
package = 07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit" */;
package = 07C753F126D9560200081BF8 /* XCRemoteSwiftPackageReference "PromiseKit.git" */;
productName = PromiseKit;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PolarConnectionExperiment: ObservableObject {
var keysManager: KeysManager
var keysInterface: KeysInterface

var blockchainObserver: RegtestBlockchainObserver!
var blockchainObserver: RegtestBlockchainObserverOld!

// reliant on async response from blockchain observer
var channelManagerConstructor: ChannelManagerConstructor!
Expand Down Expand Up @@ -53,7 +53,7 @@ class PolarConnectionExperiment: ObservableObject {

self.keysInterface = self.keysManager.as_KeysInterface()

self.blockchainObserver = RegtestBlockchainObserver(listeners: [], chainTip: nil) {
self.blockchainObserver = RegtestBlockchainObserverOld(listeners: [], chainTip: nil) {
// sync complete
let config = UserConfig()
let lightningNetwork = LDKNetwork_Regtest
Expand Down
Loading

0 comments on commit 147518f

Please sign in to comment.