ldk-c-bindings
18 months agoMerge pull request #22 from TheBlueMatt/main
Matt Corallo [Mon, 3 May 2021 17:55:04 +0000 (17:55 +0000)]
Merge pull request #22 from TheBlueMatt/main

Redo wasm bindings

18 months agoFix double-free of String bytes after converting an owned Str.
Matt Corallo [Mon, 3 May 2021 16:33:05 +0000 (16:33 +0000)]
Fix double-free of String bytes after converting an owned Str.

18 months agoRedo wasm bindings
Matt Corallo [Mon, 3 May 2021 14:58:06 +0000 (14:58 +0000)]
Redo wasm bindings

18 months agoMerge pull request #20 from TheBlueMatt/main
Matt Corallo [Mon, 3 May 2021 13:18:57 +0000 (13:18 +0000)]
Merge pull request #20 from TheBlueMatt/main

18 months agoUpdate CI to work around missing version.rs
Matt Corallo [Sun, 2 May 2021 22:36:34 +0000 (22:36 +0000)]
Update CI to work around missing version.rs

18 months agoUpdate auto-generated bindings (without new version files)
Matt Corallo [Sun, 2 May 2021 19:49:21 +0000 (19:49 +0000)]
Update auto-generated bindings (without new version files)

18 months agoAdd ability to get the LDK and LDK-C-Bindings version
Matt Corallo [Sun, 2 May 2021 18:37:45 +0000 (18:37 +0000)]
Add ability to get the LDK and LDK-C-Bindings version

18 months agoFix no-std+WASM builds by not mixing -flto and -fembed-bitcode
Matt Corallo [Sat, 1 May 2021 04:10:24 +0000 (04:10 +0000)]
Fix no-std+WASM builds by not mixing -flto and -fembed-bitcode

18 months agoMerge pull request #19 from TheBlueMatt/2021-04-invoice-incl
Matt Corallo [Sat, 1 May 2021 02:02:41 +0000 (02:02 +0000)]
Merge pull request #19 from TheBlueMatt/2021-04-invoice-incl

18 months agoBump git hashes to latest upstream 2021-04-invoice-incl
Matt Corallo [Fri, 30 Apr 2021 20:56:28 +0000 (20:56 +0000)]
Bump git hashes to latest upstream

18 months agoUpdate auto-generated bindings with new upstream invoice creation
Matt Corallo [Fri, 30 Apr 2021 01:17:42 +0000 (01:17 +0000)]
Update auto-generated bindings with new upstream invoice creation

18 months agoMap enum tuple variants with no contents as unitary enum variants
Matt Corallo [Fri, 30 Apr 2021 23:41:18 +0000 (23:41 +0000)]
Map enum tuple variants with no contents as unitary enum variants

cbindgen maps `enum A { V() }` with a `struct A_V_Body {}` which
has different size on C and C++ (0 and 1 bytes). While this is
fine if a different variant has non-0 size as the union will be
correctly sized. However, there isn't a lot of reason to rely on
this when we can just have a unitary variant as well.

18 months agoResolve issues with Str introduced when it became ownable
Matt Corallo [Fri, 30 Apr 2021 23:09:05 +0000 (23:09 +0000)]
Resolve issues with Str introduced when it became ownable

When converting from a Str to an &str, we previously took ownership
of the Str, copied the pointer to its characters to an &str and
returned the &str. This made the returned bytes always unreadable.

Further, there is now no reason to use Vec_u8Z for owned Strs, so
we swap for Str as well.

