Skip to content

Rust script for generating Bitcoin addresses from mnemonic phrases, supporting multiple derivation paths and parallel processing.

License

Notifications You must be signed in to change notification settings

z1ph1us/btc-address-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Bitcoin Wallet Address Generator

This Rust script efficiently generates Bitcoin addresses from a list of mnemonic phrases. It supports multiple derivation paths (P2PKH, P2SH-P2WPKH, P2WPKH) and leverages multithreading to process large input files quickly.

Features

  • Multithreaded Processing: Utilizes all available CPU cores (or a specified number) for faster address generation.
  • Multiple Derivation Paths: Generates addresses for BIP44 (P2PKH / Legacy), BIP49 (P2SH-P2WPKH / Nested SegWit), and BIP84 (P2WPKH / Native SegWit / Bech32) standards.
  • Configurable Generation: Specify the number of addresses to generate per mnemonic and the number of accounts to derive.
  • Chunked File Reading: Processes large mnemonic files in memory-efficient chunks.
  • Mnemonic Caching: Avoids reprocessing duplicate mnemonics for improved performance.
  • Progress Tracking: Displays real-time progress, showing mnemonics processed and addresses generated.

How it Works

The script reads mnemonic phrases from an input file, by default mnemonics.txt. For each mnemonic, it derives a master extended private key and then generates Bitcoin addresses based on the specified derivation paths (BIP44, BIP49, BIP84). The generated addresses, along with their corresponding mnemonics, are written to an output file, by default addresses.txt.

To enhance performance, the script:

  • Uses rayon for parallel processing of mnemonic chunks.
  • Maintains a cache of already processed mnemonics to skip redundant computations.
  • Employs a buffered writer to minimize disk I/O operations.

Input File Format

The input file (e.g., mnemonics.txt) should contain one mnemonic phrase per line. The script expects these mnemonics to be BIP39-compliant.

  • Structure: Each line must contain a single mnemonic phrase, with words separated by spaces.
  • Word Count: Standard BIP39 mnemonics consist of 12, 15, 18, 21, or 24 words. The script is designed to process these lengths.
  • Languages: Any language supported by the BIP39 standard is supported. As long as the mnemonic adheres to one of the official BIP39 word lists and its words are correctly spaced, the script will generate addresses.
  • Whitespace: Leading or trailing whitespace on a line will be ignored. Empty lines will be skipped.

Example mnemonics.txt content with two 24 words mnemonics:

dash achieve brand thing collect trumpet man wealth enemy junior heart tragic sadness apart curve virus wisdom merry method scare cherry become reject license
agrume vorace narrer chambre codifier doyen rouleau client anormal nombreux infusion palper tétine sauvage costume calvaire secouer moelleux imposer tolérant copie opale élitisme inonder

Output File Format

The output file (e.g., addresses.txt) will contain each processed mnemonic followed by a tab (\t) and the generated Bitcoin address. Each mnemonic-address pair will be on its own line.

Example addresses.txt content (assuming default -n 1 -a 1):

dash achieve brand thing collect trumpet man wealth enemy junior heart tragic sadness apart curve virus wisdom merry method scare cherry become reject license    1YourLegacyAddressHere
dash achieve brand thing collect trumpet man wealth enemy junior heart tragic sadness apart curve virus wisdom merry method scare cherry become reject license    3YourNestedSegWitAddressHere
dash achieve brand thing collect trumpet man wealth enemy junior heart tragic sadness apart curve virus wisdom merry method scare cherry become reject license    bc1qYourNativeSegWitAddressHere
agrume vorace narrer chambre codifier doyen rouleau client anormal nombreux infusion palper tétine sauvage costume calvaire secouer moelleux imposer tolérant copie opale élitisme inonder    1AnotherLegacyAddressHere
agrume vorace narrer chambre codifier doyen rouleau client anormal nombreux infusion palper tétine sauvage costume calvaire secouer moelleux imposer tolérant copie opale élitisme inonder    3AnotherNestedSegWitAddressHere
agrume vorace narrer chambre codifier doyen rouleau client anormal nombreux infusion palper tétine sauvage costume calvaire secouer moelleux imposer tolérant copie opale élitisme inonder    bc1qAnotherNativeSegWitAddressHere

Installation

Prerequisites

  • Rust programming language: If you don't have Rust installed, you can install it by following the instructions on the official Rust website.

Building the Project

  1. Clone this repository:
    git clone https://github.com/z1ph1us/btc-address-generator.git
    cd btc-address-generator
  2. Build the project in release mode for optimized performance:
    cargo build --release

Usage

Run the script from your terminal:

./target/release/btc-address-generator -h

Options:

  • -i, --input <FILE>: Path to the input file containing mnemonic phrases (one per line).
    • Default: mnemonics.txt
  • -o, --output <FILE>: Path to the output file where generated addresses will be saved.
    • Default: addresses.txt
  • -n, --count <COUNT>: Number of addresses to generate per mnemonic for each derivation path and change type.
    • Default: 1
  • -a, --accounts <ACCOUNTS>: Number of accounts to derive for each mnemonic.
    • Default: 1
  • -c, --chunk-size <SIZE>: Number of mnemonics to process in each chunk.
    • Default: 10000
  • -t, --threads <THREADS>: Number of threads to use for parallel processing. Set to 0 to use all available CPU cores.
    • Default: 0
  • -b, --buffer-size <SIZE>: Size of the internal write buffer for the output file.
    • Default: 1000

Examples:

To generate 5 addresses for 2 accounts for each mnemonic from my_mnemonics.txt using all available threads, saving results to my_addresses.txt:

./target/release/wallet-generator -i my_mnemonics.txt -o my_addresses.txt -n 5 -a 2 -t 0

To use 4 threads with default address/account generation:

./target/release/wallet-generator -t 4

To process mnemonics in smaller chunks of 100 with a larger output buffer of 5000 lines:

./target/release/wallet-generator -c 100 -b 5000

Performance Notes:

  • -c, --chunk-size <SIZE>: Controls how many mnemonics are grouped for parallel processing. A small chunk size can introduce more overhead; a larger size generally keeps threads busy.
  • -b, --buffer-size <SIZE>: Manages how many generated addresses are held in memory before being written to the output file. A small buffer means more frequent, smaller disk writes (slower); a larger buffer means fewer, larger writes (faster, but uses more RAM).

Match crypto addresses

To match the generated addresses from this script with a list of funded addresses you can use this tool:

Support

If you found this project useful and would like to encourage me to create more tools like it, consider donating:

  • Bitcoin (BTC): bc1qg7xmlsdxfgu3muxherh4eee2ywj3gz8qfgct3s
  • Ethereum (ETH): 0x1B449E1D545bD0dc50f361d96706F6C904553929
  • Solana (SOL): F776tt1it7vifCzD9icrsby3ujkZdJ8EY9917GUM3skr
  • Tron (TRX): TJj96B4SukPJSC4M2FyssoxduVyviv9aGr
  • Polygon (POL): 0x1B449E1D545bD0dc50f361d96706F6C904553929
  • Monero (XMR): 48aaDb1g4Ms7PB3WMj6ttbMWuEwe171d6Yjao59uFJR38tHa75nKwPqYoPAYmWZPUhXmDbDvqtE6d2FX3YaF1dVE7zhD9Dt

Releases

No releases published

Packages

No packages published

Languages