Skip to content

Commit 67574b3

Browse files
committed
Fix compiler errors stemming from using new Swift files.
1 parent 8251471 commit 67574b3

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

ci/LDKSwift/Sources/LDKSwift/batteries/ChannelManagerConstructor.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public struct ChannelManagerConstructionParameters {
8181

8282
fileprivate func router(networkGraph: NetworkGraph?) -> Router {
8383
if let netGraph = networkGraph, let scorer = self.scorer, let scoreParams = self.scoreParams {
84-
return DefaultRouter(networkGraph: netGraph, logger: self.logger, randomSeedBytes: self.entropySource.getSecureRandomBytes(), scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
84+
return DefaultRouter(networkGraph: netGraph, logger: self.logger, entropySource: self.entropySource, scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
8585
}
86-
return CMCRouter()
86+
return CMCRouter(messageRouter: MessageRouter())
8787
}
8888
}
8989

@@ -124,7 +124,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
124124
public private(set) var channel_monitors: [(ChannelMonitor, [UInt8])]
125125

126126

127-
public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], networkGraph: NetworkGraphArgument, filter: Filter?, params: ChannelManagerConstructionParameters) throws {
127+
public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], networkGraph: NetworkGraphArgument, filter: Filter?, params: ChannelManagerConstructionParameters, logger: Logger) throws {
128128

129129
self.constructionParameters = params
130130

@@ -204,7 +204,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
204204

205205
if let filter = filter {
206206
for (currentMonitor, _) in self.channel_monitors {
207-
currentMonitor.loadOutputsToWatch(filter: filter)
207+
currentMonitor.loadOutputsToWatch(filter: filter, logger: logger)
208208
}
209209
}
210210

ci/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public class HumanObjectPeerTestInstance {
523523
let config = UserConfig.initWithDefault()
524524
let theirNodeId = peerB.channelManager.getOurNodeId()
525525
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
526-
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, overrideConfig: config)
526+
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)
527527

528528
XCTAssertTrue(channelOpenResult.isOk())
529529
let channels = peerA.channelManager.listChannels()
@@ -757,7 +757,13 @@ public class HumanObjectPeerTestInstance {
757757
}
758758

759759
let channelManagerConstructor = peer1.constructor!
760-
let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)
760+
761+
let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromInvoice(invoice: invoice).getValue()!
762+
let paymentId = invoice.paymentHash()!
763+
764+
765+
let invoicePaymentResult = channelManagerConstructor.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Bindings.Retry.initWithAttempts(a: 3))
766+
// let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)
761767
XCTAssertTrue(invoicePaymentResult.isOk())
762768

763769
do {
@@ -853,7 +859,9 @@ public class HumanObjectPeerTestInstance {
853859
try! await Task.sleep(nanoseconds: 0_100_000_000)
854860
}
855861

856-
let invoicePayment = invoicePaymentResult.getValue()!
862+
863+
// let invoicePayment = invoicePaymentResult.getValue()!
864+
XCTAssert(invoicePaymentResult.isOk())
857865
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B)
858866
XCTAssertEqual(currentChannelBBalance, secondChannelBalanceBToA + SEND_MSAT_AMOUNT_A_TO_B)
859867
}
@@ -874,12 +882,12 @@ public class HumanObjectPeerTestInstance {
874882
let recreatedInvoice = Bolt11Invoice.fromStr(s: invoiceString)
875883
XCTAssertTrue(recreatedInvoice.isOk())
876884

877-
let invoicePaymentResult = Bindings.payZeroValueInvoice(invoice: invoice, amountMsats: SEND_MSAT_AMOUNT_B_TO_A, retryStrategy: Retry.initWithAttempts(a: 3), channelmanager: peer2.channelManager)
885+
886+
let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromZeroAmountInvoice(invoice: invoice, amountMsat: SEND_MSAT_AMOUNT_B_TO_A).getValue()!
887+
let paymentId = invoice.paymentHash()!
888+
let invoicePaymentResult = peer2.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Retry.initWithAttempts(a: 3))
878889
if let error = invoicePaymentResult.getError() {
879-
print("value type: \(error.getValueType())")
880-
if let routingError = error.getValueAsSending() {
881-
print("sending error: \(routingError)")
882-
}
890+
print("sending error: \(error)")
883891
}
884892
XCTAssertTrue(invoicePaymentResult.isOk())
885893

@@ -951,7 +959,8 @@ public class HumanObjectPeerTestInstance {
951959
try! await Task.sleep(nanoseconds: 0_100_000_000)
952960
}
953961

954-
let invoicePayment = invoicePaymentResult.getValue()!
962+
// let invoicePayment = invoicePaymentResult.getValue()!
963+
XCTAssert(invoicePaymentResult.isOk())
955964
XCTAssertEqual(currentChannelABalance, prePaymentBalanceAToB + SEND_MSAT_AMOUNT_B_TO_A)
956965
XCTAssertEqual(currentChannelBBalance, prePaymentBalanceBToA - SEND_MSAT_AMOUNT_B_TO_A)
957966
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B + SEND_MSAT_AMOUNT_B_TO_A)

