]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Support building a cdylib and skip libbitcoinconsensus in wasm32 2020-04-wasm
authorMatt Corallo <git@bluematt.me>
Thu, 16 Apr 2020 21:04:42 +0000 (17:04 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 16 Apr 2020 21:49:37 +0000 (17:49 -0400)
This, combined with
https://github.com/rust-bitcoin/rust-secp256k1/pull/208 should get
us building in wasm again, hopefully without any future
complications due to WASM's lack of standard stdlibc.

lightning/Cargo.toml
lightning/src/ln/functional_test_utils.rs

index 341084fc393a7b0fc35822b1e67c0661f0ee42db..a2487e49b64cc39ae7b152253784ecad063e42cd 100644 (file)
@@ -10,6 +10,9 @@ Does most of the hard work, without implying a specific runtime, requiring clien
 Still missing tons of error-handling. See GitHub issues for suggested projects if you want to contribute. Don't have to bother telling you not to use this for anything serious, because you'd have to build a client around it to even try.
 """
 
+[lib]
+crate-type = ["cdylib", "rlib"]
+
 [features]
 # Supports tracking channels with a non-bitcoin chain hashes. Currently enables all kinds of fun DoS attacks.
 non_bitcoin_chain_hash_routing = []
@@ -26,7 +29,13 @@ bitcoin = "0.21"
 bitcoin_hashes = "0.7"
 secp256k1 = "0.15"
 
-[dev-dependencies.bitcoin]
+# Building libbitcoinconsensus in wasm32 requires a stdlibc, which is...complicated
+# Instead, just skip the script verification runs in wasm test runs.
+# Note that due to a long-standing bug only recently fixed in an RFC on nightly, this
+# workaround requires building with cargo nightly -Z features=itarget. See
+# tracking issue https://github.com/rust-lang/cargo/issues/7914 and
+# https://github.com/rust-lang/cargo/issues/1197.
+[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.bitcoin]
 version = "0.21"
 features = ["bitcoinconsensus"]
 
index 95358208e9de283f2b78837e74cd78875d773a8e..e6b99b7331a0bd2990d791cbae0c19ee4a8e7925 100644 (file)
@@ -467,6 +467,7 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a
 
 macro_rules! check_spends {
        ($tx: expr, $($spends_txn: expr),*) => {
+               #[cfg(not(target_arch = "wasm32"))]
                {
                        $tx.verify(|out_point| {
                                $(