Bitcoin Forum
August 11, 2024, 10:30:05 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to make a bitcoin miner using PYTHON?  (Read 166 times)
julia335 (OP)
Newbie
*
Offline Offline

Activity: 20
Merit: 0


View Profile
July 12, 2024, 10:12:06 AM
 #1

I want to get python code that will work for real life bitcoin mining. Is there anybody who could help me? I have gotten the following script which works as simulator only.

import hashlib
import time

def calculate_hash(block_header):
    return hashlib.sha256(block_header.encode()).hexdigest()

def mine_block(previous_hash, transactions, difficulty):
    nonce = 0
    start_time = time.time()

    while True:
        block_header = f"{previous_hash}{transactions}{nonce}"
        block_hash = calculate_hash(block_header)
       
        if block_hash[:difficulty] == '0' * difficulty:
            end_time = time.time()
            print(f"Block mined!")
            print(f"Hash: {block_hash}")
            print(f"Nonce: {nonce}")
            print(f"Time taken: {end_time - start_time:.2f} seconds")
            print(block_header)
            return block_hash, nonce
       
       
        nonce += 1

# Example usage
previous_hash = '0000000000000000000000000000000000000000000000000000000000000000'
transactions = 'tx1->tx2->tx3'
difficulty = 4  # Number of leading zeros required in the hash

mine_block(previous_hash, transactions, difficulty)
ABCbits
Legendary
*
Offline Offline

Activity: 2968
Merit: 7768


Crypto Swap Exchange


View Profile
July 13, 2024, 08:30:16 AM
 #2

I want to get python code that will work for real life bitcoin mining. Is there anybody who could help me? I have gotten the following script which works as simulator only.
--snip--

To get? You could find that easily from quick google search. For example, i found these,
https://bitcointalk.org/index.php?topic=3546.0
https://github.com/muimota/miniminer

Note that i haven't tried any of those, where I'm not responsible if those doesn't work or do anything malicious. And please stop performing SEO spam.

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Stalker22
Legendary
*
Offline Offline

Activity: 1596
Merit: 1379



View Profile
July 13, 2024, 09:36:06 PM
 #3

I am not doing any seo spam. I only want to sell my website.
~

Wait a minute! Are you really that stupid?  So you are the same idiot "fromindia" who you recently claimed hacked your wallet and stole your funds?  Why did you make that whole story up?

See here for reference:

Has anyone looked at the history of his Bitcoin address on the forum? This is a scammer who doesn’t have the intelligence to change the wallet address and regularly makes requests for help or a loan.
It's spring, and it's time for schizophrenics to get worse.

https://ninjastic.space/addresses?address=1DWoQqyx3mDSWRLoQrYphvVLumnqu6N6E

█████████████████████████
██
█████▀▀███████▀▀███████
█████▀░░▄███████▄░░▀█████
██▀░░██████▀░▀████░░▀██
██▀░░▀▀▀████████████░░▀██
██░░█▄████▀▀███▀█████░░██
██░░███▄▄███████▀▀███░░██
██░░█████████████████░░██
██▄░░████▄▄██████▄▄█░░▄██
██▄░░██████▄░░████░░▄██
█████▄░░▀███▌░░▐▀░░▄█████
███████▄▄███████▄▄███████
█████████████████████████
.
.ROOBET 2.0..██████.IIIIIFASTER & SLEEKER.██████.
|

█▄█
▀█▀
████▄▄██████▄▄████
█▄███▀█░░█████░░█▀███▄█
▀█▄▄░▐█████████▌▄▄█▀
██▄▄█████████▄▄████▌
██████▄▄████████
█▀▀████████████████
██████
█████████████
██
█▀▀██████████████
▀▀▀███████████▀▀▀▀
|.
    PLAY NOW    
NotATether
Legendary
*
Offline Offline

Activity: 1694
Merit: 7147


In memory of o_e_l_e_o


View Profile WWW
July 14, 2024, 05:21:47 AM
 #4

If you are trying to build an application in python for real-life mining, you can't really build the SHA256d hashing part. You can only really build the part that receives all of the hashes generated thus far by the mining hardware and send them to a pool like ViaBTC's and retrieve the next range back from it.
ABCbits
Legendary
*
Offline Offline

Activity: 2968
Merit: 7768


Crypto Swap Exchange


View Profile
July 14, 2024, 08:28:38 AM
 #5

I am not doing any seo spam. I only want to sell my website.
--snip--

Whether it's SEO spam or selling ads, you violate these forum rules.

1. No zero or low value, pointless or uninteresting posts or threads. [1][e]

2. No off-topic posts.

--snip--

22. Advertising (this includes mining pools, gambling services, exchanges, shops, etc.) in others' threads is no longer allowed, including, but not limited to, in altcoin announcement threads. [8]



If you are trying to build an application in python for real-life mining, you can't really build the SHA256d hashing part. You can only really build the part that receives all of the hashes generated thus far by the mining hardware and send them to a pool like ViaBTC's and retrieve the next range back from it.

You're right, although OP never say anything about profitable mining. And i feel OP just want excuse to perform SEO spam or selling ads while responding to our reply.

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NotATether
Legendary
*
Offline Offline

Activity: 1694
Merit: 7147


In memory of o_e_l_e_o


View Profile WWW
July 14, 2024, 04:02:48 PM
 #6

@julia335, if you are trying to sell something, you need to move this topic to the Marketplace board.
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!