lightningdevkit / ldk-c-bindings Goto Github PK
View Code? Open in Web Editor NEWMain LDK C Bindings on which other bindings are built
License: Other
Main LDK C Bindings on which other bindings are built
License: Other
Which seems to be missing
This is at least required for the new NodeAlias
type which is really all about having Display
.
I'm trying to build this on macos x86 but fails with:
./genbindings.sh /opt/rust-lightning-matt true
...
+ '[' '-ffile-prefix-map=/Users/g/.cargo= -frandom-seed=42 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.9 --target=aarch64-apple-darwin -mcpu=apple-a14' '!=' '' ']'
+ RUSTFLAGS='--remap-path-prefix /opt/rust-lightning-matt=rust-lightning --remap-path-prefix /opt/ldk-c-bindings=ldk-c-bindings --remap-path-prefix /Users/g/.cargo= -C target-cpu=apple-a14'
+ cargo build --target aarch64-apple-darwin
Compiling cc v1.0.69
Compiling autocfg v1.0.1
Compiling bitcoin_hashes v0.9.7
Compiling bech32 v0.7.3
error[E0463]: can't find crate for `std`
|
= note: the `aarch64-apple-darwin` target may not be installed
= help: consider downloading the target with `rustup target add aarch64-apple-darwin`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `bech32`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`
|
= note: the `aarch64-apple-darwin` target may not be installed
= help: consider downloading the target with `rustup target add aarch64-apple-darwin`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: build failed
See full output
There was an issue raised in ldk-swift pertaining to parameter names: lightningdevkit/ldk-swift#91
For the sake of automatically being able to take argument names from the C bindings, I think it would be nice to be able to improve naming right here at the source. Specifically, here's the offending C method signature:
/**
* Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write
*/
struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c);
People are always confused that the byte order is swapped when logging/printing to hex, so we should have a wrapper type that does that.
Moved from lightningdevkit/rust-lightning#677
Discussed offline. In this variation, the C++ class would be LDKObject
. Since the copy constructor would be deleted, any object passed to rust_fn
would need to be an rvalue; it would be a compilation error to pass the object as an lvalue. Instead, the user would need to explicitly std::move
the lvalue in order to pass it to rust_fn
as an rvalue, which would trigger the move constructor.
Agreed to open an issue and prioritize based on user need for the C++ header.
Originally posted by @jkczyz in lightningdevkit/rust-lightning#618 (comment)
Sadly this is currently not persisted as it requires some io stuff that wasn't in place. Still, it should very much easily be exposeable, so we really need to.
This keeps coming up, and I think we can actually do it via a separate artifact.
Currently, it has s a hidden nullability, which, at least for Swift, becomes a hidden liability.
Moved from lightningdevkit/rust-lightning#682
Val pointed out at lightningdevkit/rust-lightning#618 (comment) that we should have a broader C demo client for the C bindings, though more than simply feature-parity with the C++ demo would probably also be good.
We're hoping to start using the channels()
and nodes()
functions on the ReadOnlyNetworkGraph
, but they are not currently exported to the C-bindings
I got the following error on building. Older rustc version is better?
Environment
$ rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/xxx/.rustup
installed toolchains
--------------------
stable-aarch64-apple-darwin
stable-x86_64-apple-darwin (default)
1.60.0-x86_64-apple-darwin
1.61.0-x86_64-apple-darwin
installed targets for active toolchain
--------------------------------------
aarch64-apple-darwin
wasm32-wasi
x86_64-apple-darwin
active toolchain
----------------
1.61.0-x86_64-apple-darwin (overridden by '/Users/xxx/tmp/ldk-c-bindings/c-bindings-gen/rust-toolchain')
rustc 1.61.0 (fe5b13d68 2022-05-18)
Error message
$ bash genbindings.sh /Users/xxx/tmp/rust-lightning true
+ '[' '!' -d /Users/xxx/tmp/rust-lightning/lightning -o true '!=' true -a true '!=' false ']'
+ export LC_ALL=C
+ LC_ALL=C
...
+ CARGO_BUILD_ARGS=--features=std
+ cat /tmp/crate-source.txt
+ RUST_BACKTRACE=1
+ /Users/xxx/tmp/ldk-c-bindings/c-bindings-gen/target/release/c-bindings-gen /Users/xxx/tmp/ldk-c-bindings/lightning-c-bindings/src/ /Users/xxx/tmp/ldk-c-bindings/lightning-c-bindings/src/c_types/derived.rs /Users/xxx/tmp/ldk-c-bindings/lightning-c-bindings/include/ldk_rust_types.h /Users/xxx/tmp/ldk-c-bindings/lightning-c-bindings/include/lightningpp.hpp
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for std::prelude::rust_2018:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring leading-colon use!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring pub(use) tree!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning_invoice::prelude:: - this may result in resolution failures
Ignoring leading-colon use!
Ignoring * use for lightning_invoice::prelude:: - this may result in resolution failures
Ignoring * use for lightning_invoice::prelude:: - this may result in resolution failures
Ignoring * use for lightning_invoice::prelude:: - this may result in resolution failures
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning::ln::msgs::fuzzy_internal_msgs:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring * use for lightning_invoice::prelude:: - this may result in resolution failures
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring leading-colon use!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring pub(use) tree!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring pub(use) tree!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Ignoring pub(use) tree!
Ignoring * use for lightning::prelude:: - this may result in resolution failures
Converting lightning::ln::chan_utils entries...
Ignoring * use for lightning::prelude:: - this may result in resolution failures
thread 'main' panicked at 'assertion failed: self.write_c_type_intern(w, t, generics, false, false, ptr_for_ref, false,\n true)', src/types.rs:2860:9
stack backtrace:
0: rust_begin_unwind
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
2: core::panicking::panic
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:48:5
3: c_bindings_gen::types::TypeResolver::write_c_type
at ldk-c-bindings/c-bindings-gen/src/types.rs:2860:3
4: c_bindings_gen::blocks::write_method_params
at ldk-c-bindings/c-bindings-gen/src/blocks.rs:558:5
5: c_bindings_gen::writeln_impl
at ldk-c-bindings/c-bindings-gen/src/main.rs:1334:10
6: c_bindings_gen::convert_file
at ldk-c-bindings/c-bindings-gen/src/main.rs:1882:6
7: c_bindings_gen::main
at ldk-c-bindings/c-bindings-gen/src/main.rs:2147:2
8: core::ops::function::FnOnce::call_once
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Other environment
I got the same error on Ubuntu 22.04 and 16.04.7.
Currently we drop all the errors and turn them into None
, we should actually return errors of the correct type.
With LLVM/clang 13 now released, we should try following Bitcoin Core and using LLVM's linker instead of OSX's linker. This may allow for deterministic Java builds.
See error output at #14 (comment)
We don't currently expose the flag accessors for features, we should do this.
Running genbindings.sh
on macOS (Monterey, M1) stopped with message:
+ RUSTC_BOOTSTRAP=1
+ cargo rustc --profile=check --features=allow_wallclock_use -- --cfg=c_bindings -Zunpretty=expanded
Updating crates.io index
Checking lightning v0.0.103 (/Users/cuhte3/lightningDevKit/rust-lightning/lightning)
Finished dev [optimized + debuginfo] target(s) in 2.73s
+ popd
~/lightningDevKit/ldk-c-bindings
+ '[' 'host: aarch64-apple-darwin' = 'host: x86_64-apple-darwin' ']'
+ sed -i '1ipub mod lightning {\n' /tmp/lightning-crate-source.txt
sed: 1: "/tmp/lightning-crate-so ...": extra characters at the end of l command
Because the new HTLC State enums are in channel.rs
and re-exported in channelmanager.rs
which we still dont support.
We need this for 106, where we now have a public field which is an Option<Enum>
and we need to be able to return it.
Would make it typed and have to do a decode call first.
Not a deal-breaker, but I noticed that whenever the build log reaches set +x
, nothing really happens beyond that.
According to @arik-so it's usually fine past that point to just force the shell script to terminate, but I was wondering if there is a fix for this so CI over at ldk-swift
doesn't take ages to run.
genbindings.sh
fails on macos. target file doesn't create. Can anyone help with it?
Here is an example of an error I get: genbindings.sh
(base) ➜ ldk-c-bindings git:(main) ./genbindings.sh /Users/brylee/Documents/Work/Blockware/Gitlab/ldk/rust-lightning false
#define _LDK_HEADER_VER "v0.0.108-22-gabf6564a44ad58cc"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.106.3-7-gc014ce6a2df808ff"
static inline const char* check_get_ldk_version() {
LDKStr bin_ver = _ldk_get_compiled_version();
if (_ldk_strncmp(_LDK_HEADER_VER, (const char*)bin_ver.chars, bin_ver.len) != 0) {
// Version mismatch, we don'''t know what we'''re running!
return 0;
}
return _LDK_HEADER_VER;
}
static inline const char* check_get_ldk_bindings_version() {
LDKStr bin_ver = _ldk_c_bindings_get_compiled_version();
if (_ldk_strncmp(_LDK_C_BINDINGS_HEADER_VER, (const char*)bin_ver.chars, bin_ver.len) != 0) {
// Version mismatch, we don'''t know what we'''re running!
return 0;
}
return _LDK_C_BINDINGS_HEADER_VER;
}
#endif /* _LDK_HEADER_VER */'
l
_l
#[warn(unused_variables)]
on by defaultwarning: unused variable: should_request_full_sync
--> lightning/src/util/test_utils.rs:471:7
|
471 | let should_request_full_sync = self.request_full_sync.load(Ordering::Acquire);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _should_request_full_sync
warning: unused variable: should_request_full_sync
--> lightning/src/routing/gossip.rs:437:7
|
437 | let should_request_full_sync = self.should_request_full_sync(&their_node_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _should_request_full_sync
warning: lightning
(lib) generated 3 warnings
Checking lightning-invoice v0.16.0 (/Users/brylee/Documents/Work/Blockware/Gitlab/ldk/rust-lightning/lightning-invoice)
warning: unused imports: ExpandedKey
, create_from_hash
, create
--> lightning-invoice/src/utils.rs:16:38
|
16 | use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
| ^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
|
= note: #[warn(unused_imports)]
on by default
warning: lightning-invoice
(lib) generated 1 warning
Finished dev [optimized + debuginfo] target(s) in 7.55s
RUST_BACKTRACE=full
for a verbose backtrace.#define _LDK_HEADER_VER "v0.0.108-22-gabf6564a44ad58cc"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.106.3-7-gc014ce6a2df808ff-dirty"
static inline const char* check_get_ldk_version() {
LDKStr bin_ver = _ldk_get_compiled_version();
if (_ldk_strncmp(_LDK_HEADER_VER, (const char*)bin_ver.chars, bin_ver.len) != 0) {
// Version mismatch, we don'''t know what we'''re running!
return 0;
}
return _LDK_HEADER_VER;
}
static inline const char* check_get_ldk_bindings_version() {
LDKStr bin_ver = _ldk_c_bindings_get_compiled_version();
if (_ldk_strncmp(_LDK_C_BINDINGS_HEADER_VER, (const char*)bin_ver.chars, bin_ver.len) != 0) {
// Version mismatch, we don'''t know what we'''re running!
return 0;
}
return _LDK_C_BINDINGS_HEADER_VER;
}
#endif /* _LDK_HEADER_VER */'
l
_l
#[warn(unused_variables)]
on by defaultwarning: unused variable: should_request_full_sync
--> lightning/src/util/test_utils.rs:471:7
|
471 | let should_request_full_sync = self.request_full_sync.load(Ordering::Acquire);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _should_request_full_sync
warning: unused variable: should_request_full_sync
--> lightning/src/routing/gossip.rs:437:7
|
437 | let should_request_full_sync = self.should_request_full_sync(&their_node_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _should_request_full_sync
warning: lightning
(lib) generated 3 warnings
Checking lightning-invoice v0.16.0 (/Users/brylee/Documents/Work/Blockware/Gitlab/ldk/rust-lightning/lightning-invoice)
warning: unused imports: ExpandedKey
, create_from_hash
, create
--> lightning-invoice/src/utils.rs:16:38
|
16 | use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
| ^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
|
= note: #[warn(unused_imports)]
on by default
warning: lightning-invoice
(lib) generated 1 warning
Finished dev [optimized + debuginfo] target(s) in 0.23s
RUST_BACKTRACE=full
for a verbose backtrace.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.