Created
October 19, 2023 19:37
-
-
Save russelldavies/d421b73c6ec5d48491b7090105635696 to your computer and use it in GitHub Desktop.
Sats Hunter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import multiprocessing | |
import itertools | |
from bip_utils import Bip39SeedGenerator, Bip44Changes, Bip84, Bip84Coins | |
from bip_utils.utils.mnemonic import MnemonicChecksumError | |
def validate_mnemonic(perm): | |
mnemonic = " ".join(perm) | |
return False | |
try: | |
Bip39SeedGenerator(mnemonic) | |
return mnemonic | |
except MnemonicChecksumError: | |
return "" | |
def find_key(target_address, seed_bytes): | |
seed_bytes = Bip39SeedGenerator(mnemonic).Generate() | |
bip84_mst_ctx = Bip84.FromSeed(seed_bytes, Bip84Coins.BITCOIN) | |
bip84_acc_ctx = bip84_mst_ctx.Purpose().Coin().Account(0) | |
bip84_chg_ctx = bip84_acc_ctx.Change(Bip44Changes.CHAIN_EXT) | |
for i in range(100): | |
bip84_addr_ctx = bip84_chg_ctx.AddressIndex(i) | |
if bip84_addr_ctx.PublicKey().ToAddress() == target_address: | |
return True | |
return False | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(prog="Sats Hunter") | |
parser.add_argument("target_address") | |
parser.add_argument("words") | |
args = parser.parse_args() | |
items = args.words.split() | |
with multiprocessing.Pool() as pool: | |
mnemonics = pool.imap_unordered(validate_mnemonic, itertools.permutations(items, len(items))) | |
for mnemonic in mnemonics: | |
if mnemonic and find_key(args.target_address, mnemonic): | |
print(mnemonic) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment