Skip to content

Commit

Permalink
updated params for doge
Browse files Browse the repository at this point in the history
  • Loading branch information
cf committed Jun 26, 2024
1 parent acd2c47 commit fed500c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 41 deletions.
4 changes: 2 additions & 2 deletions bitcoin/src/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use crate::network::Network;
use crate::prelude::*;

/// Version bytes for extended public keys on the Bitcoin network.
const VERSION_BYTES_MAINNET_PUBLIC: [u8; 4] = [0x04, 0x88, 0xB2, 0x1E];
const VERSION_BYTES_MAINNET_PUBLIC: [u8; 4] = [0x02, 0xfa, 0xca, 0xfd];
/// Version bytes for extended private keys on the Bitcoin network.
const VERSION_BYTES_MAINNET_PRIVATE: [u8; 4] = [0x04, 0x88, 0xAD, 0xE4];
const VERSION_BYTES_MAINNET_PRIVATE: [u8; 4] = [0x02, 0xfa, 0xc3, 0x98];
/// Version bytes for extended public keys on any of the testnet networks.
const VERSION_BYTES_TESTNETS_PUBLIC: [u8; 4] = [0x04, 0x35, 0x87, 0xCF];
/// Version bytes for extended private keys on any of the testnet networks.
Expand Down
27 changes: 12 additions & 15 deletions bitcoin/src/blockdata/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ pub const WITNESS_SCALE_FACTOR: usize = 4;
/// The maximum allowed number of signature check operations in a block.
pub const MAX_BLOCK_SIGOPS_COST: i64 = 80_000;
/// Mainnet (bitcoin) pubkey address prefix.
pub const PUBKEY_ADDRESS_PREFIX_MAIN: u8 = 0; // 0x00
pub const PUBKEY_ADDRESS_PREFIX_MAIN: u8 = 30;
/// Mainnet (bitcoin) script address prefix.
pub const SCRIPT_ADDRESS_PREFIX_MAIN: u8 = 5; // 0x05
pub const SCRIPT_ADDRESS_PREFIX_MAIN: u8 = 22;
/// Test (tesnet, signet, regtest) pubkey address prefix.
pub const PUBKEY_ADDRESS_PREFIX_TEST: u8 = 111; // 0x6f
pub const PUBKEY_ADDRESS_PREFIX_TEST: u8 = 113; // 0x71
/// Test (tesnet, signet, regtest) script address prefix.
pub const SCRIPT_ADDRESS_PREFIX_TEST: u8 = 196; // 0xc4
/// The maximum allowed script size.
Expand Down Expand Up @@ -96,17 +96,17 @@ fn bitcoin_genesis_tx() -> Transaction {
/// Constructs and returns the genesis block.
pub fn genesis_block(network: Network) -> Block {
let txdata = vec![bitcoin_genesis_tx()];
let hash: sha256d::Hash = txdata[0].txid().into();
let hash: sha256d::Hash = sha256d::Hash(hex!("696ad20e2dd4365c7459b4a4a5af743d5e92c6da3229e6532cd605f6533f2a5b"));
let merkle_root = hash.into();
match network {
Network::Bitcoin => Block {
header: block::Header {
version: block::Version::ONE,
prev_blockhash: Hash::all_zeros(),
merkle_root,
time: 1231006505,
bits: CompactTarget::from_consensus(0x1d00ffff),
nonce: 2083236893,
time: 1386325540,
bits: CompactTarget::from_consensus(0x1e0ffff0),
nonce: 99943,
},
txdata,
},
Expand All @@ -116,8 +116,8 @@ pub fn genesis_block(network: Network) -> Block {
prev_blockhash: Hash::all_zeros(),
merkle_root,
time: 1296688602,
bits: CompactTarget::from_consensus(0x1d00ffff),
nonce: 414098458,
bits: CompactTarget::from_consensus(0x1e0ffff0),
nonce: 997879,
},
txdata,
},
Expand Down Expand Up @@ -156,13 +156,11 @@ impl ChainHash {
// Mainnet value can be verified at https://github.com/lightning/bolts/blob/master/00-introduction.md
/// `ChainHash` for mainnet bitcoin.
pub const BITCOIN: Self = Self([
111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131,
101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0,
145, 86, 53, 44, 24, 24, 179, 46, 144, 201, 231, 146, 239, 214, 161, 26, 130, 254, 121, 86, 166, 48, 240, 59, 190, 226, 54, 206, 218, 227, 145, 26
]);
/// `ChainHash` for testnet bitcoin.
pub const TESTNET: Self = Self([
67, 73, 127, 215, 248, 38, 149, 113, 8, 244, 163, 15, 217, 206, 195, 174, 186, 121, 151,
32, 132, 233, 14, 173, 1, 234, 51, 9, 0, 0, 0, 0,
158, 85, 80, 115, 208, 196, 243, 100, 86, 219, 137, 81, 244, 73, 112, 77, 84, 77, 40, 38, 217, 170, 96, 99, 107, 64, 55, 70, 38, 120, 10, 187
]);
/// `ChainHash` for signet bitcoin.
pub const SIGNET: Self = Self([
Expand All @@ -171,8 +169,7 @@ impl ChainHash {
]);
/// `ChainHash` for regtest bitcoin.
pub const REGTEST: Self = Self([
6, 34, 110, 70, 17, 26, 11, 89, 202, 175, 18, 96, 67, 235, 91, 191, 40, 195, 79, 58, 94,
51, 42, 31, 199, 178, 183, 60, 241, 136, 145, 15,
165, 115, 233, 28, 23, 114, 7, 108, 13, 64, 247, 14, 68, 8, 200, 58, 49, 112, 95, 41, 106, 230, 231, 98, 157, 74, 220, 181, 163, 96, 33, 61
]);

/// Returns the hash of the `network` genesis block for use as a chain hash.
Expand Down
30 changes: 15 additions & 15 deletions bitcoin/src/consensus/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ impl Params {
Network::Bitcoin => Params {
network: Network::Bitcoin,
bip16_time: 1333238400, // Apr 1 2012
bip34_height: 227931, // 000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8
bip65_height: 388381, // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
bip66_height: 363725, // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
rule_change_activation_threshold: 1916, // 95%
miner_confirmation_window: 2016,
bip34_height: 1034383, //
bip65_height: 3464751, //
bip66_height: 1034383, //
rule_change_activation_threshold: 9576, // 95%
miner_confirmation_window: 10080,
pow_limit: Target::MAX_ATTAINABLE_MAINNET,
pow_target_spacing: 10 * 60, // 10 minutes.
pow_target_timespan: 14 * 24 * 60 * 60, // 2 weeks.
pow_target_spacing: 60, // 1 minutes.
pow_target_timespan: 4 * 60 * 60, // 4 hours.
allow_min_difficulty_blocks: false,
no_pow_retargeting: false,
},
Network::Testnet => Params {
network: Network::Testnet,
bip16_time: 1333238400, // Apr 1 2012
bip34_height: 21111, // 0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8
bip65_height: 581885, // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
bip66_height: 330776, // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
rule_change_activation_threshold: 1512, // 75%
bip34_height: 708658, // 0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8
bip65_height: 1854705, // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
bip66_height: 708658, // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
rule_change_activation_threshold: 2880, // 75%
miner_confirmation_window: 2016,
pow_limit: Target::MAX_ATTAINABLE_TESTNET,
pow_target_spacing: 10 * 60, // 10 minutes.
pow_target_timespan: 14 * 24 * 60 * 60, // 2 weeks.
pow_target_spacing: 60, // 1 minutes.
pow_target_timespan: 4 * 60 * 60, // 4 hours.
allow_min_difficulty_blocks: true,
no_pow_retargeting: false,
},
Expand All @@ -103,8 +103,8 @@ impl Params {
rule_change_activation_threshold: 108, // 75%
miner_confirmation_window: 144,
pow_limit: Target::MAX_ATTAINABLE_REGTEST,
pow_target_spacing: 10 * 60, // 10 minutes.
pow_target_timespan: 14 * 24 * 60 * 60, // 2 weeks.
pow_target_spacing: 1, // 1 second.
pow_target_timespan: 4 * 60 * 60, // 4 hours
allow_min_difficulty_blocks: true,
no_pow_retargeting: true,
},
Expand Down
10 changes: 6 additions & 4 deletions bitcoin/src/crypto/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ impl PrivateKey {
pub fn fmt_wif(&self, fmt: &mut dyn fmt::Write) -> fmt::Result {
let mut ret = [0; 34];
ret[0] = match self.network {
Network::Bitcoin => 128,
Network::Testnet | Network::Signet | Network::Regtest => 239,
Network::Bitcoin => 158,
Network::Testnet => 241,
Network::Signet | Network::Regtest => 239,
};
ret[1..33].copy_from_slice(&self.inner[..]);
let privkey = if self.compressed {
Expand Down Expand Up @@ -345,8 +346,9 @@ impl PrivateKey {
};

let network = match data[0] {
128 => Network::Bitcoin,
239 => Network::Testnet,
158 => Network::Bitcoin,
239 => Network::Regtest,
241 => Network::Testnet,
x => {
return Err(Error::Base58(base58::Error::InvalidAddressVersion(x)));
}
Expand Down
8 changes: 4 additions & 4 deletions bitcoin/src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ pub struct Magic([u8; 4]);

impl Magic {
/// Bitcoin mainnet network magic bytes.
pub const BITCOIN: Self = Self([0xF9, 0xBE, 0xB4, 0xD9]);
pub const BITCOIN: Self = Self([0xc0, 0xc0, 0xc0, 0xc0]);
/// Bitcoin testnet network magic bytes.
pub const TESTNET: Self = Self([0x0B, 0x11, 0x09, 0x07]);
pub const TESTNET: Self = Self([0xfc, 0xc1, 0xb7, 0xdc]);
/// Bitcoin signet network magic bytes.
pub const SIGNET: Self = Self([0x0A, 0x03, 0xCF, 0x40]);
/// Bitcoin regtest network magic bytes.
Expand Down Expand Up @@ -408,8 +408,8 @@ mod tests {
#[test]
fn magic_from_str() {
let known_network_magic_strs = [
("f9beb4d9", Network::Bitcoin),
("0b110907", Network::Testnet),
("c0c0c0c0", Network::Bitcoin),
("fcc1b7dc", Network::Testnet),
("fabfb5da", Network::Regtest),
("0a03cf40", Network::Signet),
];
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ macro_rules! hash_type {
#[cfg_attr(feature = "schemars", derive(crate::schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with = $schemars))] [u8; $bits / 8],
#[cfg_attr(feature = "schemars", schemars(schema_with = $schemars))] pub [u8; $bits / 8],
);

impl Hash {
Expand Down

0 comments on commit fed500c

Please sign in to comment.