def is_valid(self):
     flag_bits = bytes_to_bit_field(self.flags)
     hashes = [h[::-1] for h in self.hashes]
     merkle_tree = MerkleTree(self.total)
     merkle_tree.populate_tree(flag_bits, hashes)
     return merkle_tree.root()[::-1] == self.merkle_root
     raise NotImplementedError
示例#2
0
 def is_valid(self):
     '''Verifies whether the merkle tree information validates to the merkle root'''
     flag_bits = bytes_to_bit_field(self.flags)
     hashes_reverse = []
     for h in self.hashes:
         hashes_reverse.append(h[::-1])
     tree = MerkleTree(self.total)
     tree.populate_tree(flag_bits, hashes_reverse)
     return tree.root()[::-1] == self.merkle_root
示例#3
0
 def check_validity(self):
     '''Verifies whether the merkle tree information validates to the merkle root'''
     # convert the flags field to a bit field
     flag_bits = bytes_to_bit_field(self.flags)
     # reverse self.hashes for the merkle root calculation
     hashes = [h[::-1] for h in self.hashes]
     # initialize the merkle tree
     merkle_tree = MerkleTree(self.total)
     # populate the tree with flag bits and hashes
     proved_txs = merkle_tree.populate_tree(flag_bits, hashes)
     # check if the computed root reversed is the same as the merkle root
     return merkle_tree.root()[::-1] == self.header.merkle_root, proved_txs
示例#4
0
 def is_valid(self):
     '''Verifies whether the merkle tree information validates to the merkle root'''
     # use bytes_to_bit_field on self.flags to get the flag_bits
     flag_bits = bytes_to_bit_field(self.flags)
     # set hashes to be the reversed hashes of everything in self.hashes
     hashes = [h[::-1] for h in self.hashes]
     # initialize the merkle tree with self.total
     merkle_tree = MerkleTree(self.total)
     # populate_tree with flag_bits and hashes
     merkle_tree.populate_tree(flag_bits, hashes)
     # check if the computed root [::-1] is the same as the merkle root
     return merkle_tree.root()[::-1] == self.merkle_root
示例#5
0
 def is_valid(self):
     '''Verifies whether the merkle tree information validates to the merkle root'''
     # convert the flags field to a bit field using bytes_to_bit_field
     flag_bits = bytes_to_bit_field(self.flags)
     # reverse the hashes to get our list of hashes for merkle root calculation
     hashes = [h[::-1] for h in self.hashes]
     # initialize the merkle tree
     merkle_tree = MerkleTree(self.total)
     # populate the tree with flag bits and hashes
     merkle_tree.populate_tree(flag_bits, hashes)
     # check if the computed root [::-1] is the same as the merkle root
     return merkle_tree.root()[::-1] == self.merkle_root
示例#6
0
 def is_valid(self):
     '''Verifies whether the merkle tree information validates to the merkle root'''
     flag_bits = bytes_to_bit_field(self.flags)
     hashes = [h[::-1] for h in self.hashes]
     merkle_tree = MerkleTree(self.total)
     print(merkle_tree)
     print('total tx in block: {} hashes {} \n{}'.format(
         self.total, self.hashes, self.prev_block))
     merkle_tree.populate_tree(flag_bits, hashes)
     return merkle_tree.root()[::-1] == self.merkle_root
     # convert the flags field to a bit field
     # reverse self.hashes for the merkle root calculation
     # initialize the merkle tree
     # populate the tree with flag bits and hashes
     # check if the computed root reversed is the same as the merkle root
     raise NotImplementedError
示例#7
0
def is_valid(self):
    flag_bits = bytes_to_bit_field(self.flags)
    hashes = [h[::-1] for h in self.hashes]
    merkle_tree = MerkleTree(self.total)
    merkle_tree.populate_tree(flag_bits, hashes)
 def is_valid(self):
     mktree = MerkleTree(self.total)
     flag_bits = bytes_to_bit_field(self.flags)
     hashes = [h[::-1] for h in self.hashes]
     mktree.populate_tree(flag_bits, hashes)
     return self.merkle_root == mktree.root()[::-1]