Skip to content

Commit a596b45

Browse files
authored
Merge pull request #163 from TheBlueMatt/main
Update to c-bindings 0.0.123.1
2 parents 0785467 + 5081e53 commit a596b45

File tree

730 files changed

+91374
-63514
lines changed

Some content is hidden

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

730 files changed

+91374
-63514
lines changed

.github/workflows/build.yml

+52-57
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,55 @@ jobs:
258258
diffoscope ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg || echo
259259
exit 1
260260
fi
261+
- name: Run test against C# release library
262+
shell: bash
263+
run: |
264+
cd c_sharp
265+
ln -s ./packaging_artifacts/runtimes/linux-x64/native/libldkcsharp.so ./
266+
LD_LIBRARY_PATH=. dotnet run --project tests.csproj
267+
LD_LIBRARY_PATH=. dotnet run --project tests.csproj --configuration Release
268+
269+
osx_c_sharp:
270+
strategy:
271+
matrix:
272+
include:
273+
- platform: macos-13
274+
- platform: macos-14
275+
fail-fast: false
276+
runs-on: ${{ matrix.platform }}
277+
steps:
278+
- name: Checkout source code
279+
uses: actions/checkout@v2
280+
with:
281+
fetch-depth: 0
282+
- name: Setup .NET
283+
uses: actions/setup-dotnet@v4
284+
with:
285+
dotnet-version: '6.0.x'
286+
- name: Checkout latest binaries
287+
run: |
288+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
289+
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
290+
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
291+
SNAPSHOT_LINK="$(wget -O /dev/stdout "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
292+
wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
293+
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
294+
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
295+
tar xvvf ../../bins-snapshot.tgz
296+
mv ldk-java-bins-*/* ./
297+
unzip org.ldk.nupkg
298+
- name: Run test against C# release library
299+
shell: bash
300+
run: |
301+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
302+
cd c_sharp
303+
if [ "$(uname -m)" = "arm64" ]; then
304+
cp "../ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/runtimes/osx-arm64/native/libldkcsharp.dylib" ./libldkcsharp.dylib
305+
else
306+
cp "../ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/runtimes/osx-x64/native/libldkcsharp.dylib" ./libldkcsharp.dylib
307+
fi
308+
LD_LIBRARY_PATH=. dotnet run --project tests.csproj
309+
LD_LIBRARY_PATH=. dotnet run --project tests.csproj --configuration Release
261310
262311
java_bindings:
263312
runs-on: ubuntu-latest
@@ -673,44 +722,19 @@ jobs:
673722
exit 1
674723
fi
675724
676-
osx:
725+
osx_java:
677726
strategy:
678727
matrix:
679728
include:
680-
- platform: macos-11
681-
- platform: macos-12
682729
- platform: macos-13
730+
- platform: macos-14
683731
fail-fast: false
684732
runs-on: ${{ matrix.platform }}
685733
steps:
686-
- name: Install Rust components
687-
run: |
688-
rustup target install aarch64-apple-darwin
689-
rustup component add rust-src
690734
- name: Checkout source code
691735
uses: actions/checkout@v2
692736
with:
693737
fetch-depth: 0
694-
- name: Install cbindgen
695-
run: cargo install cbindgen
696-
- name: Checkout Rust-Lightning and LDK-C-Bindings git
697-
run: |
698-
git config --global user.email "[email protected]"
699-
git config --global user.name "LDK CI"
700-
# Note this is a different endpoint, as we need one non-upstream commit!
701-
git clone https://github.com/lightningdevkit/rust-lightning
702-
cd rust-lightning
703-
git checkout origin/0.0.123-bindings
704-
cd ..
705-
git clone https://github.com/lightningdevkit/ldk-c-bindings
706-
cd ldk-c-bindings
707-
git checkout 0.0.123
708-
cd lightning-c-bindings
709-
cargo update -p memchr --precise "2.5.0" --verbose
710-
- name: Rebuild C bindings and check the sample app builds + links
711-
run: |
712-
cd ldk-c-bindings
713-
CC=clang ./genbindings.sh ../rust-lightning true
714738
- name: Fetch OpenJDK 18
715739
run: |
716740
if [ "$(uname -m)" = "arm64" ]; then
@@ -728,7 +752,7 @@ jobs:
728752
fi
729753
tar xvvf openjdk-18.0.1.1_macos-x64_bin.tar.gz
730754
fi
731-
- name: Checkout latest Linux binaries
755+
- name: Checkout latest binaries
732756
run: |
733757
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
734758
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
@@ -739,24 +763,6 @@ jobs:
739763
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
740764
tar xvvf ../../bins-snapshot.tgz
741765
mv ldk-java-bins-*/* ./
742-
cd ../..
743-
mkdir -p src/main/resources/
744-
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
745-
- name: Build Java Release Bindings
746-
run: |
747-
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
748-
export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
749-
export PATH=$JAVA_HOME/bin:$PATH
750-
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
751-
752-
if [ "${{ matrix.platform }}" = "macos-11" ]; then
753-
export CC="clang --target=aarch64-apple-darwin"
754-
export LDK_TARGET=aarch64-apple-darwin
755-
export LDK_TARGET_CPU=apple-a14
756-
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
757-
cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null
758-
759-
fi
760766
- name: Fetch Maven 3.8.4
761767
run: |
762768
# We don't bother using the upstream mirrors as they remove prior
@@ -769,17 +775,6 @@ jobs:
769775
fi
770776
tar xvvf apache-maven-3.8.4-bin.tar.gz
771777
export PATH=apache-maven-3.8.4/bin:$PATH
772-
- name: Run Java Tests against built jar
773-
run: |
774-
export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
775-
export PATH=$JAVA_HOME/bin:$PATH
776-
mvn -DskipTests=true package
777-
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
778-
JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
779-
mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
780-
cd javatester
781-
mvn -q -B package
782-
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
783778
- name: Run Java Tests against release bins
784779
run: |
785780
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ The auto-generated code contains copies of the Rust documentation, which can als
77
[docs.rs/lightning](https://docs.rs/lightning). High-level documentation of the API can be found at
88
[lightningdevkit.org](https://lightningdevkit.org).
99

10+
API Mappings
11+
============
12+
13+
As the bindings are auto-generated, they often read fairly verbose with lots of additional type
14+
information compared to what might be expected with a native interface. A brief understanding of
15+
some Rust nomenclature will help read bindings:
16+
17+
## `Result`
18+
19+
Rust APIs make heavy use of the `Result` enum. They can either be in an `Ok` state, with an
20+
optional value or an `Err` state, with an optional error value. These often appear as
21+
`Result_OKValueTypeErrValueTypeZ` in bindings. Subclasses are build for the `Ok` and `Err` states,
22+
with the appropriate values available in the subclasses which all instances will be of.
23+
24+
## `Option`
25+
26+
Similar to `Result`, Rust APIs make heavy use of the `Option` enum. Like `Result`, they may contain
27+
a value in the `Some` state, but may contain no value in the `None` state. They are mapped
28+
similarly to `Result`s, usually as `Option_SomeValueTypeZ`.
29+
30+
## Tuples
31+
32+
Rust APIs occasionally use tuples, which are simply mapped as a tuple type like
33+
`TwoTuple_FirstValueTypeSecondValueTypeZ`. Individual elements can be fetched or set with `get_a()`,
34+
`get_b()`, `set_a(..)`, etc.
35+
36+
## Tuple Types
37+
38+
Rust APIs occasionally build structs which are simply a named tuple type. These appear in rust as,
39+
eg, `struct PrintableString(String)`, and in the bindings as simply the class name (eg
40+
`class PrintableString`). The value(s) in the tuple can be fetched or set with `get_a()`,
41+
`get_b()`, `set_a(..)`, etc.
42+
1043
Building
1144
========
1245

@@ -42,8 +75,8 @@ the browser you will need to provide your own bridge from `SocketDescriptor` to
4275

4376
# C#
4477

45-
The C# bindings are functionally complete, but should be considered alpha quality. They are brand
46-
new and likely contain bugs or memory leaks.
78+
The C# bindings are functionally complete, but should be considered beta quality. As they are
79+
relatively new, unexpected issues remain possible, and bug reports are welcome.
4780

4881
## General
4982

0 commit comments

Comments
 (0)