Bitcoin Forum
April 26, 2024, 03:46:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Converting RIPEMD160 to address  (Read 177 times)
Stroncow (OP)
Jr. Member
*
Offline Offline

Activity: 38
Merit: 13


View Profile
April 06, 2021, 11: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)
1714146408
Hero Member
*
Offline Offline

Posts: 1714146408

View Profile Personal Message (Offline)

Ignore
1714146408
Reply with quote  #2

1714146408
Report to moderator
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714146408
Hero Member
*
Offline Offline

Posts: 1714146408

View Profile Personal Message (Offline)

Ignore
1714146408
Reply with quote  #2

1714146408
Report to moderator
1714146408
Hero Member
*
Offline Offline

Posts: 1714146408

View Profile Personal Message (Offline)

Ignore
1714146408
Reply with quote  #2

1714146408
Report to moderator
BlackHatCoiner
Legendary
*
Online Online

Activity: 1498
Merit: 7291


Farewell, Leo


View Profile
April 06, 2021, 11: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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6686


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 06, 2021, 12:07:05 PM
Merited by ABCbits (1), hugeblack (1), nc50lc (1)
 #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)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Stroncow (OP)
Jr. Member
*
Offline Offline

Activity: 38
Merit: 13


View Profile
April 06, 2021, 03:17:11 PM
Merited by LoyceV (2), hugeblack (1), NotATether (1)
 #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')
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 06, 2021, 05: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?
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6686


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 07, 2021, 05: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)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 08, 2021, 02:23:11 PM
 #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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!