merkle root
This commit is contained in:
parent
d1c83bc724
commit
681ad5984b
|
@ -77,12 +77,17 @@ impl Verify for ChainVerifier {
|
|||
return Err(Error::Timestamp);
|
||||
}
|
||||
|
||||
// verify merkle root
|
||||
if block.merkle_root() != block.header().merkle_root_hash {
|
||||
return Err(Error::MerkleRoot);
|
||||
}
|
||||
|
||||
// check first transaction is a coinbase transaction
|
||||
if !block.transactions()[0].is_coinbase() {
|
||||
return Err(Error::Coinbase)
|
||||
}
|
||||
|
||||
// verify transactions
|
||||
// verify transactions (except coinbase)
|
||||
for (idx, transaction) in block.transactions().iter().skip(1).enumerate() {
|
||||
try!(self.verify_transaction(transaction).map_err(|e| Error::Transaction(idx, e)));
|
||||
}
|
||||
|
@ -197,4 +202,6 @@ mod tests {
|
|||
assert_eq!(Chain::Main, verifier.verify(&b1).unwrap());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ pub enum Error {
|
|||
/// One of the transactions is invalid (corresponding index and specific transaction error)
|
||||
Transaction(usize, TransactionError),
|
||||
/// nBits do not match difficulty rules
|
||||
Difficulty
|
||||
Difficulty,
|
||||
/// Invalid merkle root
|
||||
MerkleRoot,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Reference in New Issue