Bitcoin Forum
May 10, 2024, 02:38:42 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: find a checksum to a wallet btc  (Read 87 times)
lisa6336 (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
February 11, 2023, 01:28:11 AM
 #1


Hi friends,

i really need help
I am looking for this checksum 9ed6e860 as an answer for my wallet 1H5aq8vssj9fCKdw2mYEn8enzpUMEBsUZ7

I tried with my script but it does not give me the same thing at all tell me where is the problem and help me modify the script in question,


import hashlib

def get_btc_checksum(address):
    """
    Compute the checksum of a Bitcoin address.

    Args:
    - address (str): The Bitcoin address.

    Returns:
    - str: The checksum of the Bitcoin address.
    """
    address = address.lower().encode('utf-8')
    sha256_hash = hashlib.sha256(address).hexdigest()
    ripe160_hash = hashlib.new('ripemd160', sha256_hash.encode('utf-8')).hexdigest()

    checksum = ''
    for i in range(len(ripe160_hash)):
        if ripe160_hash in '123456789abcdef':
            checksum += ripe160_hash
        else:
            checksum += str(ord(ripe160_hash))

    return checksum

btc_address = '1H5aq8vssj9fCKdw2mYEn8enzpUMEBsUZ7'
print('The checksum of the address', btc_address, 'is:', get_btc_checksum(btc_address))
1715308722
Hero Member
*
Offline Offline

Posts: 1715308722

View Profile Personal Message (Offline)

Ignore
1715308722
Reply with quote  #2

1715308722
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715308722
Hero Member
*
Offline Offline

Posts: 1715308722

View Profile Personal Message (Offline)

Ignore
1715308722
Reply with quote  #2

1715308722
Report to moderator
1715308722
Hero Member
*
Offline Offline

Posts: 1715308722

View Profile Personal Message (Offline)

Ignore
1715308722
Reply with quote  #2

1715308722
Report to moderator
1715308722
Hero Member
*
Offline Offline

Posts: 1715308722

View Profile Personal Message (Offline)

Ignore
1715308722
Reply with quote  #2

1715308722
Report to moderator
nc50lc
Legendary
*
Offline Offline

Activity: 2408
Merit: 5593


Self-proclaimed Genius


View Profile
February 13, 2023, 07:20:55 AM
Merited by vapourminer (1)
 #2

If the input is the address, all you have to do is to decode it with base58 and then get the last 4 Bytes.

Address: 1H5aq8vssj9fCKdw2mYEn8enzpUMEBsUZ7
Decoded: 00b05fea8c3768f8fbb48f9c778bb36b91334cf7a169e65f22
Last 4 Bytes: 69e65f22 (which is the correct checksum)

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

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

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

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

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

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











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











▄▄▄▄█
witcher_sense
Legendary
*
Offline Offline

Activity: 2338
Merit: 4334

🔐BitcoinMessage.Tools🔑


View Profile WWW
February 13, 2023, 07:53:25 AM
Merited by vapourminer (1), RickDeckard (1)
 #3

Before implementing any algorithm you should consult the documentation that describes this algorithm, otherwise you are risking to never find a solution to the problem the crux of which you don't fully understand. Address is simply an encoded version of some other data. In order to determine what data was taken to calculate an address, you should decode it back. Legacy addresses use Base58 encoding algorithm, which is case sensitive. When you convert it to lowercase like that:

Code:
address = address.lower().encode('utf-8')

... you break things and get a wrong result. But it is not the only problem in your code, all other steps are wrong too.

Read this articles before asking questions:

1) https://en.bitcoin.it/wiki/Base58Check_encoding
2) https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

One-line solution with base58 module:

Code:
import base58

checksum = base58.b58decode(address)[-4:].hex()

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
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!