Move opcodes to primitives
Move the `opcodes` module to the new `primitives` crate. This is pretty straight forward, some things to note: - Are we ok with the public wildcard re-export from `blockdata`? I think so because the whole `blockdata` module should, IMO, be deleted after everything in it is moved to `primitives`. - `decode_pushnum` becomes public. Includes addition of a `patch` section for `primitives` in the `bitcoin/embedded` crate.
This commit is contained in:
parent
b9f1dba3f7
commit
9a586987d1
|
@ -55,6 +55,7 @@ dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"bitcoin-internals",
|
"bitcoin-internals",
|
||||||
"bitcoin-io",
|
"bitcoin-io",
|
||||||
|
"bitcoin-primitives",
|
||||||
"bitcoin-units",
|
"bitcoin-units",
|
||||||
"bitcoin_hashes",
|
"bitcoin_hashes",
|
||||||
"bitcoinconsensus",
|
"bitcoinconsensus",
|
||||||
|
@ -98,6 +99,10 @@ version = "0.1.2"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin-primitives"
|
name = "bitcoin-primitives"
|
||||||
version = "0.100.0"
|
version = "0.100.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitcoin-internals",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin-units"
|
name = "bitcoin-units"
|
||||||
|
|
|
@ -54,6 +54,7 @@ dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"bitcoin-internals",
|
"bitcoin-internals",
|
||||||
"bitcoin-io",
|
"bitcoin-io",
|
||||||
|
"bitcoin-primitives",
|
||||||
"bitcoin-units",
|
"bitcoin-units",
|
||||||
"bitcoin_hashes",
|
"bitcoin_hashes",
|
||||||
"bitcoinconsensus",
|
"bitcoinconsensus",
|
||||||
|
@ -97,6 +98,10 @@ version = "0.1.2"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin-primitives"
|
name = "bitcoin-primitives"
|
||||||
version = "0.100.0"
|
version = "0.100.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitcoin-internals",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin-units"
|
name = "bitcoin-units"
|
||||||
|
|
|
@ -16,10 +16,10 @@ exclude = ["tests", "contrib"]
|
||||||
# If you change features or optional dependencies in any way please update the "# Cargo features" section in lib.rs as well.
|
# If you change features or optional dependencies in any way please update the "# Cargo features" section in lib.rs as well.
|
||||||
[features]
|
[features]
|
||||||
default = [ "std", "secp-recovery" ]
|
default = [ "std", "secp-recovery" ]
|
||||||
std = ["base58/std", "bech32/std", "hashes/std", "hex/std", "internals/std", "io/std", "secp256k1/std", "units/std"]
|
std = ["base58/std", "bech32/std", "hashes/std", "hex/std", "internals/std", "io/std", "primitives/std", "secp256k1/std", "units/std"]
|
||||||
rand-std = ["secp256k1/rand-std", "std"]
|
rand-std = ["secp256k1/rand-std", "std"]
|
||||||
rand = ["secp256k1/rand"]
|
rand = ["secp256k1/rand"]
|
||||||
serde = ["actual-serde", "hashes/serde", "internals/serde", "secp256k1/serde", "units/serde"]
|
serde = ["actual-serde", "hashes/serde", "internals/serde", "primitives/serde", "secp256k1/serde", "units/serde"]
|
||||||
secp-lowmemory = ["secp256k1/lowmemory"]
|
secp-lowmemory = ["secp256k1/lowmemory"]
|
||||||
secp-recovery = ["secp256k1/recovery"]
|
secp-recovery = ["secp256k1/recovery"]
|
||||||
bitcoinconsensus-std = ["bitcoinconsensus/std", "std"]
|
bitcoinconsensus-std = ["bitcoinconsensus/std", "std"]
|
||||||
|
@ -31,6 +31,7 @@ hashes = { package = "bitcoin_hashes", version = "0.14.0", default-features = fa
|
||||||
hex = { package = "hex-conservative", version = "0.2.0", default-features = false, features = ["alloc"] }
|
hex = { package = "hex-conservative", version = "0.2.0", default-features = false, features = ["alloc"] }
|
||||||
internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] }
|
internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] }
|
||||||
io = { package = "bitcoin-io", version = "0.1.1", default-features = false, features = ["alloc"] }
|
io = { package = "bitcoin-io", version = "0.1.1", default-features = false, features = ["alloc"] }
|
||||||
|
primitives = { package = "bitcoin-primitives", version = "0.100.0", default-features = false }
|
||||||
secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] }
|
secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] }
|
||||||
units = { package = "bitcoin-units", version = "0.1.0", default-features = false, features = ["alloc"] }
|
units = { package = "bitcoin-units", version = "0.1.0", default-features = false, features = ["alloc"] }
|
||||||
|
|
||||||
|
|
|
@ -39,5 +39,8 @@ path = "../../internals"
|
||||||
[patch.crates-io.bitcoin-io]
|
[patch.crates-io.bitcoin-io]
|
||||||
path = "../../io"
|
path = "../../io"
|
||||||
|
|
||||||
|
[patch.crates-io.bitcoin-primitives]
|
||||||
|
path = "../../primitives"
|
||||||
|
|
||||||
[patch.crates-io.bitcoin-units]
|
[patch.crates-io.bitcoin-units]
|
||||||
path = "../../units"
|
path = "../../units"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod locktime;
|
pub mod locktime;
|
||||||
pub mod opcodes;
|
|
||||||
pub mod script;
|
pub mod script;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
pub mod witness;
|
pub mod witness;
|
||||||
|
@ -48,6 +47,12 @@ pub mod fee_rate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bitcoin script opcodes.
|
||||||
|
pub mod opcodes {
|
||||||
|
/// Re-export everything from the [`primitives::opcodes`] module.
|
||||||
|
pub use primitives::opcodes::*;
|
||||||
|
}
|
||||||
|
|
||||||
/// Implements `Weight` and associated features.
|
/// Implements `Weight` and associated features.
|
||||||
pub mod weight {
|
pub mod weight {
|
||||||
/// Re-export everything from the [`units::weight`] module.
|
/// Re-export everything from the [`units::weight`] module.
|
||||||
|
|
|
@ -16,9 +16,14 @@ exclude = ["tests", "contrib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = []
|
std = ["internals/std"]
|
||||||
|
serde = ["actual-serde", "internals/serde"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] }
|
||||||
|
|
||||||
|
# Do NOT use this as a feature! Use the `serde` feature instead.
|
||||||
|
actual-serde = { package = "serde", version = "1.0.103", default-features = false, features = [ "alloc" ], optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,18 @@ extern crate alloc;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
extern crate actual_serde as serde;
|
||||||
|
|
||||||
|
pub mod opcodes;
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
mod prelude {
|
||||||
|
#[cfg(all(not(feature = "std"), not(test)))]
|
||||||
|
pub use alloc::string::ToString;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "std", test))]
|
||||||
|
pub use std::string::ToString;
|
||||||
|
}
|
||||||
|
|
|
@ -424,7 +424,7 @@ impl Opcode {
|
||||||
///
|
///
|
||||||
/// Returns `None` if `self` is not a PUSHNUM.
|
/// Returns `None` if `self` is not a PUSHNUM.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) const fn decode_pushnum(self) -> Option<u8> {
|
pub const fn decode_pushnum(self) -> Option<u8> {
|
||||||
const START: u8 = OP_PUSHNUM_1.code;
|
const START: u8 = OP_PUSHNUM_1.code;
|
||||||
const END: u8 = OP_PUSHNUM_16.code;
|
const END: u8 = OP_PUSHNUM_16.code;
|
||||||
match self.code {
|
match self.code {
|
Loading…
Reference in New Issue