18 months agoResolve generic params with default (eg `<A=B(>) as their default.
Matt Corallo [Fri, 30 Apr 2021 18:35:58 +0000 (18:35 +0000)]
Resolve generic params with default (eg `<A=B(>) as their default.

18 months agoDrop stale () -> u8 mapping (now) used in Rust-only code
Matt Corallo [Fri, 30 Apr 2021 23:40:51 +0000 (23:40 +0000)]
Drop stale () -> u8 mapping (now) used in Rust-only code

18 months agoHandle generics on enums
Matt Corallo [Fri, 30 Apr 2021 16:19:51 +0000 (16:19 +0000)]
Handle generics on enums

18 months agoTake parameters to trait functions as mut
Matt Corallo [Thu, 29 Apr 2021 22:49:40 +0000 (22:49 +0000)]
Take parameters to trait functions as mut

In keeping with "generally, make all variables mut so that
converters can assume inputs are mut", we should do the same for
trait implementation blocks.

18 months agoSupport secp256k1 RecoverableSignatures
Matt Corallo [Thu, 29 Apr 2021 22:29:36 +0000 (22:29 +0000)]
Support secp256k1 RecoverableSignatures

18 months agoDrop debug print that slipped into git
Matt Corallo [Thu, 29 Apr 2021 22:18:52 +0000 (22:18 +0000)]
Drop debug print that slipped into git

18 months agoUpdate module paths for hash wrappers
Matt Corallo [Thu, 29 Apr 2021 15:21:35 +0000 (15:21 +0000)]
Update module paths for hash wrappers

18 months agoCorrect handling of Display trait conversion
Matt Corallo [Fri, 30 Apr 2021 04:33:10 +0000 (04:33 +0000)]
Correct handling of Display trait conversion

Previously we were incorrectly taking the *Rust* objects as
parameters in C functions instead of the C-mapped ones.

19 months agoMerge pull request #18 from TheBlueMatt/2021-04-invoice-incl
Matt Corallo [Thu, 29 Apr 2021 21:55:48 +0000 (21:55 +0000)]
Merge pull request #18 from TheBlueMatt/2021-04-invoice-incl

Bump to latest upstream and include lightning-invoice bindings

19 months agoUpdate auto-generated bindings with lightning-invoice
Matt Corallo [Thu, 29 Apr 2021 18:58:26 +0000 (18:58 +0000)]
Update auto-generated bindings with lightning-invoice

19 months agoSimplify crates in genbindings, add invoice, and bump upstream git
Matt Corallo [Sun, 18 Apr 2021 03:09:12 +0000 (03:09 +0000)]
Simplify crates in genbindings, add invoice, and bump upstream git

19 months agoHandle std::time::SystemTime as a manually-converted object
Matt Corallo [Thu, 29 Apr 2021 15:21:04 +0000 (15:21 +0000)]
Handle std::time::SystemTime as a manually-converted object

19 months agoUpdate C++ bindings demo to support new payment secret/hash API
Matt Corallo [Wed, 28 Apr 2021 01:53:08 +0000 (01:53 +0000)]
Update C++ bindings demo to support new payment secret/hash API

19 months agoAllow missing_docs again as lightning-invoice uses it for enums
Matt Corallo [Thu, 29 Apr 2021 15:23:13 +0000 (15:23 +0000)]
Allow missing_docs again as lightning-invoice uses it for enums

19 months agoSupport super:: in use block resolution
Matt Corallo [Mon, 19 Apr 2021 21:18:24 +0000 (17:18 -0400)]
Support super:: in use block resolution

19 months agoSupport FromStr and Display impls, even if impl'd in a priv module
Matt Corallo [Mon, 19 Apr 2021 21:17:41 +0000 (17:17 -0400)]
Support FromStr and Display impls, even if impl'd in a priv module

19 months agoSupport Self in generics in some cases (eg Result<Self, E> in an impl block)
Matt Corallo [Sun, 18 Apr 2021 20:23:50 +0000 (20:23 +0000)]
Support Self in generics in some cases (eg Result<Self, E> in an impl block)

19 months agoSupport taking an owned Self in function exports
Matt Corallo [Sun, 18 Apr 2021 18:10:39 +0000 (18:10 +0000)]
Support taking an owned Self in function exports

19 months agoAdd a u5 type and a [u8; 20]
Matt Corallo [Sun, 18 Apr 2021 03:08:22 +0000 (03:08 +0000)]
Add a u5 type and a [u8; 20]

19 months agoHandle additional type aliases for secp256k1 types
Matt Corallo [Sun, 18 Apr 2021 03:07:53 +0000 (03:07 +0000)]
Handle additional type aliases for secp256k1 types

19 months agoCorrectly handle methods on an enum that take self
Matt Corallo [Sun, 18 Apr 2021 03:06:01 +0000 (03:06 +0000)]
Correctly handle methods on an enum that take self

19 months agoHandle `Vec<&Thing>` conversion to C.
Matt Corallo [Sun, 18 Apr 2021 00:44:55 +0000 (00:44 +0000)]
Handle `Vec<&Thing>` conversion to C.

19 months agoHandle type resolution of `crate::thing` without a `use crate`
Matt Corallo [Sun, 18 Apr 2021 00:43:21 +0000 (00:43 +0000)]
Handle type resolution of `crate::thing` without a `use crate`

19 months agoMerge pull request #17 from TheBlueMatt/2021-04-upstream-confirm
Matt Corallo [Mon, 26 Apr 2021 17:25:15 +0000 (17:25 +0000)]
Merge pull request #17 from TheBlueMatt/2021-04-upstream-confirm

Bump upstream to handle the Confirm trait

19 months agoEnsure array lengthgs are Int literals 2021-04-upstream-confirm
Matt Corallo [Mon, 26 Apr 2021 16:59:43 +0000 (16:59 +0000)]
Ensure array lengthgs are Int literals

This fixes a bug where an array will be converted to
[u8; StringLiteral] which results in us deciding we don't know how
to map it.

Fixes: dec732cefbdd97585b7de7fd4a9521f44f1580dd
19 months agoFix build with old/OSX clang, fixes #15
Matt Corallo [Mon, 26 Apr 2021 16:39:26 +0000 (16:39 +0000)]
Fix build with old/OSX clang, fixes #15

19 months agoUpdate git hash to latest upstream
Matt Corallo [Mon, 26 Apr 2021 15:50:46 +0000 (15:50 +0000)]
Update git hash to latest upstream

19 months agoUpdate auto-generated bindings to latest upstream
Matt Corallo [Mon, 26 Apr 2021 15:49:44 +0000 (15:49 +0000)]
Update auto-generated bindings to latest upstream

19 months agoDrop redundant deref in vec iteration
Matt Corallo [Mon, 26 Apr 2021 15:42:09 +0000 (15:42 +0000)]
Drop redundant deref in vec iteration

19 months agoHandle tuple-in-slice conversions both to *and* from C
Matt Corallo [Mon, 26 Apr 2021 15:41:48 +0000 (15:41 +0000)]
Handle tuple-in-slice conversions both to *and* from C

19 months agoHandle transaction conversion directly instead of via a new var
Matt Corallo [Sun, 25 Apr 2021 22:30:07 +0000 (22:30 +0000)]
Handle transaction conversion directly instead of via a new var

new var conversion isn't supported everywhere, and there's really
no reason transaction conversion should need it.

19 months agoSomewhat more consistently map references to C
Matt Corallo [Mon, 26 Apr 2021 15:48:06 +0000 (15:48 +0000)]
Somewhat more consistently map references to C

Instead of assuming that in some cases references are
pre-dereferenced before the to-C prefix and suffix conversions, we
no longer do that.

This matches other cases and is simply more consistent, apparently
fixing an old oversight in early generation code.

19 months agoMerge pull request #16 from afilini/cleanup
Matt Corallo [Mon, 26 Apr 2021 16:01:51 +0000 (16:01 +0000)]
Merge pull request #16 from afilini/cleanup

Minor cleanup/refactoring

19 months agoReplace more manually-built `syn::Path` with `parse_quote!()`
Alekos Filini [Mon, 26 Apr 2021 12:20:47 +0000 (14:20 +0200)]
Replace more manually-built `syn::Path` with `parse_quote!()`

19 months agoUse `quote::format_ident!()` to make new `syn::Ident`
Alekos Filini [Mon, 26 Apr 2021 11:10:49 +0000 (13:10 +0200)]
Use `quote::format_ident!()` to make new `syn::Ident`

19 months agoUse `parse_quote!()` to build complex syn::* objects
Alekos Filini [Mon, 26 Apr 2021 10:01:09 +0000 (12:01 +0200)]
Use `parse_quote!()` to build complex syn::* objects

19 months agoRemove unused import
Alekos Filini [Thu, 22 Apr 2021 10:27:52 +0000 (12:27 +0200)]
Remove unused import

19 months agoAdd .gitignore to ./c-bindings-gen
Alekos Filini [Thu, 22 Apr 2021 10:25:44 +0000 (12:25 +0200)]
Add .gitignore to ./c-bindings-gen

19 months agoMerge pull request #14 from TheBlueMatt/main
Matt Corallo [Thu, 22 Apr 2021 15:27:11 +0000 (15:27 +0000)]
Merge pull request #14 from TheBlueMatt/main

Update to latest upstream

19 months agoFix LTO with secp256k1's C code.
Matt Corallo [Thu, 22 Apr 2021 02:36:30 +0000 (02:36 +0000)]
Fix LTO with secp256k1's C code.

19 months agoOnly (attempt to) build for wasm32 when we're building nostd
Matt Corallo [Thu, 22 Apr 2021 02:33:35 +0000 (02:33 +0000)]
Only (attempt to) build for wasm32 when we're building nostd

19 months agoImprove c-bindings-gen compile time somewhat
Matt Corallo [Thu, 22 Apr 2021 02:33:31 +0000 (02:33 +0000)]
Improve c-bindings-gen compile time somewhat

19 months agoUpdate git hash for latest upstream
Matt Corallo [Wed, 21 Apr 2021 22:35:48 +0000 (22:35 +0000)]
Update git hash for latest upstream

19 months agoUpdate auto-generated bindings to latest upstream
Matt Corallo [Wed, 21 Apr 2021 22:32:11 +0000 (22:32 +0000)]
Update auto-generated bindings to latest upstream

19 months agoUpdate C++ bindings demo to new upstream API
Matt Corallo [Wed, 21 Apr 2021 22:31:54 +0000 (22:31 +0000)]
Update C++ bindings demo to new upstream API

19 months agoHandle alternate import paths for secp Public and SecretKey
Matt Corallo [Wed, 21 Apr 2021 22:31:23 +0000 (22:31 +0000)]
Handle alternate import paths for secp Public and SecretKey

19 months agoClean up cbindgen.toml to drop probably-stale-by-now info and options
Matt Corallo [Fri, 16 Apr 2021 02:29:11 +0000 (02:29 +0000)]
Clean up cbindgen.toml to drop probably-stale-by-now info and options

19 months agoMerge pull request #12 from TheBlueMatt/2021-04-incl-persister
Matt Corallo [Fri, 16 Apr 2021 01:00:23 +0000 (01:00 +0000)]
Merge pull request #12 from TheBlueMatt/2021-04-incl-persister

Include lightning-persister in generated bindings

19 months agoMerge pull request #13 from TheBlueMatt/2021-04-bump-upstream
Matt Corallo [Fri, 16 Apr 2021 00:39:14 +0000 (00:39 +0000)]
Merge pull request #13 from TheBlueMatt/2021-04-bump-upstream

Bump to latest upstream

19 months agoRegenerate auto-generated bindings with lightning-persister 2021-04-incl-persister
Matt Corallo [Tue, 13 Apr 2021 00:28:37 +0000 (20:28 -0400)]
Regenerate auto-generated bindings with lightning-persister

19 months agoHandle std::io::IOError and include lightning-persister in bindings
Matt Corallo [Sun, 11 Apr 2021 22:33:42 +0000 (18:33 -0400)]
Handle std::io::IOError and include lightning-persister in bindings

19 months agoIgnore `Sized` bounds when processing generics
Matt Corallo [Mon, 12 Apr 2021 22:26:28 +0000 (18:26 -0400)]
Ignore `Sized` bounds when processing generics

19 months agoUpdate auto-generated bindings with new module structure
Matt Corallo [Thu, 15 Apr 2021 17:20:09 +0000 (13:20 -0400)]
Update auto-generated bindings with new module structure

19 months agoUpdate manual c-bindings types for new bindings module structure
Matt Corallo [Mon, 12 Apr 2021 21:31:44 +0000 (17:31 -0400)]
Update manual c-bindings types for new bindings module structure

19 months agoDont pass original crate name in generator CLI (as there are multiple)
Matt Corallo [Mon, 12 Apr 2021 17:59:20 +0000 (13:59 -0400)]
Dont pass original crate name in generator CLI (as there are multiple)

19 months agoMove top-level crate inside a pub module in prep for multi-crate bindings
Matt Corallo [Mon, 12 Apr 2021 21:37:55 +0000 (17:37 -0400)]
Move top-level crate inside a pub module in prep for multi-crate bindings

This wraps the lightning crate inside a `pub mod lightning` wrapper
in genbindings.sh, and modifies the binding generator to handle it.

It ends up removing some code in the main TypeResolver, at the cost
of some extra handling of imports in the ImportResolver, which
focuses the amount of code that needs to be aware of the top-level
crate name down to a much smaller area. This preps us for creating
bindings for multiple crates at once.

19 months agoUpdate auto-generated bindings to latest upstream 2021-04-bump-upstream
Matt Corallo [Tue, 13 Apr 2021 18:27:07 +0000 (14:27 -0400)]
Update auto-generated bindings to latest upstream

19 months agoUpdate demo to latest upstream bindings
Matt Corallo [Thu, 15 Apr 2021 17:17:30 +0000 (13:17 -0400)]
Update demo to latest upstream bindings

19 months agoSupport concretizing generics in template parameters
Matt Corallo [Thu, 15 Apr 2021 17:11:04 +0000 (13:11 -0400)]
Support concretizing generics in template parameters

19 months agoHandle type aliases which are used in the same file as declared.
Matt Corallo [Thu, 15 Apr 2021 17:10:22 +0000 (13:10 -0400)]
Handle type aliases which are used in the same file as declared.

We previously only handled type aliases correctly when they were
declared in a different file and imported.

19 months agoBump git hash to latest upstream
Matt Corallo [Tue, 13 Apr 2021 18:27:34 +0000 (14:27 -0400)]
Bump git hash to latest upstream

19 months agoMerge pull request #11 from TheBlueMatt/2021-04-upstream-bump
Matt Corallo [Tue, 13 Apr 2021 01:54:49 +0000 (01:54 +0000)]
Merge pull request #11 from TheBlueMatt/2021-04-upstream-bump

Bump Upstream and clean up supertrait handling

19 months agoUpdate auto-generated bindings with latest upstream + generator 2021-04-upstream-bump
Matt Corallo [Mon, 12 Apr 2021 21:37:37 +0000 (17:37 -0400)]
Update auto-generated bindings with latest upstream + generator

19 months agoUpdate secp patch git hash to new PR (rebased on upstream)
Matt Corallo [Mon, 12 Apr 2021 21:47:35 +0000 (17:47 -0400)]
Update secp patch git hash to new PR (rebased on upstream)

19 months agoBump upstream git hash
Matt Corallo [Mon, 12 Apr 2021 21:41:22 +0000 (17:41 -0400)]
Bump upstream git hash

19 months agoUpdate demo for new upstream changes
Matt Corallo [Fri, 26 Mar 2021 22:20:19 +0000 (18:20 -0400)]
Update demo for new upstream changes

19 months agoCreate a scoped ImportResolver of the trait defn when impl'ing a parent trait
Matt Corallo [Mon, 12 Apr 2021 21:11:59 +0000 (17:11 -0400)]
Create a scoped ImportResolver of the trait defn when impl'ing a parent trait

Astoundingly, this was actually pretty easy.

19 months agoMake GenericTypes stack pushes RAII, giving borrowck knowledge of diff ImportResolver...
Matt Corallo [Mon, 12 Apr 2021 21:10:17 +0000 (17:10 -0400)]
Make GenericTypes stack pushes RAII, giving borrowck knowledge of diff ImportResolver lifetimes

19 months agoKeep track of the full parsed library in CrateTypes
Matt Corallo [Mon, 12 Apr 2021 18:34:58 +0000 (14:34 -0400)]
Keep track of the full parsed library in CrateTypes

This also moves CrateTypes to interrior mutable, as we pass around
references to it, which are ultimately mutable, but only to add
information about generic mapped types the first time we use them.

19 months agoRemove now-unused manual gen which our own trait resolution can handle
Matt Corallo [Mon, 12 Apr 2021 02:19:47 +0000 (22:19 -0400)]
Remove now-unused manual gen which our own trait resolution can handle

Note macros were unnecessary when we started doing rustc desugar runs.

19 months agoPrint the correct object names whem processing supertrait methods
Matt Corallo [Mon, 12 Apr 2021 02:19:21 +0000 (22:19 -0400)]
Print the correct object names whem processing supertrait methods

19 months agoHandle traits which require Clone when their supertraits do not
Matt Corallo [Mon, 12 Apr 2021 02:14:26 +0000 (22:14 -0400)]
Handle traits which require Clone when their supertraits do not

We do this by adding a SuperTrait_clone method field in the Trait's
object, which we call when cloning the Trait.

19 months agoMerge pull request #10 from TheBlueMatt/2021-03-enable-wallclock
Matt Corallo [Wed, 31 Mar 2021 19:34:13 +0000 (19:34 +0000)]
Merge pull request #10 from TheBlueMatt/2021-03-enable-wallclock

Optionally enable allow_wallclock_use

19 months agoUpdate auto-generated bindings with allow_wallclock_use 2021-03-enable-wallclock
Matt Corallo [Wed, 31 Mar 2021 04:08:34 +0000 (00:08 -0400)]
Update auto-generated bindings with allow_wallclock_use

19 months agoOptionally enable allow_wallclock_use
Matt Corallo [Wed, 31 Mar 2021 04:08:22 +0000 (00:08 -0400)]
Optionally enable allow_wallclock_use

20 months agoMerge pull request #9 from TheBlueMatt/2021-03-missing-docs
Arik Sosman [Tue, 30 Mar 2021 09:00:52 +0000 (02:00 -0700)]
Merge pull request #9 from TheBlueMatt/2021-03-missing-docs

Add Missing Docs

20 months agoUpdate auto-generated C bindings with new documentation 2021-03-missing-docs
Matt Corallo [Mon, 29 Mar 2021 19:26:25 +0000 (15:26 -0400)]
Update auto-generated C bindings with new documentation

20 months agoMake c_types module pub as its contents are exposed to C
Matt Corallo [Mon, 29 Mar 2021 17:50:42 +0000 (13:50 -0400)]
Make c_types module pub as its contents are exposed to C

This makes our `[deny(missing_docs)]` annotation effective

20 months agoAdd missing documentation to c_types module contents
Matt Corallo [Mon, 29 Mar 2021 18:40:22 +0000 (14:40 -0400)]
Add missing documentation to c_types module contents

20 months agoMerge pull request #8 from TheBlueMatt/2021-03-option-primitive
Matt Corallo [Mon, 29 Mar 2021 20:28:30 +0000 (20:28 +0000)]
Merge pull request #8 from TheBlueMatt/2021-03-option-primitive

Support Option<Primitive> and Option<Tuple>

20 months agoUpdate auto-generated bindings with Option constructor utilities 2021-03-option-primitive
Matt Corallo [Mon, 29 Mar 2021 19:23:42 +0000 (15:23 -0400)]
Update auto-generated bindings with Option constructor utilities

20 months agoAdd constructor utilities for generated Option<> types
Matt Corallo [Mon, 29 Mar 2021 19:23:21 +0000 (15:23 -0400)]
Add constructor utilities for generated Option<> types

20 months agoUpdate auto-generated bindings with new Option<primitive> support
Matt Corallo [Sun, 28 Mar 2021 20:46:10 +0000 (16:46 -0400)]
Update auto-generated bindings with new Option<primitive> support

20 months agoSupport Option<primitive>
Matt Corallo [Mon, 29 Mar 2021 17:32:18 +0000 (13:32 -0400)]
Support Option<primitive>

20 months agoUpdate current git hash for upstream head
Matt Corallo [Mon, 29 Mar 2021 17:43:09 +0000 (13:43 -0400)]
Update current git hash for upstream head

20 months agoUpdate auto-generated bindings to current upstream
Matt Corallo [Mon, 29 Mar 2021 17:38:49 +0000 (13:38 -0400)]
Update auto-generated bindings to current upstream

20 months agoHandle Option<(..)> as a non-transparent container, unlike Option<..>
Matt Corallo [Mon, 29 Mar 2021 16:43:00 +0000 (12:43 -0400)]
Handle Option<(..)> as a non-transparent container, unlike Option<..>