edit this code so instead of usin blockchain.info api it actually uses the bitcoinlib…
- User
edit this code so instead of usin blockchain.info api it actually uses the bitcoinlib library to check the balance.
from mnemonic import Mnemonic import bip32utils import requests import sys import random import re
mnemo = Mnemonic("english")
target=[ ['xxxx'], # word on plate is "like" ??? ['muscle'], # word on plate is "love" ??? ['xxxx'], # word is "king" ['shaft'], # word is "place" ['task'], # word on plate is "closet" ??? ['xxxx'], # word on plate is "repel" ['nut'], # word on plate is "pear" ['xxxx'], # word on plate is "lizard" ??? ['fault'], # word on plate is covered up ['list'], # word on plate is "fast" ['xxxx'], # word on plate is "fast" ['excess'], # word on plate is "fast" ]
allwords=[] for line in open('bip39.txt'): allwords.append(line.strip())
target[0]=allwords target[2]=allwords target[5]=list(filter(re.compile('^p').match, allwords)) target[7]=list(filter(re.compile('^[pygjq].{4,}').match, allwords)) target[10]=list(filter(re.compile('^[fhiklmnrvwx]').match, allwords))
keyspace = 1 print(len(target)) for i in range(0,len(target)): keyspace *= len(target[i])
print ("keyspace size is %i (%i bits)" % (keyspace, len(bin(keyspace))-2))
starting = random.randint(0,keyspace) #starting = 0 # for when you're all alone
for x in range(starting,keyspace): # know your limits mystring="" eol=0
if x%10000 == 0: sys.stderr.write(str('{:3.10f}'.format(x/keyspace*100))+"% complete\n") #sys.stderr.write("keyspace size is %i (%i bits)\n" % (keyspace, len(bin(keyspace))-2))
codesys.stderr.flush()remaining=x for word in range(0,len(target)): choice = int(remaining%len(target[word])) mystring+=target[word][choice]+' '
codeif(choice == len(target[word])-1 ): # okay, we're at the end of this word placement eol+=1 remaining=remaining/len(target[word])uncomment for debug to ensure proper mnemo
print(mystring.strip())
try: win = mnemo.check(mystring.strip()) if win: print(mystring) # print the winnings seed = mnemo.to_seed(mystring.strip(),"") bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed)
code - Assistant