Bitcoin Forum
September 29, 2025, 06:25:54 AM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: How to convert bech32 address to hash160 in python? on: March 28, 2022, 03:36:49 AM
I search a bit and found a python code that can convert bech32 to hash160 I don't if this is the exact script you looking for but read this

Quote from: Question
Is there a way to get to the hash160 address from bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c

Thaks a lot🙏

Code:
import bech32

f = open("addresses.txt", "r")
for line in f:
hash1 = bech32.decode("bc", line.strip())
try:
hash2 = bytes(hash1[1])
open('hash160.txt', 'a').write(hash2.hex() + '\n')
except:
print('False:', line.strip())
pass
f.close()
2  Bitcoin / Development & Technical Discussion / How to convert bech32 <> hash160 in python? on: March 27, 2022, 10:15:58 PM
like this script:

Code:
import base58

f = open("addresses.txt", "r")
for line in f:
try:
hash1 = base58.b58decode_check(line.strip())
open('hash160.txt', 'a').write(hash1.hex()[-40:] + '\n')
except:
print('False:', line.strip())
pass
f.close()
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!