Skip to content

Instantly share code, notes, and snippets.

@llazzaro
Created July 16, 2021 20:25
Show Gist options
  • Save llazzaro/7ac7977040c1bcfe439186ce8beee65a to your computer and use it in GitHub Desktop.
Save llazzaro/7ac7977040c1bcfe439186ce8beee65a to your computer and use it in GitHub Desktop.
Recover bitcoin from seeds
import sys
import tempfile
from pybloom_live import ScalableBloomFilter
try:
from electrum import SimpleConfig
from electrum.keystore import from_seed
from electrum.tests.test_wallet_vertical import WalletIntegrityHelper
from electrum.util import BitcoinException
from tqdm import tqdm
except ImportError:
print('Missing deps, intall with: pip install electrum tqdm')
print('pip install git+https://github.com/joseph-fox/python-bloomfilter')
sys.exit(1)
# bip39 words
# https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt
def try_words(word1, word2):
try:
keystore = from_seed(f'wild father tree among universe such mobile favorite target dynamic {word1} {word2}', passphrase=None)
#print(keystore.get)
config = SimpleConfig({'electrum_path': tempfile.mkdtemp()})
wallet = WalletIntegrityHelper.create_standard_wallet(keystore, config=config)
return wallet.get_addresses()
except BitcoinException:
pass
def check_balance(bloomfilter, addresses):
print(addresses)
if __name__ == '__main__':
# text.txt has the bloom filter
with open('/User/you/text.txt', 'r') as fh:
sbf_from_file = ScalableBloomFilter.fromfile(fh)
with open('english.txt') as english_file:
words = english_file.readlines()
for word1 in tqdm(words):
for word2 in words:
addresses = try_words(word1, word2)
if addresses:
check_balance(sbf_from_file, addresses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment