Skip to content

Commit 73adb75

Browse files
authored
Merge pull request #127 from arik-so/arik/2024/01/prep-121
Prepare 0.0.121
2 parents 4996800 + 9ab9a0a commit 73adb75

File tree

197 files changed

+25794
-9006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+25794
-9006
lines changed

.github/actions/install-dependencies/action.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
run: |
2323
echo `pwd`
2424
mkdir -p ${{ inputs.destination }}/bin
25-
git clone --branch 0.0.118-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning
25+
git clone --branch 0.0.121-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning
2626
git clone --branch main https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
2727
- name: Install Rust, required targets
2828
if: ${{ inputs.configureRustNightly == 'true' }}
@@ -51,5 +51,9 @@ runs:
5151
run: |
5252
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
5353
pushd ${{ inputs.destination }}/ldk-c-bindings
54-
./genbindings.sh ../rust-lightning true
54+
if [ "$RUNNER_OS" == "macOS" ]; then
55+
./genbindings.sh ../rust-lightning true skip-tests
56+
else
57+
./genbindings.sh ../rust-lightning true
58+
fi
5559
popd

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

+4-4
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

+18-9
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

+4-4
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

+4-4
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)

0 commit comments

Comments
 (0)