jgilmour / brainwallet-check

Generates a bitcoin address and private key according to a 'brainwallet' string, then checks to see if the wallet is active
27 stars 32 forks source link

Not valid bitcoin address #2

Closed Nuc7ear closed 3 years ago

Nuc7ear commented 6 years ago

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