nbits max check

This commit is contained in:
NikVolf 2016-11-22 12:00:38 +03:00
parent eb24c5aff6
commit e6c182a904
1 changed files with 4 additions and 0 deletions

View File

@ -4,7 +4,11 @@ use byteorder::{BigEndian, ByteOrder};
use chain;
use script::{self, Script};
const MAX_NBITS: u32 = 0x207fffff;
pub fn check_nbits(hash: &H256, n_bits: u32) -> bool {
if n_bits > MAX_NBITS { return false; }
let hash_bytes: &[u8] = &**hash;
let mut nb = [0u8; 4];