Author

Topic: fastest way to get bip44/bip49 addresses from seed phrase! (Read 182 times)

newbie
Activity: 9
Merit: 5
thank you sooooo much! i really appreciate you!

Minor Improvement to take File opening outside the function

Code:
from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins
from multiprocessing import Pool, cpu_count

arq = open('addresses_bip44.txt', 'a')
arp = open('addresses_bip49.txt', 'a')

def generatemenemonic(listofmenmonic):
       
    mnemonic = listofmenmonic
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
    bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
    bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
    arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
    arp.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())


if __name__ == "__main__":
    listofmenmonic = []   
    with open('x.txt') as f:
        for line in f:
            mnemonic = line.strip()
            listofmenmonic.append(mnemonic)
           
    cpustotal = cpu_count()-1
    pool = Pool(cpustotal)
    print("Starting Address Generator on " +str(cpustotal)+ " CPU's")
    results = pool.map(generatemenemonic, listofmenmonic)
    pool.close()
    pool.join()
newbie
Activity: 5
Merit: 0
Minor Improvement to take File opening outside the function

Code:
from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins
from multiprocessing import Pool, cpu_count

arq = open('addresses_bip44.txt', 'a')
arp = open('addresses_bip49.txt', 'a')

def generatemenemonic(listofmenmonic):
       
    mnemonic = listofmenmonic
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
    bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
    bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
    arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
    arp.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())


if __name__ == "__main__":
    listofmenmonic = []   
    with open('x.txt') as f:
        for line in f:
            mnemonic = line.strip()
            listofmenmonic.append(mnemonic)
           
    cpustotal = cpu_count()-1
    pool = Pool(cpustotal)
    print("Starting Address Generator on " +str(cpustotal)+ " CPU's")
    results = pool.map(generatemenemonic, listofmenmonic)
    pool.close()
    pool.join()
newbie
Activity: 5
Merit: 0
Here is tweaked code below

its depend on the number of CPU your processor have

if your processor have 5 CPU it will use 4 i.e cpustotal = cpu_count()-1

if you want to use all available cpu you can change it to cpustotal = cpu_count()

Code:

from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins
from multiprocessing import Pool, cpu_count

def generatemenemonic(listofmenmonic):
    arq = open('addresses.txt', 'a')        
    mnemonic = listofmenmonic
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
    bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
    bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
    arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
    arq.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())


if __name__ == "__main__":
    listofmenmonic = []  
    with open('x.txt') as f:
        for line in f:
            mnemonic = line.strip()
            listofmenmonic.append(mnemonic)
            
    cpustotal = cpu_count()-1
    pool = Pool(cpustotal)
    print("Starting Address Generator on " +str(cpustotal)+ " CPU's")
    results = pool.map(generatemenemonic, listofmenmonic)
    pool.close()
    pool.join()



I want to make a note here one seed can have thousands of addresses as well which called Derivation paths address generation

let me add that code as well incase you want something like that

right now below code will get 30 address but you can change this line for i in range(30): to get more change 30 to 1000 may be

Code:

from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins
from multiprocessing import Pool, cpu_count

def generatemenemonic(listofmenmonic):    
        
    mnemonic = listofmenmonic
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
    bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    #bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
    #bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
    #arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
    #arq.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())
    tempaddr = []
    for i in range(30):
        bip44_addr_ctx = bip44_chg_ctx.AddressIndex(i)
        bip49_addr_ctx = bip49_chg_ctx.AddressIndex(i)
        bip44addr = bip44_addr_ctx.PublicKey().ToAddress()
        bip49addr = bip49_addr_ctx.PublicKey().ToAddress()
        tempaddr.append(bip44addr)
        tempaddr.append(bip49addr)
    with open('addresses.txt', 'a') as f:
        for line in tempaddr:
            f.write(f"{line}\n")


if __name__ == "__main__":
    listofmenmonic = []  
    with open('x.txt') as f:
        for line in f:
            mnemonic = line.strip()
            listofmenmonic.append(mnemonic)
            
    cpustotal = cpu_count()-1
    pool = Pool(cpustotal)
    print("Starting Address Generator on " +str(cpustotal)+ " CPU's")
    results = pool.map(generatemenemonic, listofmenmonic)
    pool.close()
    pool.join()



