Revert "Added regtest"

This reverts commit 34e228c699.
This commit is contained in:
Andrew Poelstra 2018-06-16 22:54:32 +00:00
parent 14a920ab7d
commit bc5cb3bc31
5 changed files with 9 additions and 29 deletions

View File

@ -121,20 +121,6 @@ pub fn genesis_block(network: Network) -> Block {
txdata: txdata
}
}
Network::Regtest => {
let txdata = vec![bitcoin_genesis_tx()];
Block {
header: BlockHeader {
version: 1,
prev_blockhash: Default::default(),
merkle_root: txdata.merkle_root(),
time: 1296688602,
bits: 0x207fffff,
nonce: 2
},
txdata: txdata
}
}
}
}

View File

@ -28,9 +28,7 @@ user_enum! {
#[doc="Classic Bitcoin"]
Bitcoin <-> "bitcoin",
#[doc="Bitcoin's testnet"]
Testnet <-> "testnet",
#[doc="Bitcoin's regtest"]
Regtest <-> "regtest"
Testnet <-> "testnet"
}
}
@ -46,8 +44,7 @@ pub const USER_AGENT: &'static str = "bitcoin-rust v0.1";
pub fn magic(network: Network) -> u32 {
match network {
Network::Bitcoin => 0xD9B4BEF9,
Network::Testnet => 0x0709110B,
Network::Regtest => 0xDAB5BFFA,
Network::Testnet => 0x0709110B
// Note: any new entries here must be added to `consensus_decode` below
}
}
@ -66,7 +63,6 @@ impl<D: SimpleDecoder> ConsensusDecodable<D> for Network {
match magic {
0xD9B4BEF9 => Ok(Network::Bitcoin),
0x0709110B => Ok(Network::Testnet),
0xDAB5BFFA => Ok(Network::Regtest),
x => Err(d.error(format!("Unknown network (magic {:x})", x)))
}
}
@ -81,11 +77,9 @@ mod tests {
fn serialize_test() {
assert_eq!(serialize(&Network::Bitcoin).unwrap(), vec![0xf9, 0xbe, 0xb4, 0xd9]);
assert_eq!(serialize(&Network::Testnet).unwrap(), vec![0x0b, 0x11, 0x09, 0x07]);
assert_eq!(serialize(&Network::Regtest).unwrap(), vec![0xfa, 0xbf, 0xb5, 0xda]);
assert_eq!(deserialize(&[0xf9, 0xbe, 0xb4, 0xd9]).ok(), Some(Network::Bitcoin));
assert_eq!(deserialize(&[0x0b, 0x11, 0x09, 0x07]).ok(), Some(Network::Testnet));
assert_eq!(deserialize(&[0xfa, 0xbf, 0xb5, 0xda]).ok(), Some(Network::Regtest));
let bad: Result<Network, _> = deserialize("fakenet".as_bytes());
assert!(bad.is_err());

View File

@ -162,7 +162,7 @@ impl Address {
fn bech_network (network: Network) -> bitcoin_bech32::constants::Network {
match network {
Network::Bitcoin => bitcoin_bech32::constants::Network::Bitcoin,
Network::Testnet | Network::Regtest => bitcoin_bech32::constants::Network::Testnet,
Network::Testnet => bitcoin_bech32::constants::Network::Testnet
}
}
@ -206,7 +206,7 @@ impl ToString for Address {
let mut prefixed = [0; 21];
prefixed[0] = match self.network {
Network::Bitcoin => 0,
Network::Testnet | Network::Regtest => 111,
Network::Testnet => 111,
};
prefixed[1..].copy_from_slice(&hash[..]);
base58::check_encode_slice(&prefixed[..])
@ -215,7 +215,7 @@ impl ToString for Address {
let mut prefixed = [0; 21];
prefixed[0] = match self.network {
Network::Bitcoin => 0,
Network::Testnet | Network::Regtest => 111,
Network::Testnet => 111,
};
prefixed[1..].copy_from_slice(&hash[..]);
base58::check_encode_slice(&prefixed[..])
@ -224,7 +224,7 @@ impl ToString for Address {
let mut prefixed = [0; 21];
prefixed[0] = match self.network {
Network::Bitcoin => 5,
Network::Testnet | Network::Regtest => 196,
Network::Testnet => 196,
};
prefixed[1..].copy_from_slice(&hash[..]);
base58::check_encode_slice(&prefixed[..])

View File

@ -344,7 +344,7 @@ impl ToString for ExtendedPrivKey {
let mut ret = [0; 78];
ret[0..4].copy_from_slice(&match self.network {
Network::Bitcoin => [0x04, 0x88, 0xAD, 0xE4],
Network::Testnet | Network::Regtest => [0x04, 0x35, 0x83, 0x94],
Network::Testnet => [0x04, 0x35, 0x83, 0x94],
}[..]);
ret[4] = self.depth as u8;
ret[5..9].copy_from_slice(&self.parent_fingerprint[..]);
@ -402,7 +402,7 @@ impl ToString for ExtendedPubKey {
let mut ret = [0; 78];
ret[0..4].copy_from_slice(&match self.network {
Network::Bitcoin => [0x04u8, 0x88, 0xB2, 0x1E],
Network::Testnet | Network::Regtest => [0x04u8, 0x35, 0x87, 0xCF],
Network::Testnet => [0x04u8, 0x35, 0x87, 0xCF],
}[..]);
ret[4] = self.depth as u8;
ret[5..9].copy_from_slice(&self.parent_fingerprint[..]);

View File

@ -96,7 +96,7 @@ impl ToString for Privkey {
let mut ret = [0; 34];
ret[0] = match self.network {
Network::Bitcoin => 128,
Network::Testnet | Network::Regtest => 239,
Network::Testnet => 239
};
ret[1..33].copy_from_slice(&self.key[..]);
if self.compressed {