-
Notifications
You must be signed in to change notification settings - Fork 825
Start crate smashing #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start crate smashing #751
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,3 @@ | ||
[package] | ||
name = "bitcoin" | ||
version = "0.27.0" | ||
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"] | ||
license = "CC0-1.0" | ||
homepage = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||
repository = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||
documentation = "https://docs.rs/bitcoin/" | ||
description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies." | ||
keywords = [ "crypto", "bitcoin" ] | ||
readme = "README.md" | ||
exclude = ["./test_data"] | ||
|
||
# Please don't forget to add relevant features to docs.rs below | ||
[features] | ||
default = [ "std", "secp-recovery" ] | ||
base64 = [ "base64-compat" ] | ||
unstable = [] | ||
rand = ["secp256k1/rand-std"] | ||
use-serde = ["serde", "bitcoin_hashes/serde", "secp256k1/serde"] | ||
secp-lowmemory = ["secp256k1/lowmemory"] | ||
secp-recovery = ["secp256k1/recovery"] | ||
|
||
# At least one of std, no-std must be enabled. | ||
# | ||
# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. | ||
# Instead no-std enables additional features required for this crate to be usable without std. | ||
# As a result, both can be enabled without conflict. | ||
std = ["secp256k1/std", "bitcoin_hashes/std", "bech32/std"] | ||
no-std = ["hashbrown", "core2/alloc", "bitcoin_hashes/alloc", "secp256k1/alloc"] | ||
|
||
[package.metadata.docs.rs] | ||
features = [ "std", "secp-recovery", "base64", "rand", "use-serde", "bitcoinconsensus" ] | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[dependencies] | ||
bech32 = { version = "0.8.1", default-features = false } | ||
bitcoin_hashes = { version = "0.10.0", default-features = false } | ||
secp256k1 = { version = "0.21.2", default-features = false } | ||
core2 = { version = "0.3.0", optional = true, default-features = false } | ||
|
||
base64-compat = { version = "1.0.0", optional = true } | ||
bitcoinconsensus = { version = "0.19.0-3", optional = true } | ||
serde = { version = "1", features = [ "derive" ], optional = true } | ||
hashbrown = { version = "0.8", optional = true } | ||
|
||
[dev-dependencies] | ||
serde_json = "<1.0.45" | ||
serde_test = "1" | ||
secp256k1 = { version = "0.21.2", features = [ "recovery", "rand-std" ] } | ||
bincode = "1.3.1" | ||
# We need to pin ryu (transitive dep from serde_json) to stay compatible with Rust 1.22.0 | ||
ryu = "<1.0.5" | ||
|
||
[[example]] | ||
name = "bip32" | ||
|
||
[[example]] | ||
name = "handshake" | ||
required-features = ["std"] | ||
[workspace] | ||
members = ["bitcoin", "bitcoin-str"] | ||
exclude = ["embedded", "fuzz"] | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||
[package] | ||||||
name = "bitcoin-str" | ||||||
version = "0.27.0" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"] | ||||||
license = "CC0-1.0" | ||||||
homepage = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||||||
repository = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||||||
documentation = "https://docs.rs/bitcoin/" | ||||||
description = "The string encodings used by rust-bitcoin (base58, base58check, bech32, bech32m, base64, hex)." | ||||||
keywords = [ "crypto", "bitcoin" ] | ||||||
readme = "https://github.com/rust-bitcoin/rust-bitcoin/README.md" | ||||||
|
||||||
# Please don't forget to add relevant features to docs.rs below | ||||||
[features] | ||||||
default = ["std"] | ||||||
unstable = [] | ||||||
base64 = ["base64-compat"] | ||||||
use-serde = ["serde", "bitcoin_hashes/serde"] | ||||||
|
||||||
# At least one of std, no-std must be enabled. | ||||||
# | ||||||
# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. | ||||||
# Instead no-std enables additional features required for this crate to be usable without std. | ||||||
# As a result, both can be enabled without conflict. | ||||||
std = ["bitcoin_hashes/std", "bech32/std"] | ||||||
no-std = ["core2/alloc", "bitcoin_hashes/alloc"] | ||||||
|
||||||
[package.metadata.docs.rs] | ||||||
features = [ "std", "secp-recovery", "base64", "rand", "use-serde", "bitcoinconsensus" ] | ||||||
rustdoc-args = ["--cfg", "docsrs"] | ||||||
|
||||||
[dependencies] | ||||||
bech32 = { version = "0.8.1", default-features = false } | ||||||
bitcoin_hashes = { version = "0.10.0", default-features = false } | ||||||
|
||||||
|
||||||
serde = { version = "1", features = [ "derive" ], optional = true } # Typically enabled with `use-serde`. | ||||||
base64-compat = { version = "1.0.0", optional = true } # Typically enabled with `base64`. | ||||||
core2 = { version = "0.3.0", default-features = false, optional = true } # Typically enabled with `no-std`. | ||||||
|
||||||
[dev-dependencies] | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Rust Bitcoin Library | ||
// Written in 2014 by | ||
// Andrew Poelstra <apoelstra@wpsoftware.net> | ||
// | ||
// To the extent possible un F438 der law, the author(s) have dedicated all | ||
// copyright and related and neighboring rights to this software to | ||
// the public domain worldwide. This software is distributed without | ||
// any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication | ||
// along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
// | ||
|
||
//! # Rust Bitcoin String Encoding/Decoding. | ||
//! | ||
//! This library provides encoding and decoding into/from various string formats used by Bitcoin. | ||
//! | ||
//! - base58 | ||
//! - bech32 | ||
//! - bech32m | ||
//! - hex | ||
//! - base64 (optional) | ||
//! | ||
|
||
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] | ||
|
||
// Experimental features we need | ||
#![cfg_attr(all(test, feature = "unstable"), feature(test))] | ||
|
||
#![cfg_attr(docsrs, feature(doc_cfg))] | ||
|
||
// Coding conventions | ||
#![forbid(unsafe_code)] | ||
#![deny(non_upper_case_globals)] | ||
#![deny(non_camel_case_types)] | ||
#![deny(non_snake_case)] | ||
#![deny(unused_mut)] | ||
#![deny(dead_code)] | ||
#![deny(unused_imports)] | ||
#![deny(missing_docs)] | ||
#![deny(unused_must_use)] | ||
#![deny(broken_intra_doc_links)] | ||
|
||
#[cfg(not(any(feature = "std", feature = "no-std")))] | ||
compile_error!("at least one of the `std` or `no-std` features must be enabled"); | ||
|
||
// Disable 16-bit support at least for now as we can't guarantee it yet. | ||
#[cfg(target_pointer_width = "16")] | ||
compile_error!("rust-bitcoin currently only supports architectures with pointers wider | ||
than 16 bits, let us know if you want 16-bit support. Note that we do | ||
NOT guarantee that we will implement it!"); | ||
|
||
#[cfg(feature = "no-std")] | ||
#[macro_use] | ||
extern crate alloc; | ||
#[cfg(feature = "no-std")] | ||
extern crate core2; | ||
|
||
#[cfg(any(feature = "std", test))] | ||
extern crate core; // for Rust 1.29 and no-std tests | ||
|
||
// Re-exported dependencies. | ||
pub extern crate bech32; | ||
pub extern crate bitcoin_hashes as hashes; | ||
|
||
#[cfg(feature = "base64")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))] | ||
pub extern crate base64; | ||
|
||
pub mod base58; | ||
pub mod endian; | ||
|
||
pub mod hex { | ||
//! Re-exports hex de/serialization code from `bitcoin_hashes`. | ||
//! | ||
// There is a chicken and the egg problem with putting _all_ the en/decoding code in a single crate. | ||
// Hashing cannot be separated totally from en/decoding because base58 -> hashing -> hex. | ||
|
||
pub use hashes::hex::{Error, ToHex, FromHex, HexIterator, format_hex, format_hex_reverse}; | ||
// TODO: This doesn't work with Rust 1.29 (same problem trying to use macros from hashes in ../bitcoin) | ||
pub use hashes::hex_fmt_impl; | ||
} | ||
|
||
mod prelude { | ||
#[cfg(all(not(feature = "std"), not(test)))] | ||
pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Cow, ToOwned}, slice, rc, sync}; | ||
|
||
#[cfg(any(feature = "std", test))] | ||
pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Cow, ToOwned}, slice, rc, sync}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
[package] | ||
name = "bitcoin" | ||
version = "0.27.0" | ||
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"] | ||
license = "CC0-1.0" | ||
homepage = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||
repository = "https://github.com/rust-bitcoin/rust-bitcoin/" | ||
documentation = "https://docs.rs/bitcoin/" | ||
description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies." | ||
keywords = [ "crypto", "bitcoin" ] | ||
readme = "https://github.com/rust-bitcoin/rust-bitcoin/README.md" | ||
exclude = ["./test_data"] | ||
|
||
# Please don't forget to add relevant features to docs.rs below | ||
[features] | ||
default = [ "std", "secp-recovery" ] | ||
base64 = [ "bitcoin-str/base64" ] | ||
unstable = [] | ||
rand = ["secp256k1/rand-std"] | ||
use-serde = ["serde", "secp256k1/serde"] | ||
secp-lowmemory = ["secp256k1/lowmemory"] | ||
secp-recovery = ["secp256k1/recovery"] | ||
|
||
# At least one of std, no-std must be enabled. | ||
# | ||
# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. | ||
# Instead no-std enables additional features required for this crate to be usable without std. | ||
# As a result, both can be enabled without conflict. | ||
std = ["bitcoin-str/std", "secp256k1/std"] | ||
no-std = ["bitcoin-str/no-std", "hashbrown", "core2/alloc", "secp256k1/alloc"] | ||
|
||
[package.metadata.docs.rs] | ||
features = [ "std", "secp-recovery", "base64", "rand", "use-serde", "bitcoinconsensus" ] | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[dependencies] | ||
bitcoin-str = { path = "../bitcoin-str", default-features = false } | ||
|
||
secp256k1 = { version = "0.21.2", default-features = false } | ||
core2 = { version = "0.3.0", optional = true, default-features = false } | ||
|
||
bitcoinconsensus = { version = "0.19.0-3", optional = true } | ||
serde = { version = "1", features = [ "derive" ], optional = true } | ||
hashbrown = { version = "0.8", optional = true } | ||
|
||
[dev-dependencies] | ||
serde_json = "<1.0.45" | ||
serde_test = "1" | ||
secp256k1 = { version = "0.21.2", features = [ "recovery", "rand-std" ] } | ||
bincode = "1.3.1" | ||
# We need to pin ryu (transitive dep from serde_json) to stay compatible with Rust 1.22.0 | ||
ryu = "<1.0.5" | ||
|
||
[[example]] | ||
name = "bip32" | ||
|
||
[[example]] | ||
name = "handshake" | ||
required-features = ["std"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can reduce the diff here by not moving the main crate into a subdirectory.
Regular crate manifests can also have a
[workspace]
table, meaning you can introducebitcoin-str
and move all the stuff in without touching anything inbitcoin
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, I did not know that. Cheers man!