If you want your to get separate files for both bip44 and bip49 then code is below


Code:

from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins
from multiprocessing import Pool, cpu_count

def generatemenemonic(listofmenmonic):
    arq = open('addresses_bip44.txt', 'a')
    arp = open('addresses_bip49.txt', 'a')    
    mnemonic = listofmenmonic
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
    bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
    bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
    bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
    arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
    arp.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())


if __name__ == "__main__":
    listofmenmonic = []  
    with open('x.txt') as f:
        for line in f:
            mnemonic = line.strip()
            listofmenmonic.append(mnemonic)
            
    cpustotal = cpu_count()-1
    pool = Pool(cpustotal)
    print("Starting Address Generator on " +str(cpustotal)+ " CPU's")
    results = pool.map(generatemenemonic, listofmenmonic)
    pool.close()
    pool.join()



There is one more thing that we can add to code i.e compress and uncompressed addresses ( lemme know if u want to add that)

Also there is a built-in mnemonic lib for python as well if you want to generate random mnemonic

message me for that if you need to learn

cheers !





newbie
Activity: 9
Merit: 5
share your python code
I can tweak it and add multiprocessing to make it fast and other tweaks if possible also customize it for required seed


Code:
from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, Bip49, Bip49Coins, Bip44, Bip44Coins

arq = open('addresses.txt', 'a')
with open('x.txt') as f:
for line in f:
mnemonic = line.strip()
seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
bip49_mst_ctx = Bip49.FromSeed(seed_bytes, Bip49Coins.BITCOIN)
bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)
bip49_acc_ctx = bip49_mst_ctx.Purpose().Coin().Account(0)
bip49_chg_ctx = bip49_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)
bip49_addr_ctx = bip49_chg_ctx.AddressIndex(0)
arq.write("%s \n" % bip44_addr_ctx.PublicKey().ToAddress())
arq.write("%s \n" % bip49_addr_ctx.PublicKey().ToAddress())
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
share your python code
I can tweak it and add multiprocessing to make it fast and other tweaks if possible also customize it for required seed

BTCrecover already has multi-cpu code inside it - there is no need to waste time adding your own. Also it includes GPU support which will be better for the OP than multiple CPUs because the recovery will then be several hundreds of times faster.

It is not particularly a good idea to use different libraries for recovering seeds if BTCrecover can do it the fastest.
newbie
Activity: 5
Merit: 0
share your python code
I can tweak it and add multiprocessing to make it fast and other tweaks if possible also customize it for required seed

legendary
Activity: 2268
Merit: 18771
Agree with ETFbitcoin - use btcrecover.

If your address is BIP44 then it should start with "1", and if it's BIP49 then it should start with "3". If you don't know the address at all then you'll need to use an address database to check against: https://btcrecover.readthedocs.io/en/latest/Creating_and_Using_AddressDB/

If you have already calculated all the possible valid seed phrases from your words, then you can use the --seedlist command to avoid having btcrecover calculate them all again: https://btcrecover.readthedocs.io/en/latest/BIP39_descrambling_seedlists/#seedlists
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Short answer, just use btcrecover[1] which have multi CPU and GPU support. Based on comment on it's source code, it's definitely support BIP 44 and 49[2]. If you need specific path, you can use parameter --bip32-path as well[3].

[1] https://btcrecover.readthedocs.io/
[2] https://github.com/3rdIteration/btcrecover/blob/master/btcrecover/btcrseed.py#L718-L720
[3] https://github.com/3rdIteration/btcrecover/blob/master/btcrecover/btcrseed.py#L3149
newbie
Activity: 9
Merit: 5
Long story short, I have my seed phrase (12 words) out of order, with a few additional words in addition to me not being sure about the address (not sure if it's a bip44 or bip49). I figured one way to make things easier was to get all of the valid seed phrases from permutations/combinations. Now I've got all of them however my issue is that the python script I have is taking forever to get the addresses from the seed phrase( for example a descrambled seed gets about 29 million valid ones and its takes a little over 24 hours to complete. I've tested all of the bitcoin python libraries to see which one was the fastest (bip_utils). Is there any way to speed up that process, or anyone know of a superfast program to help me out?

Jump to: