[BREAKING CHANGE] [v0.5 -> v0.6] Move nasty script stuff into a feature-gated module

This commit is contained in:
Andrew Poelstra 2016-06-12 00:03:10 +00:00
parent 46681bbcac
commit 220775015e
5 changed files with 3195 additions and 2611 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "bitcoin"
version = "0.5.11"
version = "0.6.0"
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
license = "CC0-1.0"
homepage = "https://github.com/apoelstra/rust-bitcoin/"
@ -15,6 +15,12 @@ readme = "README.md"
name = "bitcoin"
path = "src/lib.rs"
[features]
# Compile broken and complicated script interpreter, as well as
# an unspendability checker which is not broken (I think) but is
# a huge pile of unreviewed code
broken_consensus_code = []
[dependencies]
byteorder = "0.3"
num = "0.1"

View File

@ -20,9 +20,13 @@
pub mod constants;
pub mod opcodes;
pub mod script;
#[cfg(not(feature="broken_consensus_code"))] pub mod script;
pub mod transaction;
pub mod block;
pub mod blockchain;
#[cfg(feature="broken_consensus_code")]
/// # Script -- including consensus code
pub mod script {
include!("script_consensus.rs");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ use std::fmt;
use serde;
use util::hash::Sha256dHash;
use blockdata::script::{self, Script, ScriptTrace};
use blockdata::script::Script;
use network::serialize::BitcoinHash;
/// A reference to a transaction output
@ -112,54 +112,6 @@ impl Transaction {
}
}
/// A transaction error
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum Error {
/// Concatenated script failed in the input half (script error)
InputScriptFailure(script::Error),
/// Concatenated script failed in the output half (script error)
OutputScriptFailure(script::Error),
/// P2SH serialized script failed (script error)
P2shScriptFailure(script::Error),
/// P2SH serialized script ended with false at the top of the stack
P2shScriptReturnedFalse,
/// P2SH serialized script ended with nothing in the stack
P2shScriptReturnedEmptyStack,
/// Script ended with false at the top of the stack
ScriptReturnedFalse,
/// Script ended with nothing in the stack
ScriptReturnedEmptyStack,
/// Script ended with nothing in the stack (input txid, input vout)
InputNotFound(Sha256dHash, u32),
}
display_from_debug!(Error);
impl serde::Serialize for Error {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer,
{
serializer.visit_str(&self.to_string())
}
}
/// A trace of a transaction input's script execution
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct InputTrace {
input_txid: Sha256dHash,
input_vout: usize,
sig_trace: ScriptTrace,
pubkey_trace: Option<ScriptTrace>,
p2sh_trace: Option<ScriptTrace>,
error: Option<Error>
}
/// A trace of a transaction's execution
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct TransactionTrace {
txid: Sha256dHash,
inputs: Vec<InputTrace>
}
impl BitcoinHash for Transaction {
fn bitcoin_hash(&self) -> Sha256dHash {
use network::serialize::serialize;
@ -167,6 +119,7 @@ impl BitcoinHash for Transaction {
}
}
impl_consensus_encoding!(TxIn, prev_hash, prev_index, script_sig, sequence);
impl_consensus_encoding!(TxOut, value, script_pubkey);
impl_consensus_encoding!(Transaction, version, input, output, lock_time);