Hard code genesis script bytes instead of hex
Currently we have a dependency on `hex_lit` and it is used in exactly one place outside of test code, if we instead use a hardcoded array instead we can move the `hex_lit` dependency to `dev-dependencies`. Hard code the genesis block script bytes as an array of hex digits, link to the blockstream explorer for those interested and comment the bytes liberally since it took me a while to work out what they were. Move the `hex_lit` dependency and update the lock files.
This commit is contained in:
parent
6e5592db77
commit
726ff25c46
|
@ -47,7 +47,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin"
|
name = "bitcoin"
|
||||||
version = "0.33.0-unreleased"
|
version = "0.32.0-rc1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base58ck",
|
"base58ck",
|
||||||
"base64",
|
"base64",
|
||||||
|
|
|
@ -46,7 +46,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin"
|
name = "bitcoin"
|
||||||
version = "0.33.0-unreleased"
|
version = "0.32.0-rc1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base58ck",
|
"base58ck",
|
||||||
"base64",
|
"base64",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bitcoin"
|
name = "bitcoin"
|
||||||
version = "0.33.0-unreleased"
|
version = "0.32.0-rc1"
|
||||||
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
|
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
|
||||||
license = "CC0-1.0"
|
license = "CC0-1.0"
|
||||||
repository = "https://github.com/rust-bitcoin/rust-bitcoin/"
|
repository = "https://github.com/rust-bitcoin/rust-bitcoin/"
|
||||||
|
@ -32,7 +32,6 @@ base58 = { package = "base58ck", version = "0.1.0", default-features = false }
|
||||||
bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] }
|
bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] }
|
||||||
hashes = { package = "bitcoin_hashes", version = "0.14.0", default-features = false, features = ["alloc", "io"] }
|
hashes = { package = "bitcoin_hashes", version = "0.14.0", default-features = false, features = ["alloc", "io"] }
|
||||||
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"] }
|
||||||
hex_lit = "0.1.1"
|
|
||||||
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"] }
|
||||||
secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] }
|
secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] }
|
||||||
|
@ -50,6 +49,7 @@ actual-serde = { package = "serde", version = "1.0.103", default-features = fals
|
||||||
serde_json = "1.0.0"
|
serde_json = "1.0.0"
|
||||||
serde_test = "1.0.19"
|
serde_test = "1.0.19"
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
|
hex_lit = "0.1.1"
|
||||||
|
|
||||||
[target.'cfg(mutate)'.dev-dependencies]
|
[target.'cfg(mutate)'.dev-dependencies]
|
||||||
mutagen = { git = "https://github.com/llogiq/mutagen" }
|
mutagen = { git = "https://github.com/llogiq/mutagen" }
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
//! single transaction.
|
//! single transaction.
|
||||||
|
|
||||||
use hashes::{sha256d, Hash};
|
use hashes::{sha256d, Hash};
|
||||||
use hex_lit::hex;
|
|
||||||
use internals::impl_array_newtype;
|
use internals::impl_array_newtype;
|
||||||
|
|
||||||
use crate::blockdata::block::{self, Block};
|
use crate::blockdata::block::{self, Block};
|
||||||
|
@ -50,6 +49,23 @@ pub const MAX_SCRIPTNUM_VALUE: u32 = 0x80000000; // 2^31
|
||||||
/// Number of blocks needed for an output from a coinbase transaction to be spendable.
|
/// Number of blocks needed for an output from a coinbase transaction to be spendable.
|
||||||
pub const COINBASE_MATURITY: u32 = 100;
|
pub const COINBASE_MATURITY: u32 = 100;
|
||||||
|
|
||||||
|
// This is the 65 byte (uncompressed) pubkey used as the one-and-only output of the genesis transaction.
|
||||||
|
//
|
||||||
|
// ref: https://blockstream.info/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b?expand
|
||||||
|
// Note output script includes a leading 0x41 and trailing 0xac (added below using the `script::Builder`).
|
||||||
|
#[rustfmt::skip]
|
||||||
|
const GENESIS_OUTPUT_PK: [u8; 65] = [
|
||||||
|
0x04,
|
||||||
|
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27,
|
||||||
|
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10,
|
||||||
|
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6,
|
||||||
|
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6,
|
||||||
|
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4,
|
||||||
|
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde,
|
||||||
|
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57,
|
||||||
|
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f
|
||||||
|
];
|
||||||
|
|
||||||
/// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block.
|
/// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block.
|
||||||
fn bitcoin_genesis_tx() -> Transaction {
|
fn bitcoin_genesis_tx() -> Transaction {
|
||||||
// Base
|
// Base
|
||||||
|
@ -74,9 +90,8 @@ fn bitcoin_genesis_tx() -> Transaction {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Outputs
|
// Outputs
|
||||||
let script_bytes = hex!("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f");
|
|
||||||
let out_script =
|
let out_script =
|
||||||
script::Builder::new().push_slice(script_bytes).push_opcode(OP_CHECKSIG).into_script();
|
script::Builder::new().push_slice(GENESIS_OUTPUT_PK).push_opcode(OP_CHECKSIG).into_script();
|
||||||
ret.output.push(TxOut { value: Amount::from_sat(50 * 100_000_000), script_pubkey: out_script });
|
ret.output.push(TxOut { value: Amount::from_sat(50 * 100_000_000), script_pubkey: out_script });
|
||||||
|
|
||||||
// end
|
// end
|
||||||
|
|
Loading…
Reference in New Issue