def calc_hdr_hash(blk_hdr): #hash1 = hashlib.sha256() #hash1.update(blk_hdr) #hash1_o = hash1.digest() #hash2 = hashlib.sha256() #hash2.update(hash1_o) #hash2_o = hash2.digest() #return hash2_o pow_hash = dash_hash.getPoWHash(blk_hdr) return pow_hash
import dash_hash as dashhash __b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' __b58base = len(__b58chars) global PUBKEY_ADDRESS global SCRIPT_ADDRESS PUBKEY_ADDRESS = 76 SCRIPT_ADDRESS = 16 def rev_hex(s): return s.decode('hex')[::-1].encode('hex') # Dash's X11 Function HashX11 = lambda x: dashhash.getPoWHash(x) Hash = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest() hash_encode = lambda x: x[::-1].encode('hex') hash_decode = lambda x: x.decode('hex')[::-1] def header_to_string(res): pbh = res.get('prev_block_hash') if pbh is None: pbh = '0'*64 return int_to_hex4(res.get('version')) \ + rev_hex(pbh) \
def polishash(s): return dash_hash.getPoWHash(s)
def test_dash_hash(self): self.pow_hash = hexlify(dash_hash.getPoWHash(self.block_header)) self.assertEqual(self.pow_hash, self.best_hash)
def gullhash(s): return dash_hash.getPoWHash(s)
def masterhash(s): return dash_hash.getPoWHash(s)
def helpforcancerhash(s): return dash_hash.getPoWHash(s)
def zaaphash(s): return dash_hash.getPoWHash(s)
def ripoffcoinhash(s): return dash_hash.getPoWHash(s)
def exiliumhash(s): return dash_hash.getPoWHash(s)
def dashhash(s): return dash_hash.getPoWHash(s) #To do for Pura - no pura_dash repo!
def waggoxhash(s): return dash_hash.getPoWHash(s)
def corvushash(s): return dash_hash.getPoWHash(s)
def mocacoinhash(s): return dash_hash.getPoWHash(s)
def fusionhash(s): return dash_hash.getPoWHash(s)
def dashhash(s): return dash_hash.getPoWHash(s)
def unodehash(s): return dash_hash.getPoWHash(s)
def block_header_hash(chain, header): import dash_hash return dash_hash.getPoWHash(header)
def bitrityhash(s): return dash_hash.getPoWHash(s)
def generate_hashes_from_block(data_block, algorithm): # if algorithm == 'scrypt': # return scrypt.hash(data_block,data_block,1024,1,1,32)[::-1] # elif algorithm == 'SHA256': # return hashlib.sha256(hashlib.sha256(data_block).digest()).digest()[::-1] # elif algorithm == 'X11': # try: # import xcoin_hash # header_hash = xcoin_hash.getPoWHash(data_block)[::-1] # except ImportError: # sys.exit("Cannot run X11 algorithm: module xcoin_hash not found") # elif algorithm == 'X11': # try: # import x11_hash # header_hash = x11_hash.getPoWHash(data_block)[::-1] # except ImportError: # sys.exit("Cannot run X11 algorithm: module x11_hash not found") if algorithm == 'X11': try: import dash_hash return dash_hash.getPoWHash(data_block)[::-1] except ImportError: sys.exit("Cannot run X11 algorithm: module dash_hash not found") # elif algorithm == 'X11': # try: # header_hash = coinhash.X11Hash(data_block)[::-1] # except ImportError: # sys.exit("Cannot run X11 algorithm: module dash_hash not found") elif algorithm == 'X13': try: import x13_hash return x13_hash.getPoWHash(data_block)[::-1] except ImportError: sys.exit("Cannot run X13 algorithm: module x13_hash not found") elif algorithm == 'X15': try: import x15_hash return x15_hash.getPoWHash(data_block)[::-1] except ImportError: sys.exit("Cannot run X15 algorithm: module x15_hash not found") elif algorithm == 'quark': try: import quark_hash return quark_hash.getPoWHash(data_block)[::-1] except ImportError: sys.exit("Cannot run quark algorithm: module quark_hash not found") elif algorithm == 'lyra2re': try: return mixhash.Lyra2re(data_block)[::-1] except ImportError: sys.exit( "Cannot run quark algorithm: module mixhash.Lyra2re not found") elif algorithm == 'lyra2re2': try: return mixhash.Lyra2re2(data_block)[::-1] except ImportError: sys.exit( "Cannot run quark algorithm: module mixhash.Lyra2re not found") elif algorithm == 'keccak': try: return mixhash.Keccak(data_block)[::-1] except ImportError: sys.exit( "Cannot run quark algorithm: module mixhash.Keccak not found") elif algorithm == 'neoscrypt': try: return mixhash.Neoscrypt(data_block)[::-1] except ImportError: sys.exit( "Cannot run quark algorithm: module mixhash.Neoscrypt not found" ) elif algorithm == 'qubit': try: return mixhash.Qubit(data_block)[::-1] except ImportError: sys.exit( "Cannot run quark algorithm: module mixhash.Qubit not found")
def securetaghash(s): return dash_hash.getPoWHash(s)
def chickendinnerhash(s): return dash_hash.getPoWHash(s)
def gobytehash(s): return dash_hash.getPoWHash(s)
def acedhash(s): return dash_hash.getPoWHash(s)
s = "0"*(2*length - len(s)) + s return rev_hex(s) def var_int(i): if i < 0xfd: return int_to_hex(i) elif i <= 0xffff: return "fd" + int_to_hex(i, 2) elif i <= 0xffffffff: return "fe" + int_to_hex(i, 4) else: return "ff" + int_to_hex(i, 8) # Dash's X11 Function HashX11 = lambda x: dashhash.getPoWHash(x) Hash = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest() hash_encode = lambda x: x[::-1].encode('hex') hash_decode = lambda x: x.decode('hex')[::-1] def header_to_string(res): pbh = res.get('prev_block_hash') if pbh is None: pbh = '0'*64 return int_to_hex(res.get('version'), 4) \ + rev_hex(pbh) \