[![CI][ci-image]][ci-url]
# vanitygen-hd
Generate Bitcoin vanity address for Hierarchical Deterministic Wallet and Hierarchical Deterministic Multisig Wallet.  
## Quickstart
You can use [CLI](https://github.com/zealic/vanitygen-hd/releases) or [Docker Image](https://hub.docker.com/r/zealic/vanitygen-hd) to run this program.
### HD Wallet
HD Wallet generated vanity address path is `m/44'/0'/0'/0/0`.
Using Docker to run:
```shell
# CLI
vanitygen-hd generate HDD BTC 999 666
# Docker
docker run -it --rm --network=none zealic/vanitygen-hd generate HDD BTC 999 666
```
You will got below vanity address with prefix `HDD`:
```yaml
- address: 1HDDGgRFrtY38ZVVTtkgbBS4aUwE2rwUhz
  mnemonic: behave crack outer fine rude dwarf verb prosper because split loyal blue cream jar merge cupboard prize normal subway celery unfold alarm blue fetch
```
According to your CPU frequency and vanity address requirements, the time to generate mnemonic will gradually become longer. Generally, 3~4 length addresses are recommended.
### HDM Wallet
If you want generate HDM Wallet, use `--co-signers` and `--co-members`.  
Generated vanity address path is `m/45'/<CO_SIGNER_INDEX>/0/0`.
Prepare co-signers public keys file **co-signers.yml**:
```yaml
# Public key of co-signer-1, path is "m/45'/1"
- <KEY>
# Public key of co-signer-2, path is "m/45'/2"
- <KEY>
```
Generate with HDM wallet
```shell
# CLI
vanitygen-hd generate --co-signers=/co-signers.yml HDD BTC 999 666
# Docker
docker run -it --rm --network=none \
  -v $PWD/co-signers.yml:/co-signers.yml \
  zealic/vanitygen-hd \
  generate --co-signers=/co-signers.yml HDD BTC 999 666
```
Got vanity address, that public key path is "m/45'/0":
```yaml
- address: 3666kmVbsBF6K5Di8sUef1Qg9fp2wxFYxC
  parentAddress: 1LFsUUBtEg2PS8HALDi48fSUcjVcF6Htpg
  mnemonic: detail walnut stock this history ivory stamp leaf half marine inspire fitness erase apple flee bird length dizzy rubber open index print crystal boring
```
## Usage
```text
Usage: vanitygen-hd [options] [command]
Options:
  -V, --version                   output the version number
  -h, --help                      display help for command
Commands:
  generate [options] [rule-list]
    Options:
      -b, --bits <int>               BIP32 specifies the entropy length to be tween 128 and 256 bits and a multiple of 32 bits. (default: 256)
      -w, --workers <int>            Numeber of parallel worker, use 0 as CPU num. (default: 0)
      -s, --co-signers <yaml-file>   Co-signers YAML file, include m/45'/{1~n} public key array.
      -m, --co-members <int>         Co-signers member num, use 0 as 'MAX(1,LEN(co_signers))'. (default: 0)
      -t, --co-last-signer <bool>    Generated vanity address is last signer, public key path is : m/45'/{n}. (default: false)
      -f, --rules-file <rules-file>  One rule per line, allowing '#' to be a comment. (default: "rules.txt")
      -h, --help                     display help for command
  help [command]                  display help for command
```
## P2SH Address Limition
Because base58 address encoding with `0x05` heading, the second character of the P2SH address cannot be `STUVWXYZ` and `a-z`.
## Donate
Bitcoin: [`18mXNJyHdUSKfvQSrXCdQsuStp6eWFUVnh`][donate-url]
[![Donate Bitcoin][donate-image]][donate-url]
## License
[MIT](./LICENSE)
## References
* [vanitygen](https://github.com/samr7/vanitygen)
* [vanitygen-plus](https://github.com/exploitagency/vanitygen-plus)
* [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib)
* [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
* [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
* [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
* [BIP-45](https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki)
* [BIP-39 Tool : Mnemonic Code Converter](https://github.com/iancoleman/bip39)
* [P2PKH Graphical Address Generator](http://royalforkblog.github.io/2014/08/11/graphical-address-generator/)
[ci-image]:       https://github.com/zealic/vanitygen-hd/workflows/CI/badge.svg
[ci-url]:         https://github.com/zealic/vanitygen-hd/actions?query=workflow%3ACI
[donate-image]:   ./donate.png
[donate-url]:     https://www.blockchain.com/btc/address/18mXNJyHdUSKfvQSrXCdQsuStp6eWFUVnh