Author

Topic: Converting RIPEMD160 to address (Read 178 times)

member
Activity: 406
Merit: 45
April 08, 2021, 10:23:11 AM
#7

if want to reverse address to RIPEMD160 for recheck is correct (or use convert address to RIPEMD160)

Do you have simple code?

The base58 library provides a base58decode_check function that decodes a byte-encoded base58 string back into a byte array. Note that you must convert the base58 string to bytes first before you can pass it as an argument, and because you not only get RIPEMD160 bytes but also the checksum back, you need to strip the checksum too.

Code:
import base58

addr = "insert base58 address here"

bytesaddr = bytes(addr, "utf-8")
r160check = base58.base58decode_check(bytesaddr).decode('utf-8');

r160 = r160check[2:] # If you put a "00" at the beginning of the string, so remove it
print(r160)

Thank you NotATether
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 07, 2021, 01:38:39 AM
#6

if want to reverse address to RIPEMD160 for recheck is correct (or use convert address to RIPEMD160)

Do you have simple code?

The base58 library provides a base58decode_check function that decodes a byte-encoded base58 string back into a byte array. Note that you must convert the base58 string to bytes first before you can pass it as an argument, and because you not only get RIPEMD160 bytes but also the checksum back, you need to strip the checksum too.

Code:
import base58

addr = "insert base58 address here"

bytesaddr = bytes(addr, "utf-8")
r160check = base58.base58decode_check(bytesaddr).decode('utf-8');

r160 = r160check[2:] # If you put a "00" at the beginning of the string, so remove it
print(r160)
member
Activity: 406
Merit: 45
April 06, 2021, 01:41:06 PM
#5

if want to reverse address to RIPEMD160 for recheck is correct (or use convert address to RIPEMD160)

Do you have simple code?
jr. member
Activity: 38
Merit: 13
April 06, 2021, 11:17:11 AM
#4
Install the base58 library from Pip and use the base58.base58encode_check(bytestring) function to encode it.

Code:
import base58

hash160 = '010966776006953D5567439E5E39F86A0D273BEE'

# convert your hex string into a byte array like this:
b = bytes.fromhex(hash160)

addr = base58.b58encode_check(b).decode('utf-8')  # Should give you the address
print(addr)

Thank you. I added them.

Code:
import base58

with open('2.txt', 'r') as f:
for hash160 in f:
key_hash = '00' + hash160
b = bytes.fromhex(key_hash)
addr = base58.b58encode_check(b).decode('utf-8')
open('addresses.txt', 'a').write(addr + '\n')
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 06, 2021, 08:07:05 AM
#3
Install the base58 library from Pip and use the base58.base58encode_check(bytestring) function to encode it.

Code:
import base58

hash160 = '010966776006953D5567439E5E39F86A0D273BEE'

# convert your hex string into a byte array like this:
b = bytes.fromhex(hash160)

addr = base58.b58encode_check(b).decode('utf-8')  # Should give you the address
print(addr)
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
April 06, 2021, 07:46:41 AM
#2
I haven't work with python in the past, but based on the code you posted, you're performing a function falsely. Precisely, it's pubtoaddr(string). As far as I can read from the code, you should enter a public key as a string parameter of that function, not a hash160.

I'm saying this without knowing what that function do, I just understand it from its name. A python expert could give you a better answer.
jr. member
Activity: 38
Merit: 13
April 06, 2021, 07:28:50 AM
#1
I want to convert all hash160s in the list to addresses.

This code did not work for me, what should I do to edit it?

Code:
from bitcoin import *

hash160 = '010966776006953D5567439E5E39F86A0D273BEE'
addr = pubtoaddr(hash160)
print (addr)
Jump to: