Code Monkey home page Code Monkey logo

brainwallet-check's Issues

Not valid bitcoin address

Hi man, thanks for script. But i have a small problem. Your code generate not valid bitcoin address. Not all time but sometimes. I modified your code and in the request I have 200 addresses. and periodically I get 500 response from the server. when I entered the list of addresses obtained by generating your code some addresses are not correct. can you help deal with this?

#!/usr/bin/python
import os
import sys, getopt
import ecdsa
import urllib2
import binascii, hashlib
import requests
import subprocess
from itertools import islice

secp256k1curve=ecdsa.ellipticcurve.CurveFp(115792089237316195423570985008687907853269984665640564039457584007908834671663,0,7)
secp256k1point=ecdsa.ellipticcurve.Point(secp256k1curve,0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8,0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141)
secp256k1=ecdsa.curves.Curve('secp256k1',secp256k1curve,secp256k1point,(1,3,132,0,10))

def addy(pk):
pko=ecdsa.SigningKey.from_secret_exponent(pk,secp256k1)
pubkey=binascii.hexlify(pko.get_verifying_key().to_string())
pubkey2=hashlib.sha256(binascii.unhexlify('04'+pubkey)).hexdigest()
pubkey3=hashlib.new('ripemd160',binascii.unhexlify(pubkey2)).hexdigest()
pubkey4=hashlib.sha256(binascii.unhexlify('00'+pubkey3)).hexdigest()
pubkey5=hashlib.sha256(binascii.unhexlify(pubkey4)).hexdigest()
pubkey6=pubkey3+pubkey5[:8]
pubnum=int(pubkey6,16)
pubnumlist=[]
while pubnum!=0: pubnumlist.append(pubnum%58); pubnum/=58
address=''
for l in ['123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'[x] for x in pubnumlist]:
address=l+address
return '1'+address
if name == "main":
with open("1.txt") as ofile:
address_gen = ''
key_gen = ''
i = 0
b = 0
f = list(islice(ofile, 100))
for line in f:
linestrip = line.rstrip('\n')
privatekey = (int(hashlib.sha256(linestrip).hexdigest(),16))
privatekeysha = (hashlib.sha256(linestrip)).hexdigest()
bcaddy = addy(privatekey)
addr = bcaddy
keyr = privatekeysha
if i == 0:
i += 1
key_gen = key_gen + keyr
else:
key_gen = key_gen + '|' + keyr
if b == 0:
b += 1
address_gen = address_gen + addr
else:
address_gen = address_gen + '|' + addr
subprocess.Popen('sed -i 1,100d 1.txt', shell=True)
print address_gen
acc_bal = requests.get('https://blockchain.info/ru/multiaddr?active=' + address_gen)
print acc_bal

Python 2.7 to Python 3.x

Thank you very much for sharing your code, I really liked it and that is why I have taken the liberty to adapt it to python3.

Original:

pubkey2=hashlib.sha256(binascii.unhexlify('04'+pubkey)).hexdigest()
pubkey4=hashlib.sha256(binascii.unhexlify('00'+pubkey3)).hexdigest()

Final Code:

pubkey2=hashlib.sha256(binascii.unhexlify(b'04'+pubkey)).hexdigest()  # Encode as bytes
pubkey4=hashlib.sha256(binascii.unhexlify(b'00'+pubkey3.encode())).hexdigest()  # Encode '00' and pubkey3 as bytes

In the final version of the code, specific changes have been made to ensure that concatenation operations are carried out correctly. Here's the detailed explanation of the changes:

pubkey2 Encoding:

Originally, pubkey is a string of hexadecimal digits. To use it with the hashlib.sha256 function, you need to convert it into bytes. In the final version, a b is added before the string '04'+pubkey, indicating that it's bytes rather than a string.

pubkey4 Encoding:

Similarly, you need to convert '00'+pubkey3 into bytes before passing it to the hashlib.sha256 function. However, in this case, pubkey3 is a hexadecimal string, so you need to explicitly encode it using .encode(). Hence, b'00'+pubkey3.encode() is used.

Input String Encoding:

Also, in the main code block section, a line has been added to encode the input string (sys.argv[1]) into bytes using .encode('utf-8'). This is necessary to ensure that the input is handled properly in the hash operations. In the original version, the input was used directly, causing issues with hash operations in Python 3.

GET Request with urllib.request:

The part of the code that handles GET requests using urllib.request is well implemented and doesn't require any changes. This allows the script to retrieve information from blockchain.info.

These changes are made to ensure compatibility with Python 3 and to ensure that concatenation and manipulation of strings and bytes are done correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.