Commit graph

64 commits

Author SHA1 Message Date
Matt Corallo
578f8b72e2 Change ChannelManager::wait to be more descriptive
`wait` doesn't capture enough of what's going on, but also Java
Java doesn't accpet methods just called `wait`, as it conflicts
with existing sync primitives on all Objects.
2021-03-07 13:06:07 -05:00
Matt Corallo
6742343319 [bindings] Support converting Network to rust, update variants 2021-03-05 19:16:29 -05:00
Matt Corallo
f2e4f8a229 [bindings] Build a wasm32-wasi library in genbindings.sh
This will switch to use the clang/C WASM ABI instead of the
wasm_bindgen WASM ABI as of rustc 1.51 (or nightly since [1]),
allowing us to link C and Rust code in a single wasm binary.

[1] https://github.com/rust-lang/rust/pull/79998
2021-03-01 18:07:29 -05:00
Matt Corallo
808db58578 Update auto-generated bindings 2021-02-28 19:44:45 -05:00
Matt Corallo
cd0b212e4d [bindings] Use global context for secp256k1
Note that this uses https://github.com/rust-bitcoin/rust-secp256k1/pull/279
2021-02-28 19:44:45 -05:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05:00
Matt Corallo
c2297353b5 Update auto-generated bindings 2021-02-22 11:48:24 -05:00
Matt Corallo
fc416d6295 Update C++ bindings demo with new struct naming 2021-02-20 10:06:22 -05:00
Matt Corallo
aa3f84123d Update auto-generated bindings 2021-02-20 10:06:22 -05:00
Matt Corallo
68811da302 Update C bindings demos for new KeysManager API 2021-02-19 14:02:46 -05:00
Matt Corallo
5f0977260e - bindings updates 2021-02-19 14:02:46 -05:00
Matt Corallo
02c21842fd - bindings updates 2021-02-19 14:01:10 -05:00
Matt Corallo
954e66ed08 Update auto-generated bindings 2021-02-18 12:31:29 -05:00
Matt Corallo
0dcc937bf1 Update demo C++ bindings example for new bindings 2021-02-18 12:28:25 -05:00
Matt Corallo
06342a30b1 Adapt C++ bindings demo to new API and keys (new funding tx) 2021-02-12 18:59:01 -05:00
Matt Corallo
e9d819dce8 Update auto-generated bindings 2021-02-12 18:58:59 -05:00
Matt Corallo
c2fd68377c Update auto-generated bindings 2021-02-10 22:38:51 -05:00
Matt Corallo
ac70f278cb [C++ bindings] Update demo app due to removed TupleTempl generics 2021-02-10 22:25:10 -05:00
Matt Corallo
faad5124cf [bindings] Move to manual write-out for Tuples, too 2021-02-10 22:25:10 -05:00
Matt Corallo
7dd9d6f40c [bindings] Move to manual write-out for Vec, too 2021-02-10 22:25:10 -05:00
Matt Corallo
c5c2d464ba [bindings] Concretize Result types without type aliasing
While the type aliasing trick works great for cbindgen,
wasm_bindgen doesn't support it and requires fully-concrete types.
In order to better support wasm_bindgen in the future, we do so
here, adding a function which manually writes out almost the exact
thing which was templated previously in concrete form.

As a nice side-effect, we no longer have to allocate and free a u8
for generic parameters which were `()` (though we still do in some
conversion functions, which we can get rid of when we similarly
concretize all generics fully).
2021-02-10 22:24:16 -05:00
Matt Corallo
ee07a73b82 [bindings] Add additional clone methods on manually-defined types 2021-02-10 22:24:16 -05:00
Matt Corallo
3efd641ca4 Update C++ bindings demo to use ChannelManager de/serialization
This demonstrates (and tests) the newly-exposed `ChannelManager`
de/serialization functions. Best revewied with -b --color-moved.
2021-02-03 10:11:35 -05:00
Matt Corallo
78bc724091 [C++ bindings demo] Add now-missing std::moves 2021-02-03 10:11:35 -05:00
Matt Corallo
64aa8baf98 Auto-generated bindings updates 2021-02-03 10:11:35 -05:00
Matt Corallo
53f2e25a96 [bindings] Use new non-null annotation feature in cbindgen
This adds a new annotation for objects we take by reference in the
C header indicating the pointers must not be null. We have to
disable some warning clang now dumps that we haven't annotated all
pointers, as cbindgen is not yet able to add a nullable annotation.
2021-02-03 10:11:28 -05:00
Matt Corallo
56134a2bd1 [bindings] Implement ReadableArgs mapping, try impl mapping for ()s
This is most of the code to expose `ChannelManager`/`ChannelMonitor`
deserialization in our C bindings, using the new infrastructure to
map types in `maybe_convert_trait_impl` and passing generics in
from the callsites.

We also call `maybe_convert_trait_impl` for tuple types, as the
`ChannelManager`/`ChannelMonitor` deserialization returns a
`(BlockHash, T)` to indicate the block hash at which users need to
start resyncing the chain.

