Automate Bip39 seed restoration – Bitcoin Stack Alternate

0
69


Increasing off of this reply (utilizing python) from the associated query you linked to we are able to begin to slender down the listing of prospects.

Begin off along with your ordered listing of recognized phrases:

ordered_known_words = [
    'glory',
    'twice',
    'film',
    'near',
    'senior',
    'trust',
    'thunder',
    'endorse',
    'suggest',
    'scheme',
    'habit',
    'limit',
    'slow',
    'yard',
    'clog',
    'attend',
    'axis',
    'enough',
    'only',
    'magic',
    'hair',
    'rule',
    'zone',
]

First, generate a phrase sample for every potential place of your lacking phrase:

def generate_phrase_patterns(ordered_known_words, mnemonic_length=24):
    list_of_patterns = []

    for i in vary(0, mnemonic_length):
        list_template = ['{x}'] * mnemonic_length
        word_position = 0

        for place, known_word in enumerate(ordered_known_words):
            if i <= place:
                list_template[position + 1] = known_word
            else:
                list_template[position] = known_word
            word_position += 1

        list_of_patterns.append(', '.be a part of(list_template))

    return list_of_patterns

This may a listing of lists yield one thing like the next:

{x}, glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, {x}, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, {x}, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, {x}, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, {x}, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, {x}, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, {x}, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, {x}, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, {x}, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, {x}, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, {x}, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, {x}, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, {x}, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, {x}, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, {x}, clog, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, {x}, attend, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, {x}, axis, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, {x}, sufficient, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, {x}, solely, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, {x}, magic, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, {x}, hair, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, {x}, rule, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, {x}, zone
glory, twice, movie, close to, senior, belief, thunder, endorse, recommend, scheme, behavior, restrict, gradual, yard, clog, attend, axis, sufficient, solely, magic, hair, rule, zone, {x}

Now, feed this into the code from this reply on the associated query you linked to generate a listing of all potential phrases:

def generate_all_valid_phrases(phrase_patterns):
    from btctools.HD import test, WORDS
    total_phrases = []
    for sample in phrase_patterns:
        for phrase in WORDS:
            mnemonic = sample.format(x=phrase)
            if test(mnemonic):
                total_phrases.append(mnemonic)
    return total_phrases

At this level we now have 180 legitimate 24 phrase mnemonic phrases, certainly one of which incorporates your coin.

When you might manually test all of those that will be a tedious activity. As mentioned in m1xolyd1an’s reply, if one of many deal with’ beforehand used, we are able to use every of those mnemonic phrases to generate the primary 5 or so deterministic addresses
produced by every phrase and carry out a comparisson to test for an deal with match.

from btctools import Xprv
import json

master_address_list = []

for phrase in total_phrases:

    m = Xprv.from_mnemonic(phrase)

    # test first few deal with areas for a recognized match
    for i in vary(0, 5):
        addr = (m/44./0./0./0/i).deal with('P2PKH')
        if addr == '1C26mdyEsNpe4fpkYtuHzH4Y378wez8mxP':
            master_address_list.append({addr: phrase})
        elif addr == '1BjoCJhvRCx9nVLPaKhg4qQ2YYps8mDgY4':
            master_address_list.append({addr: phrase})


print(f'Deal with match(s) discovered: ', len(master_address_list))
print(json.dumps(master_address_list, indent=4, sort_keys=True))

If any deal with matches are discovered this can print them as key worth pairs:

{
    "<deal with>": "<mnemonic phrase>"
}

Listed here are two python scripts utilizing incorporating the above logic in numerous methods:

LEAVE A REPLY

Please enter your comment!
Please enter your name here