Commit graph

48 commits

Author SHA1 Message Date
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
Matt Corallo
d5912ec75f
Merge pull request #633 from ariard/2020-05-rename-keys-var
Rename a's keys as local's keys and b's keys as remote's keys
2020-09-14 12:49:56 -07:00
Antoine Riard
21d0a955ef Cleanup locally-selected-delay
Comment meaning of holder/counterparty

Diverse chan_utils cleanups

Cleanups post-cbindings merge

Fix misusage of holder_selected_contest_delay instead of counterparty
_selected_contest_delay in HolderCommitmentTransaction

Fix old payment_point comment
2020-09-14 15:19:06 -04:00
Antoine Riard
6133498ca1 Overhaul LocalCommitmentTx to new nomenclature 2020-09-14 14:39:47 -04:00
Antoine Riard
00d063df5c Overhaul ChannelMonitor/OnchainTxHandler to new nomenclature 2020-09-14 14:39:47 -04:00
Antoine Riard
9a23130db9 Change ChannelKeys interface nomenclature to holder/counterparty one
Transaction signing methods are changed from local_/remote_ prefix
to newer holder_/counterparty_ wihout any semantic changes.
2020-09-14 14:39:47 -04:00
Antoine Riard
b51721fc8a Underscore TxCreationKeys ownership
A TxCreationKeys set represents the key which will be embedded in output
scripts of a party's commitment tx state. Among them there is a always
a key belonging to counter-party, the HTLC pubkey. To dissociate
strongly, prefix keys with broadcaster/countersignatory.

A revocation keypair is attributed to the broadcaster as it's used
to punish a fraudulent broadcast while minding that such keypair
derivation method will be always used by countersignatory as it's
its task to enforce punishement thanks to the release secret.
2020-09-14 14:39:47 -04:00
Antoine Riard
c6a91f2ebd Change variable nomenclature for to_self_delay
To avoid reviewers confusion, rename counterparty_to_self_delay
to counteparty_selected_contest_delay, i.e the justice delay announced
by a channel counterparty restraining our transactions, and to_self_delay
to locally_selected_contest_delay, i.e the justice delay announced by us
restraining counterparty's transactions

We deviate from wider nomenclature by prefixing local data with a
locally_ extension due to the leak of this value in transactions/scripts
builder, where the confusion may happen.

Rename further AcceptChannelData to the new nomenclature.
2020-09-14 14:39:44 -04:00
Matt Corallo
dce831ed20 Rename lightning C/C++ bindings library to libldk
This should fix #689.
2020-09-13 20:58:50 -04:00
Matt Corallo
53182a8cec Note that genbindings.sh is really also a test script. 2020-09-13 20:58:50 -04:00
Matt Corallo
dbf4f58987 Remove the bindings crate from the root namespace to let it break
Until we get the bindings generation process super stable, let the
bindings get stale with respect to the main repo while still letting
`cargo check` pass.
2020-09-13 20:58:50 -04:00
Antoine Riard
1d7c4f663c Change variable nomenclature in chan_utils
Variables should be named according to the script semantic which is
an invariant with regards to generating a local or remote commitment
transaction.

I.e a broadcaster_htlc_key will always guard a HTLC to the party able
to broadcast the computed transactions whereas countersignatory_htlc_key
will guard HTLC to a countersignatory of the commitment transaction.
2020-09-11 09:50:18 -04:00
Matt Corallo
4f6f34fa30 Add bindings README 2020-09-10 22:03:32 -04:00
Matt Corallo
96b2927a9a Add automatically generated C/C++ wrapper bindings 2020-09-10 22:03:32 -04:00
Matt Corallo
1af8a464b4 Add all the manually-generated bits for the c-bindings crate
Including:
 * A script to automatically generate all the rest,
 * Cargo.toml and cbindgen.toml,
 * manually-written wrapper types for a few types
2020-09-10 22:03:32 -04:00