Skip to content

Commit

Permalink
Merge pull request #127 from arik-so/arik/2024/01/prep-121
Browse files Browse the repository at this point in the history
Prepare 0.0.121
  • Loading branch information
arik-so authored Feb 12, 2024
2 parents 4996800 + 9ab9a0a commit 73adb75
Show file tree
Hide file tree
Showing 197 changed files with 25,794 additions and 9,006 deletions.
8 changes: 6 additions & 2 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
run: |
echo `pwd`
mkdir -p ${{ inputs.destination }}/bin
git clone --branch 0.0.118-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning
git clone --branch 0.0.121-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning
git clone --branch main https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
- name: Install Rust, required targets
if: ${{ inputs.configureRustNightly == 'true' }}
Expand Down Expand Up @@ -51,5 +51,9 @@ runs:
run: |
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
pushd ${{ inputs.destination }}/ldk-c-bindings
./genbindings.sh ../rust-lightning true
if [ "$RUNNER_OS" == "macOS" ]; then
./genbindings.sh ../rust-lightning true skip-tests
else
./genbindings.sh ../rust-lightning true
fi
popd
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public struct ChannelManagerConstructionParameters {

fileprivate func router(networkGraph: NetworkGraph?) -> Router {
if let netGraph = networkGraph, let scorer = self.scorer, let scoreParams = self.scoreParams {
return DefaultRouter(networkGraph: netGraph, logger: self.logger, randomSeedBytes: self.entropySource.getSecureRandomBytes(), scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
return DefaultRouter(networkGraph: netGraph, logger: self.logger, entropySource: self.entropySource, scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
}
return CMCRouter()
return CMCRouter(messageRouter: MessageRouter())
}
}

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


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

self.constructionParameters = params

Expand Down Expand Up @@ -204,7 +204,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {

if let filter = filter {
for (currentMonitor, _) in self.channel_monitors {
currentMonitor.loadOutputsToWatch(filter: filter)
currentMonitor.loadOutputsToWatch(filter: filter, logger: logger)
}
}

Expand Down
27 changes: 18 additions & 9 deletions ci/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public class HumanObjectPeerTestInstance {
let config = UserConfig.initWithDefault()
let theirNodeId = peerB.channelManager.getOurNodeId()
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, overrideConfig: config)
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)

XCTAssertTrue(channelOpenResult.isOk())
let channels = peerA.channelManager.listChannels()
Expand Down Expand Up @@ -757,7 +757,13 @@ public class HumanObjectPeerTestInstance {
}

let channelManagerConstructor = peer1.constructor!
let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)

let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromInvoice(invoice: invoice).getValue()!
let paymentId = invoice.paymentHash()!


let invoicePaymentResult = channelManagerConstructor.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Bindings.Retry.initWithAttempts(a: 3))
// let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)
XCTAssertTrue(invoicePaymentResult.isOk())

do {
Expand Down Expand Up @@ -853,7 +859,9 @@ public class HumanObjectPeerTestInstance {
try! await Task.sleep(nanoseconds: 0_100_000_000)
}

let invoicePayment = invoicePaymentResult.getValue()!

// let invoicePayment = invoicePaymentResult.getValue()!
XCTAssert(invoicePaymentResult.isOk())
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B)
XCTAssertEqual(currentChannelBBalance, secondChannelBalanceBToA + SEND_MSAT_AMOUNT_A_TO_B)
}
Expand All @@ -874,12 +882,12 @@ public class HumanObjectPeerTestInstance {
let recreatedInvoice = Bolt11Invoice.fromStr(s: invoiceString)
XCTAssertTrue(recreatedInvoice.isOk())

let invoicePaymentResult = Bindings.payZeroValueInvoice(invoice: invoice, amountMsats: SEND_MSAT_AMOUNT_B_TO_A, retryStrategy: Retry.initWithAttempts(a: 3), channelmanager: peer2.channelManager)

let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromZeroAmountInvoice(invoice: invoice, amountMsat: SEND_MSAT_AMOUNT_B_TO_A).getValue()!
let paymentId = invoice.paymentHash()!
let invoicePaymentResult = peer2.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Retry.initWithAttempts(a: 3))
if let error = invoicePaymentResult.getError() {
print("value type: \(error.getValueType())")
if let routingError = error.getValueAsSending() {
print("sending error: \(routingError)")
}
print("sending error: \(error)")
}
XCTAssertTrue(invoicePaymentResult.isOk())

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

let invoicePayment = invoicePaymentResult.getValue()!
// let invoicePayment = invoicePaymentResult.getValue()!
XCTAssert(invoicePaymentResult.isOk())
XCTAssertEqual(currentChannelABalance, prePaymentBalanceAToB + SEND_MSAT_AMOUNT_B_TO_A)
XCTAssertEqual(currentChannelBBalance, prePaymentBalanceBToA - SEND_MSAT_AMOUNT_B_TO_A)
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B + SEND_MSAT_AMOUNT_B_TO_A)
Expand Down
8 changes: 4 additions & 4 deletions ci/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class LDKSwiftTests: XCTestCase {
)

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

let channelManager = channelManagerConstructor.channelManager;
let cmPersister = TestChannelManagerPersister(channelManager: channelManager)
Expand Down Expand Up @@ -143,10 +143,10 @@ class LDKSwiftTests: XCTestCase {
let rawInvoice = signedRawInvoice.rawInvoice()
let description = rawInvoice.description()
let descriptionString = description?.intoInner()
XCTAssertEqual(descriptionString, "Invoice description")
XCTAssertEqual(descriptionString!.getA(), "Invoice description")

let singleLineDescriptionString = invoice.intoSignedRaw().rawInvoice().description()?.intoInner()
XCTAssertEqual(singleLineDescriptionString, "Invoice description")
XCTAssertEqual(singleLineDescriptionString!.getA(), "Invoice description")
}

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

let channelOpenError = channelOpenResult.getError()!
print("error type: \(channelOpenError.getValueType())")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ class WrappedSignerProviderTests: XCTestCase {
print("entering wrapper: readChanSigner()")
return myKeysManager!.keysManager.asSignerProvider().readChanSigner(reader: reader)
}

override func getDestinationScript() -> Bindings.Result_CVec_u8ZNoneZ {
override func getDestinationScript(channelKeysId: [UInt8]) -> Bindings.Result_CVec_u8ZNoneZ {
print("entering wrapper: getDestinationScript()")
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript()
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript(channelKeysId: channelKeysId)
}

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

let randomHex = "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000"
let randomHexBytes = LDKSwiftTests.hexStringToBytes(hexString: randomHex)!
let witnessProgram = ShutdownScript.newWitnessProgram(version: 1, program: randomHexBytes)
let witnessProgram = ShutdownScript.newWitnessProgram(witnessProgram: WitnessProgram(version: 1, program: randomHexBytes))
let witnessBasedScript = witnessProgram.getValue()!

return Result_ShutdownScriptNoneZ.initWithOk(o: witnessBasedScript)
Expand Down
Loading

0 comments on commit 73adb75

Please sign in to comment.