├── LooperLinux.sh ├── LooperWin.bat ├── README.md ├── SoloMiner.py ├── SoloMinerPost.jpg ├── Solominer_v2.py ├── SoloxMiner.PNG └── _config.yml /LooperLinux.sh: -------------------------------------------------------------------------------- 1 | while : 2 | do 3 | python3 Solominer_v2.py 4 | done 5 | -------------------------------------------------------------------------------- /LooperWin.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | title Solominer_v2.py 3 | Pushd "%~dp0" 4 | :loop 5 | python Solominer_v2.py 6 | goto loop 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Solo Miner 2 | ## Bitcoin Mining With SoloMiner On Python 3 | 4 | New Program Source Bitcoin Free Mining with python and high speed best hash rate . use ckpool for solo miner . 5 | 6 | ![Bitcoin Mining With Python Source Solo Miner ckpool](https://mmdrza.com/wp-content/uploads/2022/04/SoloMinerPost.jpg) 7 | 8 | first install this package's : 9 | ``` 10 | pip install requests 11 | pip install colorthon 12 | ``` 13 | if use windows can run this code on .bat or .cmd file for loop for ever time to your system , 14 | ``` 15 | @Echo off 16 | title SoloMiner.py 17 | Pushd "%~dp0" 18 | :loop 19 | python SoloMiner.py 20 | goto loop 21 | ``` 22 | 23 | ---- 24 | ![Bitcoin Mining With Python (SoloMiner)](https://mmdrza.com/wp-content/uploads/2022/04/SoloxMiner.png 'Bitcoin Miner With Python solo miner') 25 | 26 | ---- 27 | 28 | ### Download File 29 | 30 | | Filename | Type | Link | 31 | | ------- | ------ | ------ | 32 | | SoloMiner | Python File .py | [Download](https://mmdrza.page.link/uEsh) | 33 | | LooperWin | Shell Script .cmd / .bat | [Download](https://mmdrza.page.link/Looper) | 34 | | LooperLinux | Bash Script .sh `sh looper.sh`| [Download](https://mmdrza.page.link/LooperSH) | 35 | 36 | ---- 37 | >[!NOTE] 38 | >This script is placed in this section for public review and use, and all the incomes that the audience intends and uses are the responsibility of the pool that is connected to it. So please refer to the [official website](https://solo.ckpool.org/ 'solo.ckpool.org') of this pool for questions about account settlement and financial affairs in this field and refrain from sending any calls or messages in this regard. [`ckpool`](https://solo.ckpool.org/ 'solo.ckpool.org') 39 | 40 | 41 | -------------------------------------------------------------------------------- /SoloMiner.py: -------------------------------------------------------------------------------- 1 | from colorama import Fore, Style 2 | from threading import Thread 3 | import requests 4 | import binascii 5 | import hashlib 6 | import logging 7 | import socket 8 | import random 9 | import json 10 | import time 11 | import sys 12 | 13 | 14 | #''' 15 | # 16 | # /\ /\ /\ /\ /\ /\ /\ 17 | # /\//\\/\ /\//\\/\ /\//\\/\ /\//\\/\ /\//\\/\ /\//\\/\ /\//\\/\ 18 | # /\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\ 19 | # /\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\ 20 | # \//\/ \/\\// 21 | # \/ ____ ___ _ ___ __ __ ___ _ _ _____ ____ \/ 22 | # /\ / ___| / _ \| | / _ \ | \/ |_ _| \ | | ____| _ \ /\ 23 | # /\\ \___ \| | | | | | | | | | |\/| || || \| | _| | |_) | //\\ 24 | # \// ___) | |_| | |__| |_| | | | | || || |\ | |___| _ < \\// 25 | # \/ |____/ \___/|_____\___/ |_| |_|___|_| \_|_____|_| \_\ \/ 26 | # /\ /\ 27 | # \/ PROGRAMMER = MMDRZA || Official WebSite : httpS://Mmdrza.Com \/ 28 | # /\ X4@mmdrza.Com / Github.Com/PyMmdrza / Dev.TO/Mmdrza /\ 29 | # /\\/\ /\//\\ 30 | # \///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\///\\/\//\\\// 31 | # \/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/\\///\\\//\/ 32 | # \/\\//\/ \/\\//\/ \/\\//\/ \/\\//\/ \/\\//\/ \/\\//\/ \/\\//\/ 33 | # \/ \/ \/ \/ \/ \/ \/ 34 | # 35 | #''' 36 | 37 | soloxminer = ''' 38 | ███████╗ ██████╗ ██╗ ██████╗ 39 | ██╔════╝██╔═══██╗██║ ██╔═══██╗ 40 | ███████╗██║ ██║██║ ██║ ██║ 41 | ╚════██║██║ ██║██║ ██║ ██║ 42 | ███████║╚██████╔╝███████╗╚██████╔╝ 43 | ╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ 44 | 45 | ███╗ ███╗██╗███╗ ██╗███████╗██████╗ 46 | ████╗ ████║██║████╗ ██║██╔════╝██╔══██╗ 47 | ██╔████╔██║██║██╔██╗ ██║█████╗ ██████╔╝ 48 | ██║╚██╔╝██║██║██║╚██╗██║██╔══╝ ██╔══██╗ 49 | ██║ ╚═╝ ██║██║██║ ╚████║███████╗██║ ██║ 50 | ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ 51 | ''' 52 | 53 | mmdrza = ''' 54 | |======================================================| 55 | |=========== ╔╦╗╔╦╗╔╦╗╦═╗╔═╗╔═╗ ╔═╗╔═╗╔╦╗ ============| 56 | |=========== ║║║║║║ ║║╠╦╝╔═╝╠═╣ ║ ║ ║║║║ ============| 57 | |=========== ╩ ╩╩ ╩═╩╝╩╚═╚═╝╩ ╩o╚═╝╚═╝╩ ╩ ============| 58 | |------------------------------------------------------| 59 | |- WebSite ------------------------------- Mmdrza.Com -| 60 | |- MAIL ---------------------------- X4@Mmdrza.Com -| 61 | |- DEV ---------------------------- DEV.to/Mmdrza -| 62 | |- GiTHUB ---------------------- Github.Com/PyMmdrza -| 63 | |- MEDIUM -------------- PythonWithMmdrza.Medium.Com -| 64 | |======================================================| 65 | ''' 66 | def delay_print(s): 67 | for c in s: 68 | sys.stdout.write(c) 69 | sys.stdout.flush() 70 | time.sleep(0.1) 71 | 72 | print(Fore.RED,soloxminer) 73 | print(Fore.YELLOW,mmdrza) 74 | cHeight = 0 75 | inpAdd = input('[*] INSERT HERE YOUR ADDRESS BITCOIN WALLET For Withdrawal : ') 76 | address = str(inpAdd) 77 | print(Fore.YELLOW,'\nBitcoin Wallet Address ===>> ',Fore.GREEN,str(address)) 78 | print(Fore.MAGENTA,'\n------------------------------------------------------------------------------',Style.RESET_ALL) 79 | delay_print(' Your Bitcoin Wallet Address Added For Mining Now ...') 80 | print(Fore.MAGENTA,'\n------------------------------------------------------------------------------',Style.RESET_ALL) 81 | 82 | time.sleep(3) 83 | def logg(msg): 84 | logging.basicConfig(level=logging.INFO, filename="miner.log", format='%(asctime)s %(message)s') # include timestamp 85 | logging.info(msg) 86 | 87 | def get_current_block_height(): 88 | # Returns the current network best height 89 | r = requests.get('https://blockchain.info/latestblock') 90 | return int(r.json()['height']) 91 | 92 | def newBlockListener(): 93 | global cHeight 94 | 95 | while True: 96 | network_height = get_current_block_height() 97 | 98 | if network_height > cHeight: 99 | logg('[*] Network has new height %d ' % network_height) 100 | logg('[*] Our local is %d' % cHeight) 101 | cHeight = network_height 102 | logg('[*] Our new local after update is %d' % cHeight) 103 | 104 | # respect Api 105 | time.sleep(40) 106 | 107 | 108 | def BitcoinMiner(restart=False): 109 | if restart: 110 | time.sleep(2) 111 | logg('[*] Bitcoin Miner Restarted') 112 | else: 113 | logg('[*] Bitcoin Miner Started') 114 | print('[*] Bitcoin Miner Started') 115 | 116 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 117 | sock.connect(('solo.ckpool.org', 3333)) 118 | 119 | sock.sendall(b'{"id": 1, "method": "mining.subscribe", "params": []}\n') 120 | 121 | lines = sock.recv(1024).decode().split('\n') 122 | 123 | response = json.loads(lines[0]) 124 | sub_details, extranonce1, extranonce2_size = response['result'] 125 | 126 | sock.sendall(b'{"params": ["' + address.encode() + b'", "password"], "id": 2, "method": "mining.authorize"}\n') 127 | 128 | response = b'' 129 | while response.count(b'\n') < 4 and not (b'mining.notify' in response): response += sock.recv(1024) 130 | 131 | responses = [json.loads(res) for res in response.decode().split('\n') if 132 | len(res.strip()) > 0 and 'mining.notify' in res] 133 | job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs = responses[0]['params'] 134 | target = (nbits[2:] + '00' * (int(nbits[:2], 16) - 3)).zfill(64) 135 | extranonce2 = hex(random.randint(0, 2 ** 32 - 1))[2:].zfill(2 * extranonce2_size) # create random 136 | 137 | coinbase = coinb1 + extranonce1 + extranonce2 + coinb2 138 | coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest() 139 | 140 | merkle_root = coinbase_hash_bin 141 | for h in merkle_branch: 142 | merkle_root = hashlib.sha256(hashlib.sha256(merkle_root + binascii.unhexlify(h)).digest()).digest() 143 | 144 | merkle_root = binascii.hexlify(merkle_root).decode() 145 | 146 | merkle_root = ''.join([merkle_root[i] + merkle_root[i + 1] for i in range(0, len(merkle_root), 2)][::-1]) 147 | 148 | work_on = get_current_block_height() 149 | print(Fore.GREEN, 'Working on current Network height',Fore.WHITE, work_on) 150 | print(Fore.YELLOW,'Current TARGET =', Fore.RED, target) 151 | z = 0 152 | while True: 153 | if cHeight > work_on: 154 | logg('[*] Restarting Miner') 155 | BitcoinMiner(restart=True) 156 | break 157 | 158 | nonce = hex(random.randint(0, 2 ** 32 - 1))[2:].zfill(8) # nnonve #hex(int(nonce,16)+1)[2:] 159 | blockheader = version + prevhash + merkle_root + nbits + ntime + nonce + \ 160 | '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000' 161 | hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(blockheader)).digest()).digest() 162 | hash = binascii.hexlify(hash).decode() 163 | 164 | if hash.startswith('000000000000000000000'): logg('hash: {}'.format(hash)) 165 | print(Fore.GREEN,str(z),' HASH :', Fore.YELLOW,' 000000000000000000000{}'.format(hash), end='\r') 166 | z += 1 167 | if hash.startswith('000000000000000000'): logg('hash: {}'.format(hash)) 168 | z += 1 169 | 170 | print(Fore.YELLOW,str(z), 'HASH :', Fore.RED,' 000000000000000000{}'.format(hash), end='\r') 171 | z += 1 172 | 173 | if hash.startswith('000000000000000'): logg('hash: {}'.format(hash)) 174 | print(Fore.BLUE,str(z), 'HASH :', Fore.GREEN,' 000000000000000{}'.format(hash), end='\r') 175 | z += 1 176 | 177 | if hash.startswith('000000000000'): logg('hash: {}'.format(hash)) 178 | print(Fore.MAGENTA,str(z),'HASH :', Fore.YELLOW,' 000000000000{}'.format(hash), end='\r') 179 | z += 1 180 | 181 | if hash.startswith('0000000'): logg('hash: {}'.format(hash)) 182 | print(Fore.CYAN,str(z),'HASH :', Fore.YELLOW,'0000000{}'.format(hash), end='\r') 183 | z += 1 184 | 185 | 186 | if hash < target: 187 | print('[*] New block mined') 188 | logg('[*] success!!') 189 | logg(blockheader) 190 | logg('hash: {}'.format(hash)) 191 | 192 | payload = bytes('{"params": ["' + address + '", "' + job_id + '", "' + extranonce2 \ 193 | + '", "' + ntime + '", "' + nonce + '"], "id": 1, "method": "mining.submit"}\n', 'utf-8') 194 | sock.sendall(payload) 195 | logg(payload) 196 | ret = sock.recv(1024) 197 | logg(ret) 198 | 199 | return True 200 | 201 | 202 | if __name__ == '__main__': 203 | Thread(target=newBlockListener).start() 204 | time.sleep(2) 205 | Thread(target=BitcoinMiner).start() 206 | -------------------------------------------------------------------------------- /SoloMinerPost.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pymmdrza/SoloMiner/5befa063cd0c65ae71bffcfa0becefc91b824b44/SoloMinerPost.jpg -------------------------------------------------------------------------------- /Solominer_v2.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import hashlib 3 | import binascii 4 | import json 5 | import random 6 | import socket 7 | import time 8 | from threading import Thread 9 | from colorthon import Colors as Fore 10 | import sys, logging 11 | 12 | # Define your Bitcoin address 13 | address = "1MMDRZAcM6dzmdMUSV8pDdAPDFpwzve9Fc" 14 | # Initialize the current block height 15 | cHeight = 0 16 | soloxminer = ''' 17 | ███████╗ ██████╗ ██╗ ██████╗ 18 | ██╔════╝██╔═══██╗██║ ██╔═══██╗ 19 | ███████╗██║ ██║██║ ██║ ██║ 20 | ╚════██║██║ ██║██║ ██║ ██║ 21 | ███████║╚██████╔╝███████╗╚██████╔╝ 22 | ╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ 23 | 24 | ███╗ ███╗██╗███╗ ██╗███████╗██████╗ 25 | ████╗ ████║██║████╗ ██║██╔════╝██╔══██╗ 26 | ██╔████╔██║██║██╔██╗ ██║█████╗ ██████╔╝ 27 | ██║╚██╔╝██║██║██║╚██╗██║██╔══╝ ██╔══██╗ 28 | ██║ ╚═╝ ██║██║██║ ╚████║███████╗██║ ██║ 29 | ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ 30 | ''' 31 | 32 | mmdrza = ''' 33 | |======================================================| 34 | |=========== ╔╦╗╔╦╗╔╦╗╦═╗╔═╗╔═╗ ╔═╗╔═╗╔╦╗ ============| 35 | |=========== ║║║║║║ ║║╠╦╝╔═╝╠═╣ ║ ║ ║║║║ ============| 36 | |=========== ╩ ╩╩ ╩═╩╝╩╚═╚═╝╩ ╩o╚═╝╚═╝╩ ╩ ============| 37 | |------------------------------------------------------| 38 | |- WebSite ------------------------------- Mmdrza.Com -| 39 | |- GiTHUB ---------------------- Github.Com/PyMmdrza -| 40 | |- MEDIUM -------------- PythonWithMmdrza.Medium.Com -| 41 | |======================================================| 42 | ''' 43 | 44 | 45 | def delay_print(s): 46 | for c in s: 47 | sys.stdout.write(c) 48 | sys.stdout.flush() 49 | time.sleep(0.1) 50 | 51 | 52 | print(Fore.RED, soloxminer, Fore.RESET) 53 | print(Fore.YELLOW, mmdrza, Fore.RESET) 54 | cHeight = 0 55 | inpAdd = input( 56 | f'{Fore.MAGENTA}[*]{Fore.RESET}{Fore.WHITE} INSERT HERE YOUR ADDRESS BITCOIN WALLET For Withdrawal{Fore.RESET} : ') 57 | address = str(inpAdd) 58 | print(f'\n{Fore.GREY}Bitcoin Wallet Address{Fore.RESET} ===>> {Fore.MAGENTA}{address}{Fore.RESET}') 59 | print(f"{Fore.GREY}{'-' * 66}{Fore.RESET}") 60 | delay_print(' Your Bitcoin Wallet Address Added For Mining Now ...') 61 | print(f"\n{Fore.GREY}{'-' * 66}{Fore.RESET}") 62 | 63 | time.sleep(3) 64 | 65 | 66 | def logg(msg): 67 | logging.basicConfig(level=logging.INFO, filename="miner.log", format='%(asctime)s %(message)s') # include timestamp 68 | logging.info(msg) 69 | 70 | 71 | # Function to get the current network block height 72 | def get_current_block_height(): 73 | r = requests.get('https://blockchain.info/latestblock') 74 | return int(r.json()['height']) 75 | 76 | 77 | # Function for the mining process 78 | def BitcoinMiner(restart=False): 79 | # Function to handle the mining process 80 | 81 | if restart: 82 | time.sleep(2) 83 | logg('[*] Bitcoin Miner Restarted') 84 | else: 85 | logg('[*] Bitcoin Miner Started') 86 | print('[*] Bitcoin Miner Started') 87 | 88 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 89 | sock.connect(('solo.ckpool.org', 3333)) 90 | 91 | sock.sendall(b'{"id": 1, "method": "mining.subscribe", "params": []}\n') 92 | 93 | lines = sock.recv(1024).decode().split('\n') 94 | 95 | response = json.loads(lines[0]) 96 | sub_details, extranonce1, extranonce2_size = response['result'] 97 | 98 | sock.sendall(b'{"params": ["' + address.encode() + b'", "password"], "id": 2, "method": "mining.authorize"}\n') 99 | 100 | response = b'' 101 | while response.count(b'\n') < 4 and not (b'mining.notify' in response): response += sock.recv(1024) 102 | 103 | responses = [json.loads(res) for res in response.decode().split('\n') if 104 | len(res.strip()) > 0 and 'mining.notify' in res] 105 | job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs = responses[0]['params'] 106 | target = (nbits[2:] + '00' * (int(nbits[:2], 16) - 3)).zfill(64) 107 | extranonce2 = hex(random.randint(0, 2 ** 32 - 1))[2:].zfill(2 * extranonce2_size) # create random 108 | 109 | coinbase = coinb1 + extranonce1 + extranonce2 + coinb2 110 | coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest() 111 | 112 | merkle_root = coinbase_hash_bin 113 | for h in merkle_branch: 114 | merkle_root = hashlib.sha256(hashlib.sha256(merkle_root + binascii.unhexlify(h)).digest()).digest() 115 | 116 | merkle_root = binascii.hexlify(merkle_root).decode() 117 | 118 | merkle_root = ''.join([merkle_root[i] + merkle_root[i + 1] for i in range(0, len(merkle_root), 2)][::-1]) 119 | 120 | work_on = get_current_block_height() 121 | print(Fore.GREEN, 'Working on current Network height', Fore.WHITE, work_on) 122 | print(Fore.YELLOW, 'Current TARGET =', Fore.RED, target) 123 | z = 0 124 | while True: 125 | if cHeight > work_on: 126 | logg('[*] Restarting Miner') 127 | BitcoinMiner(restart=True) 128 | break 129 | 130 | nonce = hex(random.randint(0, 2 ** 32 - 1))[2:].zfill(8) # nnonve #hex(int(nonce,16)+1)[2:] 131 | blockheader = version + prevhash + merkle_root + nbits + ntime + nonce + \ 132 | '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000' 133 | hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(blockheader)).digest()).digest() 134 | hash = binascii.hexlify(hash).decode() 135 | 136 | if hash.startswith('000000000000000000000'): logg('hash: {}'.format(hash)) 137 | print(Fore.GREEN, str(z), ' HASH :', Fore.YELLOW, ' 000000000000000000000{}'.format(hash), end='\r') 138 | z += 1 139 | if hash.startswith('000000000000000000'): logg('hash: {}'.format(hash)) 140 | z += 1 141 | 142 | print(Fore.YELLOW, str(z), 'HASH :', Fore.RED, ' 000000000000000000{}'.format(hash), end='\r') 143 | z += 1 144 | 145 | if hash.startswith('000000000000000'): logg('hash: {}'.format(hash)) 146 | print(Fore.BLUE, str(z), 'HASH :', Fore.GREEN, ' 000000000000000{}'.format(hash), end='\r') 147 | z += 1 148 | 149 | if hash.startswith('000000000000'): logg('hash: {}'.format(hash)) 150 | print(Fore.MAGENTA, str(z), 'HASH :', Fore.YELLOW, ' 000000000000{}'.format(hash), end='\r') 151 | z += 1 152 | 153 | if hash.startswith('0000000'): logg('hash: {}'.format(hash)) 154 | print(Fore.CYAN, str(z), 'HASH :', Fore.YELLOW, '0000000{}'.format(hash), end='\r') 155 | z += 1 156 | 157 | if hash < target: 158 | print('[*] New block mined') 159 | logg('[*] success!!') 160 | logg(blockheader) 161 | logg('hash: {}'.format(hash)) 162 | 163 | payload = bytes( 164 | '{"params": ["' + address + '", "' + job_id + '", "' + extranonce2 \ 165 | + '", "' + ntime + '", "' + nonce + '"], "id": 1, "method": "mining.submit"}\n', 'utf-8') 166 | sock.sendall(payload) 167 | logg(payload) 168 | ret = sock.recv(1024) 169 | logg(ret) 170 | 171 | return True 172 | 173 | 174 | # Function to listen for new blocks 175 | def newBlockListener(): 176 | global cHeight 177 | 178 | while True: 179 | network_height = get_current_block_height() 180 | 181 | if network_height > cHeight: 182 | logg('[*] Network has new height %d ' % network_height) 183 | logg('[*] Our local is %d' % cHeight) 184 | cHeight = network_height 185 | logg('[*] Our new local after update is %d' % cHeight) 186 | 187 | # respect Api 188 | time.sleep(40) 189 | 190 | 191 | # Main function to start the miner and block listener 192 | if __name__ == '__main__': 193 | # Start the block listener and miner threads 194 | Thread(target=newBlockListener).start() 195 | time.sleep(2) 196 | Thread(target=BitcoinMiner).start() 197 | -------------------------------------------------------------------------------- /SoloxMiner.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pymmdrza/SoloMiner/5befa063cd0c65ae71bffcfa0becefc91b824b44/SoloxMiner.PNG -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker --------------------------------------------------------------------------------