ci/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class LDKSwiftTests: XCTestCase {
7272
)
7373

7474
let networkGraph = NetworkGraph(network: .Regtest, logger: logger)
75-
let channelManagerConstructor = try ChannelManagerConstructor(channelManagerSerialized: serialized_channel_manager, channelMonitorsSerialized: serializedChannelMonitors, networkGraph: NetworkGraphArgument.instance(networkGraph), filter: filter, params: constructionParameters)
75+
let channelManagerConstructor = try ChannelManagerConstructor(channelManagerSerialized: serialized_channel_manager, channelMonitorsSerialized: serializedChannelMonitors, networkGraph: NetworkGraphArgument.instance(networkGraph), filter: filter, params: constructionParameters, logger: logger)
7676

7777
let channelManager = channelManagerConstructor.channelManager;
7878
let cmPersister = TestChannelManagerPersister(channelManager: channelManager)
@@ -143,10 +143,10 @@ class LDKSwiftTests: XCTestCase {
143143
let rawInvoice = signedRawInvoice.rawInvoice()
144144
let description = rawInvoice.description()
145145
let descriptionString = description?.intoInner()
146-
XCTAssertEqual(descriptionString, "Invoice description")
146+
XCTAssertEqual(descriptionString!.getA(), "Invoice description")
147147

148148
let singleLineDescriptionString = invoice.intoSignedRaw().rawInvoice().description()?.intoInner()
149-
XCTAssertEqual(singleLineDescriptionString, "Invoice description")
149+
XCTAssertEqual(singleLineDescriptionString!.getA(), "Invoice description")
150150
}
151151

152152
func testWeirdChannelManagerMemoryLeak() async throws {
@@ -241,7 +241,7 @@ class LDKSwiftTests: XCTestCase {
241241
let reserveAmount: UInt64 = 1000 // a thousand satoshis rserve
242242
let peerPubkey = Self.hexStringToBytes(hexString: "02deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef")!
243243
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
244-
let channelOpenResult = channelManager.createChannel(theirNetworkKey: peerPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, overrideConfig: config)
244+
let channelOpenResult = channelManager.createChannel(theirNetworkKey: peerPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)
245245

246246
let channelOpenError = channelOpenResult.getError()!
247247
print("error type: \(channelOpenError.getValueType())")

ci/LDKSwift/Tests/LDKSwiftTests/WrappedSignerProviderTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,18 @@ class WrappedSignerProviderTests: XCTestCase {
136136
print("entering wrapper: readChanSigner()")
137137
return myKeysManager!.keysManager.asSignerProvider().readChanSigner(reader: reader)
138138
}
139-
140-
override func getDestinationScript() -> Bindings.Result_CVec_u8ZNoneZ {
139+
140+
override func getDestinationScript(channelKeysId: [UInt8]) -> Bindings.Result_CVec_u8ZNoneZ {
141141
print("entering wrapper: getDestinationScript()")
142-
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript()
142+
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript(channelKeysId: channelKeysId)
143143
}
144144

145145
override func getShutdownScriptpubkey() -> Bindings.Result_ShutdownScriptNoneZ {
146146
print("entering wrapper: getShutdownScriptpubkey()")
147147

148148
let randomHex = "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000"
149149
let randomHexBytes = LDKSwiftTests.hexStringToBytes(hexString: randomHex)!
150-
let witnessProgram = ShutdownScript.newWitnessProgram(version: 1, program: randomHexBytes)
150+
let witnessProgram = ShutdownScript.newWitnessProgram(witnessProgram: WitnessProgram(version: 1, program: randomHexBytes))
151151
let witnessBasedScript = witnessProgram.getValue()!
152152

153153
return Result_ShutdownScriptNoneZ.initWithOk(o: witnessBasedScript)

xcode/LDKFramework/DirectlyLinkedBindingsApp/app-batteries/PolarIntegrationSample.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class PolarIntegrationSample {
132132
let channelValueBtcString = "0.013"
133133
let reserveAmount: UInt64 = 1000 // a thousand satoshis rserve
134134
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
135-
let channelOpenResult = channelManager.createChannel(theirNetworkKey: lndPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, overrideConfig: config)
135+
let channelOpenResult = channelManager.createChannel(theirNetworkKey: lndPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)
136136

137137
if let channelOpenError = channelOpenResult.getError() {
138138
print("error type: \(channelOpenError.getValueType())")
@@ -204,8 +204,9 @@ public class PolarIntegrationSample {
204204
// let's not pay any invoices
205205
// channelManagerConstructor.interrupt(tcpPeerHandler: tcpPeerHandler)
206206
// return
207-
208-
let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: constructionParameters.payerRetries, channelmanager: channelManager)
207+
let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromInvoice(invoice: invoice).getValue()!
208+
let paymentId = invoice.paymentHash()!
209+
let invoicePaymentResult = channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: constructionParameters.payerRetries)
209210

210211
do {
211212
// process payment

0 commit comments

Comments
 (0)