<<< prev block block 332206 next block >>>
+------------------------------------------------------------------+
| THIBA - Things/Texts Hidden In Bitcoin Addresses readme >>> |
+------------------------------------------------------------------+
| hash160 | decoded text |
+------------------------------------------------------------------+
+------------------------------------------------------------------+
| 593757c37303a8487c60ed2c522b315594b365a66b2012c46da0ac8bb504225a |
+------------------------------------------------------------------+
| 2320656c65637472756d746f6f6c732e70790d0a | # electrumtools.py
| 232052657475726e73207468652068617368206f | # Returns the hash o
| 66206120626c6f636b0d0a23204261736564206f | f a block # Based o
| 6e20636f64652066726f6d20456c65637472756d | n code from Electrum
| 20312e39782e2028626974636f696e2e70792c20 | 1.9x. (bitcoin.py,
| 626c6f636b636861696e2e70792c20474e552047 | blockchain.py, GNU G
| 504c20332c2068747470733a2f2f676974687562 | PL 3, https://github
| 2e636f6d2f737065736d696c6f2f656c65637472 | .com/spesmilo/electr
| 756d290d0a23204e6565647320626c6f636b6368 | um) # Needs blockch
| 61696e5f686561646572732066696c6520666f75 | ain_headers file fou
| 6e6420617420687474703a2f2f68656164657273 | nd at http://headers
| 2e656c65637472756d2e6f72672f626c6f636b63 | .electrum.org/blockc
| 6861696e5f686561646572730d0a23206173682c | hain_headers # ash,
| 20323031342d31312d33300d0a696d706f727420 | 2014-11-30 import
| 6f730d0a696d706f727420686173686c69620d0a | os import hashlib
| 2020202072657475726e20686173686c69622e73 | return hashlib.s
| 68613235362878292e64696765737428290d0a0d | ha256(x).digest()
| 0a0d0a64656620686173682878293a0d0a202020 | def hash(x):
| 206966207479706528782920697320756e69636f | if type(x) is unico
| 64653a2078203d20782e656e636f646528277574 | de: x = x.encode('ut
| 662d3827290d0a2020202072657475726e207368 | f-8') return sh
| 6132353628736861323536287829290d0a0d0a0d | a256(sha256(x))
| 0a646566207265765f6865782873293a0d0a2020 | def rev_hex(s):
| 202072657475726e20732e6465636f6465282768 | return s.decode('h
| 657827295b3a3a2d315d2e656e636f6465282768 | ex')[::-1].encode('h
| 5f68657828692c206c656e6774683d31293a0d0a | _hex(i, length=1):
| 2020202073203d206865782869295b323a5d2e72 | s = hex(i)[2:].r
| 737472697028274c27290d0a2020202073203d20 | strip('L') s =
| 223022202a202832202a206c656e677468202d20 | "0" * (2 * length -
| 6c656e28732929202b20730d0a20202020726574 | len(s)) + s ret
| 646566206865616465725f746f5f737472696e67 | def header_to_string
| 28726573293a0d0a2020202073203d20696e745f | (res): s = int_
| 746f5f686578287265732e676574282776657273 | to_hex(res.get('vers
| 696f6e27292c203429205c0d0a20202020202020 | ion'), 4) \
| 202b207265765f686578287265732e6765742827 | + rev_hex(res.get('
| 707265765f626c6f636b5f68617368272929205c | prev_block_hash')) \
| 0d0a20202020202020202b207265765f68657828 | + rev_hex(
| 7265732e67657428276d65726b6c655f726f6f74 | res.get('merkle_root
| 272929205c0d0a20202020202020202b20696e74 | ')) \ + int
| 5f746f5f68657828696e74287265732e67657428 | _to_hex(int(res.get(
| 2774696d657374616d702729292c203429205c0d | 'timestamp')), 4) \
| 0a20202020202020202b20696e745f746f5f6865 | + int_to_he
| 7828696e74287265732e67657428276269747327 | x(int(res.get('bits'
| 29292c203429205c0d0a20202020202020202b20 | )), 4) \ +
| 696e745f746f5f68657828696e74287265732e67 | int_to_hex(int(res.g
| 657428276e6f6e63652729292c2034290d0a2020 | et('nonce')), 4)
| 6865616465725f66726f6d5f737472696e672873 | header_from_string(s
| 293a0d0a202020206865785f746f5f696e74203d | ): hex_to_int =
| 206c616d62646120733a20696e74282730782720 | lambda s: int('0x'
| 2b20735b3a3a2d315d2e656e636f646528276865 | + s[::-1].encode('he
| 7827292c203136290d0a20202020686173685f65 | x'), 16) hash_e
| 6e636f6465203d206c616d62646120783a20785b | ncode = lambda x: x[
| 3a3a2d315d2e656e636f6465282768657827290d | ::-1].encode('hex')
| 0a2020202068203d207b7d0d0a20202020685b27 | h = {} h['
| 76657273696f6e275d203d206865785f746f5f69 | version'] = hex_to_i
| 6e7428735b303a345d290d0a20202020685b2770 | nt(s[0:4]) h['p
| 7265765f626c6f636b5f68617368275d203d2068 | rev_block_hash'] = h
| 6173685f656e636f646528735b343a33365d290d | ash_encode(s[4:36])
| 0a20202020685b276d65726b6c655f726f6f7427 | h['merkle_root'
| 5d203d20686173685f656e636f646528735b3336 | ] = hash_encode(s[36
| 3a36385d290d0a20202020685b2774696d657374 | :68]) h['timest
| 616d70275d203d206865785f746f5f696e742873 | amp'] = hex_to_int(s
| 5b36383a37325d290d0a20202020685b27626974 | [68:72]) h['bit
| 73275d203d206865785f746f5f696e7428735b37 | s'] = hex_to_int(s[7
| 323a37365d290d0a20202020685b276e6f6e6365 | 2:76]) h['nonce
| 275d203d206865785f746f5f696e7428735b3736 | '] = hex_to_int(s[76
| 3a38305d290d0a2020202072657475726e20680d | :80]) return h
| 0a0d0a0d0a64656620726561645f686561646572 | def read_header
| 2866696c656e616d652c20626c6f636b5f686569 | (filename, block_hei
| 676874293a0d0a202020206966206f732e706174 | ght): if os.pat
| 682e6578697374732866696c656e616d65293a0d | h.exists(filename):
| 0a202020202020202066203d206f70656e286669 | f = open(fi
| 6c656e616d652c2027726227290d0a2020202020 | lename, 'rb')
| 202020662e7365656b28626c6f636b5f68656967 | f.seek(block_heig
| 6874202a203830290d0a20202020202020206820 | ht * 80) h
| 3d20662e72656164283830290d0a202020202020 | = f.read(80)
| 2020662e636c6f736528290d0a20202020202020 | f.close()
| 206966206c656e286829203d3d2038303a0d0a20 | if len(h) == 80:
| 202020202020202020202068203d206865616465 | h = heade
| 725f66726f6d5f737472696e672868290d0a2020 | r_from_string(h)
| 2020202020202020202072657475726e20680d0a | return h
| 0d0a0d0a64656620686173685f68656164657228 | def hash_header(
| 686561646572293a0d0a2020202072657475726e | header): return
| 207265765f686578286861736828686561646572 | rev_hex(hash(header
| 5f746f5f737472696e6728686561646572292e64 | _to_string(header).d
| 65636f646528276865782729292e656e636f6465 | ecode('hex')).encode
| 616d655f5f203d3d20275f5f6d61696e5f5f273a | ame__ == '__main__':
| 0d0a2020202066696c656e616d65203d2027626c | filename = 'bl
| 6f636b636861696e5f68656164657273270d0a20 | ockchain_headers'
| 20202068203d20726561645f6865616465722866 | h = read_header(f
| 696c656e616d652c2030290d0a0d0a2020202070 | ilename, 0) p
| 72696e7420686173685f6865616465722868290d | rint hash_header(h)
| 0a20202020202020202020202020202020202020 |
+------------------------------------------------------------------+