Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version to 0.1.0 #138

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ runs:
run: |
echo `pwd`
mkdir -p ${{ inputs.destination }}/bin
git clone --branch 0.0.124-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
git clone --branch 0.1-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning
git clone --branch 0.1 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
- name: Install Rust, required targets
if: ${{ inputs.configureRustNightly == 'true' }}
shell: bash
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ jobs:
sudo apt-get update
# sudo apt-get -y upgrade
sudo apt-get -y install cargo lld git g++ clang curl
rustup install 1.73.0
rustup default 1.73.0
- name: Print updated environment details
run: |
set -x
rustup --version
clang --version
clang --print-resource-dir
ls -ll "$(clang -print-resource-dir)"
ls -ll "$(clang -print-resource-dir)/lib/linux"
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
Expand Down Expand Up @@ -87,10 +97,11 @@ jobs:
- name: Build Swift bindings package
run: |
cd ci/LDKSwift
# should be /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a
export LLVM_CLANG_ASAN_PATH="$(clang -print-resource-dir)/lib/linux/libclang_rt.asan-x86_64.a"
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift build
env:
LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
RUST_BACKTRACE: 1
- name: Test Swift bindings package without address sanitizer
run: |
Expand All @@ -103,8 +114,9 @@ jobs:
continue-on-error: true
run: |
cd ci/LDKSwift
# should be /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a
export LLVM_CLANG_ASAN_PATH="$(clang -print-resource-dir)/lib/linux/libclang_rt.asan-x86_64.a"
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v
env:
LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
RUST_BACKTRACE: 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ In order to generate these bindings from scratch, you will need to clone two dep
**[rust-lightning](https://github.com/lightningdevkit/rust-lightning)**, (a specific branch built for bindings compatibility):

```shell
git clone --branch 0.0.124-bindings https://github.com/lightningdevkit/rust-lightning /path/to/rust-lightning
git clone --branch 0.1-bindings https://github.com/lightningdevkit/rust-lightning /path/to/rust-lightning
```

**[ldk-c-bindings](https://github.com/lightningdevkit/ldk-c-bindings)**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,18 @@ public struct ChannelManagerConstructionParameters {
)
.asRouter()
}
return CMCRouter(messageRouter: MessageRouter())
return CMCRouter()
}

private class CMCMessageRouter: MessageRouter {

}

fileprivate func messageRouter(networkGraph: NetworkGraph?) -> MessageRouter {
if let netGraph = networkGraph {
return DefaultMessageRouter(networkGraph: netGraph, entropySource: self.entropySource).asMessageRouter()
}
return CMCMessageRouter()
}
}