The final step to expose them is in the next commit.
2021-02-03 10:11:28 -05:00
Matt Corallo
93e562f5bf [bindings] Update C++ demo for new NetGraphMsgHandler::new() params 2021-02-02 17:04:31 -05:00
Matt Corallo
30a42f4597 Update auto-generated bindings, including bumping cbindgen version 2021-02-02 17:04:31 -05:00
Matt Corallo
b243c65acc [bindings] Allow unused fns that the bindings can call but don't
We no longer have any public `Option<Signatures>` in our code, and
thus get warnings that the two functions which support it are
unused. Instead of removing support for them (which we may need in
the future), we add `#[allow(unused)]`.
2021-02-02 17:04:31 -05:00
Matt Corallo
78c2c48ea3 [bindings] Support exposing bitcoin::OutPoints as our common type 2021-02-02 17:04:31 -05:00
Matt Corallo
773c2d1dc3
Merge pull request #759 from TheBlueMatt/2020-11-0.0.12
Bump version to 0.0.12
2020-11-24 14:14:16 -08:00
Matt Corallo
ccd4a7acaa Update auto-generated bindings with new NetworkGraph API 2020-11-24 16:45:36 -05:00
Matt Corallo
4aa8e9cda7 Bump version to 0.0.12 2020-11-24 16:35:20 -05:00
Matt Corallo
722a366fe2 Update auto-generated bindings 2020-11-23 11:12:49 -05:00
Matt Corallo
66f46d4ad3 Update bindings demo for new ChannelMonitor-update API 2020-11-23 11:12:37 -05:00
Matt Corallo
d169966f76 [bindings] Update eq/clone trait fns to take object, not this_arg
When a trait is required to implement eq/clone (eg in the case of
`SocketDescriptor`), the generated trait struct contains an
eq/clone function which takes a `this_arg` pointer. Since the trait
object can always be read to get the `this_arg` pointer, there is
no loss of generality to pass the trait object itself, and it
provides a bit more flexibility when the trait could be one of
several implementations (which we use in the Java higher-level
bindings).
2020-11-23 11:08:34 -05:00
Matt Corallo
faa8ec5c21 [bindings] Fix CVecTempl clone operation behavior.
CVecTempl previously called Vec.clone_from_slice() on a
newly-allocated Vec, which immediately panics as
[T].clone_from_slice() requires that the Vec/target slice already
has the same length as the source slice. This should have been
Vec.extend_from_slice() which exhibits the correct behavior.
2020-11-23 11:08:34 -05:00
Matt Corallo
336cb0828a Update bindings demo for new Transaction::data mut-ness 2020-11-23 11:08:34 -05:00
Matt Corallo
78b4598ff6 [bindings] Make Transaction::data *mut instead of *const
When the only reference to the transaction bytes is via
Transaction::data, my understanding of the C const rules is that
it would then be invalid to write to it. While its unlikely this
would ever pose an issue, its not hard to simply make it *mut, so
we do that here.
2020-11-23 11:08:34 -05:00
Matt Corallo
90b668e426 Update bindings demo for changes from #681 and the Persister trait 2020-11-23 11:08:34 -05:00
Matt Corallo
5988789a2d [bindings] update generated code 2020-10-21 14:54:51 -04:00
Matt Corallo
7e18104414 Update demo.cpp for new tuple code 2020-10-21 14:54:51 -04:00
Matt Corallo
2d0cdbd33e [bindings] Un-Box Tuple mapping
Because the C++ wrappers require being able to memset(0) the C
structs to skip free(), we'd previously mapped tuples with two
pointer indirections. However, because all other types already
support memset(0)'ing to disable free() logic, we can skip the
pointer indirections and the behavior is still correct.
2020-10-21 14:54:51 -04:00
Matt Corallo
d773151e7f Update bindings to latest upstream code 2020-10-21 14:54:51 -04:00
Matt Corallo
353e29aedd Drop the now-unused usizeslice bindings struct 2020-10-21 14:50:22 -04:00
Matt Corallo
a5e7671d1e Update bindings demo apps for new code upstream 2020-10-21 14:50:22 -04:00
Matt Corallo
d9a38d1846 [bindings] Give Transaction objects a buffer-is-owned flag.
A lot of our container mapping depends on the `is_owned` flag
which we have for in-crate mapped objects to map references and
non-references into the same container type. Transaction was
mapped to two completely different types (a slice and a Vec type),
which led to a number of edge cases in the bindings generation.
Specifically, I spent a few days trying to map
`[(A, &Transaction)]` properly and came up empty - we map slices
into the same types as Vecs (and rely on the `is_owned` flag to
avoid double-free) and the lack of one for `Transaction` would have
required a special-case in numerous functions.

Instead, we just add a flag in `Transaction` to mirror what we do
for in-crate types and check it before free-ing any underlying
memory.

Note that, sadly, because the c_types objects aren't mapped as a
part of our C++ bindings generation, you have to manually call
`Transaction_free()` even in C++.
2020-10-21 14:50:22 -04:00
Matt Corallo
8b8a97c6aa Add README note about key validity assertions at the FFI boundary 2020-10-12 12:17:26 -04:00
Matt Corallo
49e0a8ce7b Update bindings after merge of #633, #679, #683. 2020-09-16 11:12:51 -04:00