rust-bitcoin-unsafe-fast/bitcoin/embedded
Matt Corallo 27c7c4e26a Add a `bitcoin_io` crate
In order to support standard (de)serialization of structs, the
`rust-bitcoin` ecosystem uses the standard `std::io::{Read,Write}`
traits. This works great for environments with `std`, however sadly
the `std::io` module has not yet been added to the `core` crate.

Thus, in `no-std`, the `rust-bitcoin` ecosystem has historically
used the `core2` crate to provide copies of the `std::io` module
without any major dependencies. Sadly, its one dependency,
`memchr`, recently broke our MSRV.

Worse, because we didn't want to take on any excess dependencies
for `std` builds, `rust-bitcoin` has had to have
mutually-exclusive `std` and `no-std` builds. This breaks general
assumptions about how features work in Rust, causing substantial
pain for applications far downstream of `rust-bitcoin` crates.

Here, we add a new `bitcoin_io` crate, making it an unconditional
dependency and using its `io` module in the in-repository crates
in place of `std::io` and `core2::io`. As it is not substantial
additional code, the `hashes` io implementations are no longer
feature-gated.

This doesn't actually accomplish anything on its own, only adding
the new crate which still depends on `core2`.
2023-11-07 05:50:42 +00:00
..
scripts Import bitcoin_hashes crate into hashes 2022-11-08 08:58:09 +11:00
src embedded: Remove error handler 2023-04-26 14:29:39 +10:00
Cargo.toml Add a `bitcoin_io` crate 2023-11-07 05:50:42 +00:00
README.md embedded: Document how to clean up linker flags 2023-05-26 14:39:14 +10:00
memory.x Import bitcoin_hashes crate into hashes 2022-11-08 08:58:09 +11:00

README.md

Running

To run the embedded test, first prepare your environment:

sudo ./scripts/install-deps
rustup +nightly target add thumbv7m-none-eabi

Then:

source ./scripts/env.sh && cargo +nightly run --target thumbv7m-none-eabi

Output should be something like:

heap size 524288
secp buf size 66240
Seed WIF: L1HKVVLHXiUhecWnwFYF6L3shkf1E12HUmuZTESvBXUdx3yqVP1D
Address: bc1qpx9t9pzzl4qsydmhyt6ctrxxjd4ep549np9993

Note that this heap size is required because of the amount of stack used by libsecp256k1 when initializing a context.

Cleanup

After sourcing scripts/env.sh and before building again using another target you'll want to unset RUSTFLAGS otherwise you'll get linker errors.

unset RUSTFLAGS