Expand Down Expand Up @@ -192,10 +203,12 @@ public class ChannelManagerConstructor: NativeTypeWrapper {

// TODO: figure out better way to obtain a router
let router = params.router(networkGraph: self.netGraph)
let messageRouter = params.messageRouter(networkGraph: self.netGraph)
let channelManagerReadArgs = ChannelManagerReadArgs(
entropySource: params.entropySource, nodeSigner: params.nodeSigner, signerProvider: params.signerProvider,
feeEstimator: params.feeEstimator, chainMonitor: params.chainMonitor.asWatch(),
txBroadcaster: params.txBroadcaster, router: router, logger: params.logger, defaultConfig: params.config,
txBroadcaster: params.txBroadcaster, router: router, messageRouter: messageRouter, logger: params.logger,
defaultConfig: params.config,
channelMonitors: monitors)

guard
Expand Down Expand Up @@ -272,10 +285,11 @@ public class ChannelManagerConstructor: NativeTypeWrapper {

self.netGraph = netGraph
let router = params.router(networkGraph: self.netGraph)
let messageRouter = params.messageRouter(networkGraph: self.netGraph)
let timestampSeconds = UInt32(NSDate().timeIntervalSince1970)
self.channelManager = ChannelManager(
feeEst: params.feeEstimator, chainMonitor: params.chainMonitor.asWatch(),
txBroadcaster: params.txBroadcaster, router: router, logger: params.logger,
txBroadcaster: params.txBroadcaster, router: router, messageRouter: messageRouter, logger: params.logger,
entropySource: params.entropySource, nodeSigner: params.nodeSigner, signerProvider: params.signerProvider,
config: params.config, params: chainParameters, currentTimestamp: timestampSeconds)

Expand Down Expand Up @@ -355,6 +369,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
nodeIdLookup: NodeIdLookUp(), messageRouter: MessageRouter(),
offersHandler: self.channelManager.asOffersMessageHandler(),
asyncPaymentsHandler: ignoringMessageHandler.asAsyncPaymentsMessageHandler(),
dnsResolver: ignoringMessageHandler.asDNSResolverMessageHandler(),
customHandler: ignoringMessageHandler.asCustomOnionMessageHandler())

// if there is a graph msg handler, set its is_owned to false
Expand Down
36 changes: 18 additions & 18 deletions ci/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ public class HumanObjectPeerTestInstance {
XCTAssertEqual(usableChannelsA[0].getChannelId().write(), fundingChannelId.write())
XCTAssertEqual(usableChannelsB[0].getChannelId().write(), fundingChannelId.write())

let originalChannelBalanceAToB = channelAToB.getBalanceMsat()
let originalChannelBalanceBToA = channelBToA.getBalanceMsat()
let originalChannelBalanceAToB = channelAToB.getOutboundCapacityMsat()
let originalChannelBalanceBToA = channelBToA.getOutboundCapacityMsat()
print("original balance A->B mSats: \(originalChannelBalanceAToB)")
print("original balance B->A mSats: \(originalChannelBalanceBToA)")

Expand Down Expand Up @@ -739,21 +739,20 @@ public class HumanObjectPeerTestInstance {

// confirmedChannelBlock = await HumanObjectPeerTestInstance.openChannel(peerA: peer2, peerB: peer3, fundingAmount: FUNDING_SATOSHI_AMOUNT, latestBlock: confirmedChannelBlock, otherPeers: [peer1])

let originalChannelBalanceAToB = channelAToB.getBalanceMsat()
let originalChannelBalanceBToA = channelBToA.getBalanceMsat()
let originalChannelBalanceAToB = channelAToB.getOutboundCapacityMsat()
let originalChannelBalanceBToA = channelBToA.getOutboundCapacityMsat()

let secondChannelBalanceAToB = channelAToB.getBalanceMsat()
let secondChannelBalanceBToA = channelBToA.getBalanceMsat()
let secondChannelBalanceAToB = channelAToB.getOutboundCapacityMsat()
let secondChannelBalanceBToA = channelBToA.getOutboundCapacityMsat()

let logger = TestLogger()

do {
// create invoice for 10k satoshis to pay to peer2

let invoiceResult = Bindings.createInvoiceFromChannelmanager(
channelmanager: peer2.channelManager, nodeSigner: peer2.explicitKeysManager.asNodeSigner(),
logger: logger, network: .Bitcoin, amtMsat: SEND_MSAT_AMOUNT_A_TO_B, description: "Invoice description",
invoiceExpiryDeltaSecs: 60, minFinalCltvExpiryDelta: 24)
channelmanager: peer2.channelManager, amtMsat: SEND_MSAT_AMOUNT_A_TO_B,
description: "Invoice description", invoiceExpiryDeltaSecs: 60, minFinalCltvExpiryDelta: 24)
if let invoiceError = invoiceResult.getError() {
let creationError = invoiceError.getValueAsCreationError()
print("creation error: \(creationError)")
Expand Down Expand Up @@ -899,8 +898,8 @@ public class HumanObjectPeerTestInstance {
while true {
let channelA = peer1.channelManager.listUsableChannels()[0]
let channelB = peer2.channelManager.listUsableChannels()[0]
currentChannelABalance = channelA.getBalanceMsat()
currentChannelBBalance = channelB.getBalanceMsat()
currentChannelABalance = channelA.getOutboundCapacityMsat()
currentChannelBBalance = channelB.getOutboundCapacityMsat()
if currentChannelABalance != secondChannelBalanceAToB
&& currentChannelBBalance != secondChannelBalanceBToA
{
Expand All @@ -920,14 +919,13 @@ public class HumanObjectPeerTestInstance {
do {
// send some money back
// create invoice for 10k satoshis to pay to peer2
let prePaymentBalanceAToB = peer1.channelManager.listUsableChannels()[0].getBalanceMsat()
let prePaymentBalanceBToA = peer2.channelManager.listUsableChannels()[0].getBalanceMsat()
let prePaymentBalanceAToB = peer1.channelManager.listUsableChannels()[0].getOutboundCapacityMsat()
let prePaymentBalanceBToA = peer2.channelManager.listUsableChannels()[0].getOutboundCapacityMsat()
print("pre-payment balance A->B mSats: \(prePaymentBalanceAToB)")
print("pre-payment balance B->A mSats: \(prePaymentBalanceBToA)")

let invoiceResult = Bindings.createInvoiceFromChannelmanager(
channelmanager: peer1.channelManager, nodeSigner: peer1.explicitKeysManager.asNodeSigner(),
logger: logger, network: .Bitcoin, amtMsat: nil, description: "Second invoice description",
channelmanager: peer1.channelManager, amtMsat: nil, description: "Second invoice description",
invoiceExpiryDeltaSecs: 60, minFinalCltvExpiryDelta: 24)
let invoice = invoiceResult.getValue()!
print("Implicit amount invoice: \(invoice.toStr())")
Expand All @@ -938,7 +936,9 @@ public class HumanObjectPeerTestInstance {


let (paymentHash, recipientOnion, routeParameters) =
Bindings.paymentParametersFromZeroAmountInvoice(invoice: invoice, amountMsat: SEND_MSAT_AMOUNT_B_TO_A)
Bindings.paymentParametersFromVariableAmountInvoice(
invoice: invoice, amountMsat: SEND_MSAT_AMOUNT_B_TO_A
)
.getValue()!
let paymentId = invoice.paymentHash()!
let invoicePaymentResult = peer2.channelManager.sendPayment(
Expand Down Expand Up @@ -1011,8 +1011,8 @@ public class HumanObjectPeerTestInstance {
while true {
let channelA = peer1.channelManager.listUsableChannels()[0]
let channelB = peer2.channelManager.listUsableChannels()[0]
currentChannelABalance = channelA.getBalanceMsat()
currentChannelBBalance = channelB.getBalanceMsat()
currentChannelABalance = channelA.getOutboundCapacityMsat()
currentChannelBBalance = channelB.getOutboundCapacityMsat()
if currentChannelABalance != prePaymentBalanceAToB && currentChannelBBalance != prePaymentBalanceBToA {
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ class WrappedSignerProviderTests: XCTestCase {
return nodeId
}

override func getInboundPaymentKeyMaterial() -> [UInt8] {
print("entering wrapper: getInboundPaymentKeyMaterial()")
return myKeysManager!.keysManager.asNodeSigner().getInboundPaymentKeyMaterial()
}

override func signGossipMessage(msg: Bindings.UnsignedGossipMessage) -> Bindings.Result_ECDSASignatureNoneZ {
print("entering wrapper: signGossipMessage()")
return myKeysManager!.keysManager.asNodeSigner().signGossipMessage(msg: msg)
Expand Down
Loading
Loading