Long story short my 12 word seed phrase has a passphrase and I forgot the order.

So I did all the permutations of the 12 words to find the valid ones (29939407). So the script below is my way of adding the passphrase and then getting all the legacy addresses.

However, I'm not sure if it's my computer but so far the script I have has only written 3.5 million addresses and it has been running for 12 hours! So I was wondering if anyone could recommend any ways to speed up this script?

from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip84, Bip84Coins, Bip44Changes, Bip44, Bip44Coins

mnemonics_filename = open ('sats.txt')
address_filename = open('sats-address.txt')

mnemonics = open(mnemonics_filename, 'r')
address = open(address_filename, 'w+')

for mnemonic in mnemonics:
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate("satsenchanter")
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    for i in range(1):
        bip44_addr_ctx = bip44_chg_ctx.AddressIndex(i)
  • 1
    Rewriting it in C (or other compiled language) would probably make a worthwhile difference. Aug 17 at 14:24
  • What is the information you have, if you compare the result form 12 word seed phrase permutation plus passphrase. With public key instead of address, I'll be faster. And the most important thing is that Python can't utilize the full capacity of your CPU because it can't handle the Global Interpreter Lock (GIL). The script made from pure Python can only use 1 core, whereas another language like C or Rust can create a multiprocess script. Using those languages can increase the speed up to 10-30 times faster than Python.
    – Romo
    Aug 18 at 4:50
  • However, waiting for 12 hours is not too long when you consider it in contrast to learning a new language without any foundational knowledge.
    – Romo
    Aug 18 at 5:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.