{"id":13462445,"url":"https://github.com/dan-da/hd-wallet-derive","last_synced_at":"2025-04-06T16:15:40.781Z","repository":{"id":49846960,"uuid":"99254457","full_name":"dan-da/hd-wallet-derive","owner":"dan-da","description":"A command-line tool that derives bip32 addresses and private keys.","archived":false,"fork":false,"pushed_at":"2023-11-06T04:32:53.000Z","size":495,"stargazers_count":230,"open_issues_count":17,"forks_count":82,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-30T15:09:06.624Z","etag":null,"topics":["altcoin","bch","bip32","bip38","bip39","bip44","bitcoin","bitwasp","cold-wallet","commandline","deriving-addresses","doge","ethereum","hdwallet","mnemonic","offline","paper-wallet","segwit"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-da.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-03T16:40:40.000Z","updated_at":"2025-03-01T23:48:02.000Z","dependencies_parsed_at":"2024-01-12T22:18:30.405Z","dependency_job_id":"3cf68a30-f08d-440a-a179-13afd5f0ccc3","html_url":"https://github.com/dan-da/hd-wallet-derive","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-derive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-derive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-derive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-derive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-da","download_url":"https://codeload.github.com/dan-da/hd-wallet-derive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509238,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["altcoin","bch","bip32","bip38","bip39","bip44","bitcoin","bitwasp","cold-wallet","commandline","deriving-addresses","doge","ethereum","hdwallet","mnemonic","offline","paper-wallet","segwit"],"created_at":"2024-07-31T12:00:47.849Z","updated_at":"2025-04-06T16:15:40.756Z","avatar_url":"https://github.com/dan-da.png","language":"PHP","funding_links":[],"categories":["Uncategorized","Tools and Services"],"sub_categories":["Uncategorized","Warning"],"readme":"**hd-wallet-derive is a command-line tool that derives bip32 addresses and private keys for Bitcoin and many altcoins. Derivation reports show privkey (wif encoded), xprv, xpub, and address.**\n\n**Table of Contents**\n=====================\n\n- [hd-wallet-derive](#hd-wallet-derive)\n- [Path Preset examples.](#path-preset-examples)\n  * [Obtaining a list of preset paths.](#obtaining-a-list-of-preset-paths)\n  * [Deriving addresses for bitcoin-core using preset path.](#deriving-addresses-for-bitcoin-core-using-preset-path)\n  * [Deriving Change addresses for bitcoin-core using preset path.](#deriving-change-addresses-for-bitcoin-core-using-preset-path)\n- [Custom Path examples.](#custom-path-examples)\n  * [using a private (xprv) key, with default columns](#using-a-private--xprv--key--with-default-columns)\n  * [Deriving change addresses and showing all columns.](#deriving-change-addresses-and-showing-all-columns)\n  * [Derive addresses from bip39 mnemonic seed words.](#derive-addresses-from-bip39-mnemonic-seed-words)\n    + [Without a password](#without-a-password)\n    + [With a password](#with-a-password)\n    + [Using ypub extended key for segwit p2sh addresses.](#using-ypub-extended-key-for-segwit-p2sh-addresses)\n    + [Using zpub extended key for segwit bech32 addresses.](#using-zpub-extended-key-for-segwit-bech32-addresses)\n  * [Derive addresses from xpub key](#derive-addresses-from-xpub-key)\n  * [We can derive segwit keys](#we-can-derive-segwit-keys)\n    + [ypub / p2sh](#ypub---p2sh)\n    + [zpub / bech32](#zpub---bech32)\n    + [Derive addresses for a bitcoin-core wallet.](#derive-addresses-for-a-bitcoin-core-wallet)\n  * [We can easily change up the columns in whatever order we want.](#we-can-easily-change-up-the-columns-in-whatever-order-we-want)\n  * [Let's find what altcoins are supported.](#let-s-find-what-altcoins-are-supported)\n  * [We can view altcoin addresses.](#we-can-view-altcoin-addresses)\n  * [We can easily generate a new random master key, seed and extended keys for any coin.](#we-can-easily-generate-a-new-random-master-key--seed-and-extended-keys-for-any-coin)\n  * [Key generation includes segwit keys and their paths.](#key-generation-includes-segwit-keys-and-their-paths)\n  * [We can get results in a variety of additional formats](#we-can-get-results-in-a-variety-of-additional-formats)\n    + [simple list](#simple-list)\n    + [json](#json)\n    + [csv](#csv)\n- [How address derivation works](#how-address-derivation-works)\n- [Path Presets](#path-presets)\n- [Path variables](#path-variables)\n    + [Variables](#variables)\n- [Segwit notes](#segwit-notes)\n- [Litecoin notes](#litecoin-notes)\n  * [xpub vs Ltub keys.](#xpub-vs-ltub-keys)\n  * [Here we see Mtub key and new style 'M' p2sh address.](#here-we-see-mtub-key-and-new-style--m--p2sh-address)\n  * [And a ttub testnet key](#and-a-ttub-testnet-key)\n- [Privacy and Security implications](#privacy-and-security-implications)\n- [Use at your own risk.](#use-at-your-own-risk)\n- [Output formats](#output-formats)\n- [Usage](#usage)\n- [Installation and Running.](#installation-and-running)\n  * [install secp256kp1 php extension for big speedup](#install-secp256kp1-php-extension-for-big-speedup)\n- [Thanks](#thanks)\n- [Todos](#todos)\n\n\n# hd-wallet-derive\nA command-line tool that derives bip32 addresses and private keys for Bitcoin and many altcoins.\n\nAs of version 0.3.2, over 300 altcoins are available, 97 with bip44 path information.\nBitcoin Cash \"CashAddr\" and Ethereum address types are supported.\n\nAs of version 0.4.0, segwit keys and addresses are supported for Bitcoin as\nypub keys with p2sh style addresses and zpub keys with bech32 addresses.\n\nAs of version 0.4.1, Bitcoin-core style key derivation is supported.\n[See here](./doc/bitcoin-core-hd.md).\n\nAs of version 0.4.3, [Preset paths](#path-presets) are available for common wallet software.\n\nAs of version 0.5.0, PHP 8+ is supported.  Older versions of PHP are not.\n\nDerivation reports show privkey (wif encoded), xprv, xpub, and address.\n\nInput can be a xprv key, xpub key, or bip39 mnemonic string (eg 12 words) with\noptional password.\n\nThis tool can be used in place of your wallet software if it is misbehaving or\nif you just want to see more information about your wallet addresses, including\nprivate keys and addresses you haven't even used yet.\n\nReports are available in json, plaintext, and html. Columns can be changed or\nre-ordered via command-line.\n\nSee also: [hd-wallet-addrs](https://github.com/dan-da/hd-wallet-addrs) -- a tool for finding hd-wallet addresses that have received funds.\n\n# Path Preset examples.\n\n## Obtaining a list of preset paths.\n\nLet's say we want to derive addresses for bitcoin-core software.  First, we need to find out the preset\nidentifier for this software.\n\n```\n$ ./hd-wallet-derive.php --help-presets | head -n 7\n+-------------------------+----------------------+-------------------------+------------------+---------------------------+\n| id                      | path                 | wallet                  | version          | note                      |\n+-------------------------+----------------------+-------------------------+------------------+---------------------------+\n| bip44                   | m/44'/c'/a'/v/x      | Bip44 Compat            | n/a              | Bip44                     |\n| bip49                   | m/49'/c'/a'/v/x      | Bip49 Compat            | n/a              | Bip49                     |\n| bip84                   | m/84'/c'/a'/v/x      | Bip84 Compat            | n/a              | Bip84                     |\n| bitcoincore             | m/a'/v'/x'           | Bitcoin Core            | v0.13 and above. | Bip32 fully hardened      |\n```\n\nSee [Path Presets](#path-presets).\n\nIf we want only the ids, we could use the command:\n\n```\n$ ./hd-wallet-derive.php --help-presets --format=list\nbip44\nbip49\nbip84\nbitcoincore\nbither\nbreadwallet\ncoinomi\ncoinomi_bech32\ncoinomi_p2sh\ncopay\ncopay_hardware_multisig\ncopay_legacy\nelectrum\nelectrum_multi\nhive\njaxx\nledgerlive\nmultibit_hd\nmultibit_hd_44\nmycelium\nsamourai\nsamourai_bech32\nsamourai_p2sh\ntrezor\nwasabi\n```\n\n## Deriving addresses for bitcoin-core using preset path.\n\nUsing a preset means that we do not need to know the bip32 path.  We can do:\n\n```\n$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3 --preset=bitcoincore --cols=path,address\n\n+------------+------------------------------------+\n| path       | address                            |\n+------------+------------------------------------+\n| m/0'/0'/0' | 1JsH5tzm2bphJySSLJ13AbFGP8KqJBYvG7 |\n| m/0'/0'/1' | 19in8KwQy2waqzogwnVRvh2gt7EkHDGtwg |\n| m/0'/0'/2' | 1CMc7jzi6ewKRzBNSCMkYzY3PU13ck6bxQ |\n+------------+------------------------------------+\n```\n\n## Deriving Change addresses for bitcoin-core using preset path.\n\nWe can use the --path-change flag for this.  requires a preset\nwith variable 'v' present in the path.\n\n```\n$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3 --preset=bitcoincore --cols=path,address --path-change\n\n+------------+------------------------------------+\n| path       | address                            |\n+------------+------------------------------------+\n| m/0'/1'/0' | 1B6q1KTyaa9yLHV2HTZC1rZaSKMG8KNqsp |\n| m/0'/1'/1' | 15RF1R9ZaSqgtaTVBDm1ySU5MQ6dZeTpZf |\n| m/0'/1'/2' | 1DpzhgrgWuRSnQjvLiZHMG2TAjs86znvjj |\n+------------+------------------------------------+\n```\n\nNotice that that 2nd field has changed from 0' to 1'.\n\n\n# Custom Path examples.\n\n## using a private (xprv) key, with default columns\n\nHere we do not specify a bip32 path or a preset, so addresses will be derived directly from\nthis key.\n\n```\n$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --numderive=3\n\n+------+------------------------------------+------------------------------------------------------+\n| path | address                            | privkey                                              |\n+------+------------------------------------+------------------------------------------------------+\n| m/0  | 1A9X6wjnER55GMpCCsTjn973y56u3zviDe | L4mgN3QEzR9PT6zPeKXGk3xNiGxxkHu4575W9YwBSRV2sRiyjV4g |\n| m/1  | 192oE3o29AAoBPQiTYe65kRU2zoBLpEnUm | L1xYoR7VS6vuvkmfRM4ubaH84vRkWKUS2PmYj9DPTS76NQ4NtZP9 |\n| m/2  | 1BbtRW5sua3Ewhm8jHAURUiz9t4bw8TQo9 | L21sVq8wutBSQWTzVJVBTeCdkfTgw41dK3PPViZ3Ds2xnMq8RMbK |\n+------+------------------------------------+------------------------------------------------------+\n```\n\n## Deriving change addresses and showing all columns.\n\nTypically, wallets provide xprv and xpub keys at the wallet root level (eg\nm/0/0/0) and then receive addresses and change addresses are available at the\nrelative paths /0 and /1 respectively.\n\nIf this is the case with your wallet, then a command like the following should\nwork to derive change addresses. Note the --path=1 arg. Change it to --path=0 to\nderive receive addresses. In the results below, the addresses are different than\nabove. This is because the path is different.\n\nNotice also that the first xprv matches the --key argument and has \"/\" for the\nrelpath. This row is included because of the --includeroot flag. In this way, we\ncan easily obtain the xpub key for our xprv key.\n\n```\n$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --path=m/1 --cols=all --includeroot --numderive=3\n\n+-------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+--------------------------------------------------------------------+-------+\n| path  | address                            | xprv                                                                                                            | xpub                                                                                                            | privkey                                              | pubkey                                                             | pubkeyhash                                                         | index |\n+-------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+--------------------------------------------------------------------+-------+\n| m     | 1CHCnCjgMNb6digimckNQ6TBVcTWBAmPHK | xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c | xpub67xpozcx8pe95XVuZLHXZeG6XWXHpGq6Qv5cmNfi7cS5mtjJ2tgypeQbBs2UAR6KECeeMVKZBPLrtJunSDMstweyLXhRgPxdp14sk9tJPW9 | L1pbvV86crAGoDzqmgY85xURkz3c435Z9nirMt52UbnGjYMzKBUN | 0212b55b9431515c7185355f15b48c5e1a1bbfa31af61429fa2bb8709de722f420 | 0212b55b9431515c7185355f15b48c5e1a1bbfa31af61429fa2bb8709de722f420 |       |\n| m/1/0 | 1qhp7SiuVmxo3WKca7zHMkKjvjkGXs29d  | xprv9yJyMFmJjNAiXqf3yfT6NvWCkXo1PTdYw6x5sj6fH2ePRVL4N4wy8weFYJnMKxNEib9HFyS7pc69rE3tmw7FfWhshBc17wHcKsNHByt4SZC | xpub6CJKkmJCZjj1kKjX5gz6k4SwJZdVnvMQJKsgg7WGqNBNJHfCucGDgjxjPcHY9QZJCne3tubbtucYmpt7a7u1Xx3oNumZRVytpa2UdFjTr47 | KxcccHPiLz7sxUVShX9THgfH6i8D6m3iAkHtgGuB87Tm3maz8Jas | 036f45f7040f0f41068d7bcb45dbd28550be6739cfdbe16739e27cfa44e60083c3 | 093608d6a29e55873e2d1facacf6631961a4e8ed                           |     0 |\n| m/1/1 | 1N3vKW2KGeKocao9eae6kVyYL8GNLzW8yd | xprv9yJyMFmJjNAiZ2NDkwj7Jcjo8AtdJTPYXF5bBLGUYh8NNid9bgAfuhNtSEco35mLrBzPPRTaA5XeezrtPxn59MsYBzjRZt6XqGW2T87JiS4 | xpub6CJKkmJCZjj1mWSgryG7fkgXgCj7hv7PtU1Byig672fMFWxJ9DUvTVhNHVA8ciGkqrwaqDW6Mvmr4ihT3EoqjgNK6s5P6C9X7UBLX5Trzw6 | KyxHznKrz1Y6jmE5fxnHh1e2AZLNCtDjnF86cZzk8F5S8nBxfqfc | 021107c4523fb021ad5c8e5ae086b8d162ebd755df80100e26c9d4cb5c7caaa3ba | e6e7fb588626c0568fbb898edf098725ac0b8736                           |     1 |\n| m/1/2 | 17XRz7oPJLUNp5uf66BeqTmSDuRwqz3aW4 | xprv9yJyMFmJjNAibyUzvGgfpk8igy6DpCtjWQ6C5oVmXyUhqak5J2xj6K2y7o3qn22nAvt14cLjRQEXVpGRZoc3ULJHomWmkUTTPJCEaF4rZPr | xpub6CJKkmJCZjj1pTZU2JDgBt5TEzviDfcasd1ntBuP6K1giP5DqaGye7MSy5MYFWoGtVhvK8Ko2XW4JRMtKjMXctpPxcjRMjM47AqeWiZLKKN | L1AFnZ6JJyGRxLG9QoCTDzeLzLV617XtgLy8DrXCyLnPG6L1n7xo | 031d715e0943dd94df91771397d0cb75db46279da4bbd64596652ce2e1b36da74a | 479216fd27805445fc564410c1c5e83139b39005                           |     2 |\n+-------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+--------------------------------------------------------------------+-------+\n```\n\n## Derive addresses from bip39 mnemonic seed words.\n\n### Without a password\n```\n$ ./hd-wallet-derive.php --mnemonic=\"refuse brush romance together undo document tortoise life equal trash sun ask\" -g --includeroot  --numderive=2 --cols=path,address,privkey,pubkey,xprv\n\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                            | privkey                                              | pubkey                                                             | xprv                                                                                                            |\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | 15UL8r2hkZpwi7RrQzWo6fYxfzdWL8mguG | L4jtNUY2YZfARajhSzq66RCBcfB8ZaXUYVHXD3q2q8SdMGaS7HpX | 03fa47f99f33e208cf46f42bdfc120843808a6558fa77a7806124f3b00be900b4a | xprv9s21ZrQH143K2vBDZaAMUvqS1MBuyNyisggeeGiUdMpi956vyGmkX81BapU6oD2c1qHnQYETcd85Z7i4GfmBz2TCz9PDQrxHjd3W5Ty5ayu |\n| m/44'/0'/0'/0/0 | 14QEoz5SwQ5Kfjkhs5QitskgfD5QCqM7RB | L4X3nAcMs63daNUaWoVL6YBRh7GDsyT3mouEKLFhSeYe5PBwJbXe | 024977580921d65487194d2d84744b411cdbc19ec374bdb3fdfcf32e86e3e16830 | xprvA3rUF5RAJPotmYWqWmqEoWweV6CWVwYMA6vSGb6VCjhGFKaPuxHnveqBaBs19GPhp8unUjNBUj2TEFgbUUqsaPzF41w1SHcFUMC9jb8KCcJ |\n| m/44'/0'/0'/0/1 | 1B83aj2N1Dxx37C4UdNM4vE5JxVKQV1Hur | L3Ks5PyY6enhjxsevfPYfsDmCtaK6nUymPmaN1Xvszh86urom9nw | 0357e9b058d9cbaece6459537579a6b7a9822f163844cd50f94ab76ad3781f2d4d | xprvA3rUF5RAJPotoshfn98F5SpcbC2vbR2CKtKkFfr8LJ7FwmukaCCN1fbcqqefb51odUrkFxnxxTyBkUM2hQ3ymusqjtEr3CErczzT1UkhERP |\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\nnote: The --path argument defaults to the bip44 extended key path when using\n--mnemonic to make address generation easier.  If a Bip44 ID is not defined for\nthe coin then --path must be specified explicitly.\n\nyou can verify these results [with Ian Coleman's tool](https://iancoleman.io/bip39/).\n\n\n### With a password\n\n```\n$ ./hd-wallet-derive.php --mnemonic=\"refuse brush romance together undo document tortoise life equal trash sun ask\" --mnemonic-pw=\"mypass\" --path=\"m/44'/0'/0'/0\"  -g --includeroot  --numderive=2 --cols=path,address,privkey,pubkey,xprv\n\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                            | privkey                                              | pubkey                                                             | xprv                                                                                                            |\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | 1GmHqykYzYHz6G3FiC9t8JRjEGXmDqmnKA | L5D4PLY9ESVfF3pJnzp4vMz9DXfTstyWq29tdcFyGcziz1vDZZrU | 021d0ba761acb490283a75f523c38e572dd96a3b0ed9a34c110f40dab8aa82b766 | xprv9s21ZrQH143K4NLDtVeqgtfoxAPoRuPLipm1EzQRhP8Vp3sx5nYu8KTFutKfv3MRrGBJgcRxg9gcQwe2tBaLUov8tm18zaE2LxbwkW4j2SA |\n| m/44'/0'/0'/0/0 | 1MXGCNMujDdT8AbXH7bxUEemiG8zQUk7ag | Kx3sazEL38AyeiNqz2vnW6btfCTcdn2Ww1ubxyX3yCEkiZvppp5d | 02dd4630b4ded7635093afc6bb498f498b9ce5f735d10a80ad0d0f67f23a005f79 | xprvA2XuGNexMcwzPEmVVXnwcTuax4sz4nehv6eSrqnAZ2AWjXFBYuvtge55L3ytZcdTp5S3ptwhaJbtEZ35wvib3S9cQPemQEHm6W8FNWLHH59 |\n| m/44'/0'/0'/0/1 | 1EMfWdxRQYzg78PGcHq6pEDqZbQMDm31JN | L3y1MsuW6bbWsR6jkaDXcsHRocBMPHoMcnr7zz7xviHrEg1na4fU | 03597bafe11885102e45542060b8f7dec902d994fdb7b04c4b0f1f97e3db94ea64 | xprvA2XuGNexMcwzTwbLgXNrHEoYArDaV9zz17yDD1RkWsbn48g2MPJoRhoNXaZbxBqeQ64HGKkJ4hmzrgc4jFW6C9ku9L46hfbBPUguE2dRVZo |\n+-----------------+------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\n### Using ypub extended key for segwit p2sh addresses.\n```\n$ ./hd-wallet-derive.php --key-type=y --mnemonic=\"refuse brush romance together undo document tortoise life equal trash sun ask\" -g --includeroot  --numderive=2 --cols=path,address,xprv\n\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                            | xprv                                                                                                            |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | 32AuKZR2VDE92CnXqGA9ZT8tMxQdeMmWLs | yprvABrGsX5C9jantDNLPvwyh1vwBKLMuzyDnoCsRfcN1NCbCAvADvwK9BfKc2Rgo7gXRUQbA1q25HUdSQKczNBCnG8orV5dzmmn1M79U4g6cJu |\n| m/49'/0'/0'/0/0 | 3A9T2s8eeUbREb9DS3YFmK5wzajArDGvmY | yprvAN1znE9zGbrFzoVo8kSTYF7GHjDkmjkb2N8qeNA4Vecyt2t6AFroRzaLK6Fb13cidiNDAS2iL6jqrzkooz3XNQmKhBbdqiJeNhb155FS9nK |\n| m/49'/0'/0'/0/1 | 3HWjvs6ZFQQgWLcvdnDFDAt284FWroMGSz | yprvAN1znE9zGbrG4HArpijJbexkCEWP8oFyCAGfudZXEmuzLsPxoF6EJ7QAxWt4N8Ro3ebcoYyR9zxQhQxPDVwkFHqmUmTWy9BQG7uQjCjw8NS |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\n### Using zpub extended key for segwit bech32 addresses.\n```\n$ ./hd-wallet-derive.php --key-type=z --mnemonic=\"refuse brush romance together undo document tortoise life equal trash sun ask\" -g --includeroot  --numderive=2 --cols=path,address,xprv\n\n+-----------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                                    | xprv                                                                                                            |\n+-----------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | bc1qxy9m2x2nhrunduvjz0hx8sdv6av52fqzqtfw08 | zprvAWgYBBk7JR8GjWZTEHjbu72SMHUorcxihuj6D4WFPNaUFGjPUb6smFKTdEPGo2LSq7XPuVRaXwqBKgwBi4bDaVpQipn4agbGH5AnrfYE8kQ |\n| m/84'/0'/0'/0/0 | bc1qy0p88n2d09ntyvjlkmum5p9rp2a99ws04cxjjv | zprvAgjsrdySZb8q4L1tQX9EmwRYa5Ldu3kPEK6YYPBt1Et64fovuAHA5izEPaFCCNZCkeUHnVcy9Z2B6cAauJa6mz9byU1KXEgfCo4qStWFF8D |\n| m/84'/0'/0'/0/1 | bc1qvznkdsdg3nwhjy08j3x9hc8u5mf0mfwhzwgych | zprvAgjsrdySZb8q7QEmNzR81DRaTQfjcq96znUUKGhH93eRZmyWV1vPc7QiBzYTMMBVmnvvz5XQ73ofAQSrfDu3RCJiT5cAR3nLNRJNJTrrpdt |\n+-----------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\nnote: you can verify these results [with Ian Coleman's tool](https://iancoleman.io/bip39/).\n\n\n## Derive addresses from xpub key\n\nAddresses can also be derived for a public (xpub) key.  In this case, result fields pertaining to private keys will be empty.\n\n```\n$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --numderive=3\n\n+------+------------------------------------+---------+\n| path | address                            | privkey |\n+------+------------------------------------+---------+\n| m/0  | 1FZKdR3E7S1UPvqsuqStXAhZiovntFirge |         |\n| m/1  | 12UMERLGAHKe5PQPaSYX8sczr52rSAg2Mi |         |\n| m/2  | 1Pyk8NLx3gaXSng7XhKoNMLfBffUsJGAjr |         |\n+------+------------------------------------+---------+\n```\n\n## We can derive segwit keys\n\n### ypub / p2sh\n```\n$ ./hd-wallet-derive.php --key=yprvALsZfj564Q4XBd6aaAJ3sA1BVBhEw9Q8Xn7x9jFeMku6u2y6kRFdaDVFsdj9d8zuAdvwH5id6VJ5xKdwGJgMyx292kcJigqNdic2piwqAuL --numderive=3 --cols=path,address -g\n\n+------+------------------------------------+\n| path | address                            |\n+------+------------------------------------+\n| m/0  | 31qFbTk4btBfVVV3BrSopZQGfR5E5yqHQE |\n| m/1  | 3Qys6SzWm27q5KCeky5SQoaWUxLqd3xNnW |\n| m/2  | 3FKLumUJPQXtTScmpyQCEaHhePWrYcXQLj |\n+------+------------------------------------+\n```\n\n### zpub / bech32\n```\n$ ./hd-wallet-derive.php --key=zprvAfvRyooajPigxomveEuGYUPwB7KLGseATsYbGB63S6wnFvFahfNnkBYmWCjhGmWbh7fJgNZSoUeAu7HcbRqcFtRPf5KXShRj7Sik7GadJrK --numderive=3 --cols=path,address -g\n\n+------+--------------------------------------------+\n| path | address                                    |\n+------+--------------------------------------------+\n| m/0  | bc1qgpkf27eva4rdqsd3cv60hywmc83k63g08xum60 |\n| m/1  | bc1qjfz7nn90szmzzy38jym79p0hxr8s2c4dxhj4v0 |\n| m/2  | bc1qv23447pd7ezf589d9elcuztz3pnarf0ndk2twv |\n+------+--------------------------------------------+\n```\n\n### Derive addresses for a bitcoin-core wallet.\n\nHere we make use of *--path=\"m/0'/0'/x'\"* to specify hardened address generation\nand *--addr-type=p2sh-segwit* to force generation of p2sh-segwit keys for an xprv key.\n\n[See here](doc/bitcoin-core-hd.md) for more docs and examples on bitcoin-core derivation.\n\n```\n$ /home/websites/hd-wallet-derive/hd-wallet-derive.php --path=\"m/0'/0'/x'\" --addr-type=p2sh-segwit --cols=path,address,pubkey --numderive=3 --key=xprv9s21ZrQH143K3KeCJ5DMac7XqmriV7xVDDCV5MNE564bKUF6piF7JK6RWHVJMzQMUBbzxLaV9kNaRMHyjVnjNiLAq2SyvJJBs7ZUg4c9kcy -g\n\n+------------+------------------------------------+--------------------------------------------------------------------+\n| path       | address                            | pubkey                                                             |\n+------------+------------------------------------+--------------------------------------------------------------------+\n| m/0'/0'/0' | 3LTKKaLjr83nSCEE5gUfLzRhavU3wAdMtu | 0236ac3d8df99023e259d24754fd022af696542e25ff237bc9c835d52468b538ae |\n| m/0'/0'/1' | 34dCyjA9rEtjDEZ1AUViTGxYvmNAFA3gFH | 0365d31a6168e1187202ffb30bc80b4a788d68e87909024b624d4963ff2426b339 |\n| m/0'/0'/2' | 3FzQckSqoQNnzdGgn5sLRUgaE8Vxt4g4eo | 02446804c9bd85f0f782a0f4e52baa7398005b0ee54dc4eed23aeef64363a7ea99 |\n+------------+------------------------------------+--------------------------------------------------------------------+\n```\n\n\n## We can easily change up the columns in whatever order we want.\n\nJust use the --cols parameter.\n\n```\n$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --numderive=3 --cols=xpub,address\n\n+-----------------------------------------------------------------------------------------------------------------+------------------------------------+\n| xpub                                                                                                            | address                            |\n+-----------------------------------------------------------------------------------------------------------------+------------------------------------+\n| xpub6Dv5JYyovBicwK57NbxM4zbV6PBr5vP6EDZTMHsULd8uFKSXAArqiChQKo26JWjrAxgsz78riSpt2QU1TEfkK6ZSdSYqgSwnTbbrs7J3qZ8 | 1FZKdR3E7S1UPvqsuqStXAhZiovntFirge |\n| xpub6Dv5JYyovBiczGhM8vgsv5LXpjoHhBZeD8cMgjtkMbd4vsqkYudETnnKWmJHyFvcNWvgqj21pBxunfHaBGdWgEKqo9ogr1x6qaExZ5wTvPm | 12UMERLGAHKe5PQPaSYX8sczr52rSAg2Mi |\n| xpub6Dv5JYyovBid1MKNu51wxzPaCqooCFmKgzHLihydzgibWkYqQg9QZmpMuX8jqZ4zSAdTBJQKh7ekmdXrT8LNthKD1ia6nC3nNNNmua5Rfg3 | 1Pyk8NLx3gaXSng7XhKoNMLfBffUsJGAjr |\n+-----------------------------------------------------------------------------------------------------------------+------------------------------------+\n```\n\n## Let's find what altcoins are supported.\n\n```\n$ ./hd-wallet-derive.php --help-coins\n+--------------------+------------------------------------+\n| Symbol             | Coin / Network                     |\n+--------------------+------------------------------------+\n...\n| ZEC                | Zcash - Mainnet                    |\n| ZEC-test           | Zcash - Testnet                    |\n| ZEC-regtest        | Zcash - Regtest                    |\n...\n+--------------------+------------------------------------+\n\n```\n(340+ altcoins omitted for brevity)\n\nNote that testnet and regtest are supported for many coins.\n\n## We can view altcoin addresses.\n\n```\n$ ./hd-wallet-derive.php --key=xprv9zbB6Xchu2zRkf6jSEnH9vuy7tpBuq2njDRr9efSGBXSYr1QtN8QHRur28QLQvKRqFThCxopdS1UD61a5q6jGyuJPGLDV9XfYHQto72DAE8 --cols=path,address --coin=ZEC --numderive=3 -g\n\n+------+-------------------------------------+\n| path | address                             |\n+------+-------------------------------------+\n| m/0  | t1V1Qp41kbHn159hvVXZL5M1MmVDRe6EdpA |\n| m/1  | t1Tw6iqFY1g9dKeAqPDAncaUjha8cn9SZqX |\n| m/2  | t1VGTPzBSSYd27GF8p9rGKGdFuWekKRhug4 |\n+------+-------------------------------------+\n```\n\n## We can easily generate a new random master key, seed and extended keys for any coin.\n\n```\n$ ./hd-wallet-derive.php --coin=DOGE --gen-key --format=jsonpretty -g\n[\n    {\n        \"coin\": \"DOGE\",\n        \"seed\": \"a3adc3e71ac05b3336422e6506d646e995f7bfcb960e6fca48dc13c93fae8ef3dc37a6013791ad1cfe7fe408de0e7676a9fe29b02413c79b988d54c74515d3db\",\n        \"mnemonic\": \"arch hover pen regret priority sugar thunder glimpse west diagram path sword divide spread anger vendor century roof agree know treat drastic allow blind advance oil iron gold skate absorb stem shiver can pear twin helmet loan satisfy fragile admit comfort mercy pelican pupil debate tornado rifle desert\",\n        \"master_priv_key\": \"dgpv51eADS3spNJh8eoSPqujdFPAhBZywAW6KQrR5TqM1Q5NMsrJmFP1hTXvfbUHLQFLmh4jVYZjXtJvKJVakn5YxT48mocEXu7yTNkCYN29cMV\",\n        \"path\": \"m\\/44'\\/3'\\/0'\\/0\",\n        \"ext_priv_key\": \"dgpv59SfnUBjPvKLfM453bkxJXHRfNvDQ3zAngt3fpKheqR846z9W1QYzoUz5ss4qtvLU7iBd93nw8ZXcXArpdLjuyudR2uUFH4KeV9Nes8eNeJ\",\n        \"ext_pub_key\": \"dgub8tKh8A7cx4yfxCiE5qNvRNq27wHrEB1t5HfFpvigSxU8cA6qumxKe6tdf7TkUPFBoj6C8eBxofiydXy5hGf471zWZkYiy4tQ6vWqRwETdGA\"\n    }\n]\n```\n\n## Key generation includes segwit keys and their paths.\n\n```\n$ ./hd-wallet-derive.php --gen-key --cols=path,xprv -g\n+---------------+-----------------------------------------------------------------------------------------------------------------+\n| path          | xprv                                                                                                            |\n+---------------+-----------------------------------------------------------------------------------------------------------------+\n| m/44'/0'/0'/0 | xprvA19NHbsi3bjKhC9DTPzg2mxfkgrPHyHtEJZUs3P17s8QeDiefRL7jGKkHapfqyxycCBW76bdYR2cezv1ECW4rNpmJ691XaGRVDbB8m4S1Ln |\n| m/49'/0'/0'/0 | yprvALsZfj564Q4XBd6aaAJ3sA1BVBhEw9Q8Xn7x9jFeMku6u2y6kRFdaDVFsdj9d8zuAdvwH5id6VJ5xKdwGJgMyx292kcJigqNdic2piwqAuL |\n| m/84'/0'/0'/0 | zprvAfvRyooajPigxomveEuGYUPwB7KLGseATsYbGB63S6wnFvFahfNnkBYmWCjhGmWbh7fJgNZSoUeAu7HcbRqcFtRPf5KXShRj7Sik7GadJrK |\n+---------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\n## We can get results in a variety of additional formats\n\n### simple list\n\nonly the first column will be used.  This is handy for cut/paste operations.\n\n```\n ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --numderive=3 --cols=address,xpub --format=list\n\n1FZKdR3E7S1UPvqsuqStXAhZiovntFirge\n12UMERLGAHKe5PQPaSYX8sczr52rSAg2Mi\n1Pyk8NLx3gaXSng7XhKoNMLfBffUsJGAjr\n```\n\n### json\n\njson can be pretty printed or compact form.\n\n```\n$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --numderive=3 --cols=address,xpub --format=jsonpretty\n[\n    {\n        \"address\": \"1FZKdR3E7S1UPvqsuqStXAhZiovntFirge\",\n        \"xpub\": \"xpub6Dv5JYyovBicwK57NbxM4zbV6PBr5vP6EDZTMHsULd8uFKSXAArqiChQKo26JWjrAxgsz78riSpt2QU1TEfkK6ZSdSYqgSwnTbbrs7J3qZ8\"\n    },\n    {\n        \"address\": \"12UMERLGAHKe5PQPaSYX8sczr52rSAg2Mi\",\n        \"xpub\": \"xpub6Dv5JYyovBiczGhM8vgsv5LXpjoHhBZeD8cMgjtkMbd4vsqkYudETnnKWmJHyFvcNWvgqj21pBxunfHaBGdWgEKqo9ogr1x6qaExZ5wTvPm\"\n    },\n    {\n        \"address\": \"1Pyk8NLx3gaXSng7XhKoNMLfBffUsJGAjr\",\n        \"xpub\": \"xpub6Dv5JYyovBid1MKNu51wxzPaCqooCFmKgzHLihydzgibWkYqQg9QZmpMuX8jqZ4zSAdTBJQKh7ekmdXrT8LNthKD1ia6nC3nNNNmua5Rfg3\"\n    }\n]\n```\n\n### csv\n\nFor all the spreadsheet lovers out there.\n\n```\n$ ./hd-wallet-derive.php -g --key=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --numderive=3 --cols=address,xpub --format=csv\n\naddress,xpub\n1FZKdR3E7S1UPvqsuqStXAhZiovntFirge,xpub6Dv5JYyovBicwK57NbxM4zbV6PBr5vP6EDZTMHsULd8uFKSXAArqiChQKo26JWjrAxgsz78riSpt2QU1TEfkK6ZSdSYqgSwnTbbrs7J3qZ8\n12UMERLGAHKe5PQPaSYX8sczr52rSAg2Mi,xpub6Dv5JYyovBiczGhM8vgsv5LXpjoHhBZeD8cMgjtkMbd4vsqkYudETnnKWmJHyFvcNWvgqj21pBxunfHaBGdWgEKqo9ogr1x6qaExZ5wTvPm\n1Pyk8NLx3gaXSng7XhKoNMLfBffUsJGAjr,xpub6Dv5JYyovBid1MKNu51wxzPaCqooCFmKgzHLihydzgibWkYqQg9QZmpMuX8jqZ4zSAdTBJQKh7ekmdXrT8LNthKD1ia6nC3nNNNmua5Rfg3\n```\n\n\n# How address derivation works\n\nFor background, please read [bip32 proposal](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).\n\nThis tool does not care about absolute bip32 paths or their meanings. In the\ndefault mode it simply accepts a key as input and begins to derive new\n(deterministic) keys from it.\n\nThis behavior can be modified with the --path argument, which specifies a\nsub-path relative to the provided key. For xprv and xpub keys exported from most\nwallet software, use --path=0 to find receive addresses and --path=1 to find\nchange addresses. Expert users may have trickier uses for this flag.\n\nDue to the simplicity of this approach, the tool does not need to know or care about specific\nbip32 path layouts such as bip44, bip45, etc.\n\n\n# Path Presets\n\nPath presets are available for standardized paths and commonly used Bitcoin Wallet software.\n\nA list of the presets can be obtained by running\n\n    $ ./hd-wallet-derive.php --help-presets\n\nOr [view them online](./doc/wallet-bip32-path-presets.md).\n\n--path and --preset are mutually exlusive, so use one or the other.\n\n\n# Path variables\n\nSome wallet software supports features such as multiple accounts or even multiple\ncryptocurrencies that share a common bip32 path structure.  The mostly communly used structure\nis Bip44, so we will use that as an example.\n\nBip44 has the structure:\n\n    m / purpose' / coin_type' / account' / change / address_index\n\nA valid Bip44 path used to generate an address might look like:\n\n    m/44'/0/0/0/0\n\nhd-wallet-derive accepts one-letter variables with special meanings that can be\nsubstituted in a path.\n\nThese variables are used in path presets and variable values can be defined with flags\n--coin, --path-account and --path-change\n\n### Variables\n\n| var | meaning                                    | flag to fill it in  | default           |\n|-----|--------------------------------------------|---------------------|-------------------|\n| c   | coin identifier, from --help-coins         | --coin=\\\u003cid\u003e        | 0 (btc)           |\n| a   | account                                    | --path-account=\\\u003cn\u003e | 0 (first account) |\n| v   | visibility.  internal/external, aka change | --path-change       | 0 ( external )    |\n| x   | the field to increment / iterate.          | none                | n/a               |\n\n\nNormal usage will be to choose a preset with --preset=\\\u003cid\u003e and then use\none or more of the flags to override default for any included variables.\n\nUse the --help-presets flag to find path definitions for your wallet software.\n\nnote: It is possible to use variables in paths passed via the --path argument, but you\nshouldn't need to do this as you can directly manipulate every field when using a custom path.\n\n\n# Segwit notes\n\n*Segwit support is considered experimental in this release!*\n\nThis tool uses the notation x,y,z to indicate the extended key prefix bytes,\nregardless of coin or network.\n\nThe meanings of x,y,z are:\n\n|key-type|meaning        |\n|--------|---------------|\n|x       |p2pkh or p2sh  |\n|y       |p2wpkh in p2sh |\n|z       |p2wpkh         |\n\n\nSome examples:\n\n|key-type|coin      |network  |private ext key prefix|public ext key prefix|\n|--------|----------|---------|----------------------|---------------------|\n|x       |BTC       |Mainnet  |xprv                  |xpub                 |\n|y       |BTC       |Mainnet  |yprv                  |ypub                 |\n|z       |BTC       |Mainnet  |zprv                  |zpub                 |\n|x       |BTC-test  |Testnet  |tprv                  |tpub                 |\n|y       |BTC-test  |Testnet  |uprv                  |upub                 |\n|z       |BTC-test  |Testnet  |vprv                  |vpub                 |\n|x       |DOGE      |Mainnet  |dgpv                  |dgub                 |\n|x       |OK        |Mainnet  |okpv                  |okub                 |\n\nAt present, most coins do not have prefixes defined for y and z types.\nThis tool will default to BTC values for y and z in these cases, although\nz will not work unless bech32_prefix is defined in the coin's source code.\n\n[Slip132](https://github.com/satoshilabs/slips/blob/master/slip-0132.md) has a list of known prefix types.\n\nAnyway, y and z addresses for coins other than BTC are for experimental purposes\nonly and you should never send money to one without first verifying it in your\nwallet software.\n\n\n# Litecoin notes\n\nLTC went off the rails a bit and did two funky things:\n\n1. Litecoin-core always used xpub/xprv like BTC, but some wallets started\nusing Ltub and now Mtub for segwit p2sh extended keys.  This tool uses\nxpub/xprv by default, but exposes a command-line option *--alt-extended=Ltub*\nwhich will use the alternate prefixes.  Note that this is only relevant to\nextended key generation.  Both xpub and Ltub style keys will generate the\nexact same addresses.\n\n2. Liteoin-core changed the SCRIPT_ADDRESS prefix for p2sh addresses. It\ncan read old and new style, but will generate new style.  This tool\ngenerates only new style.\n\n## xpub vs Ltub keys.\n\nnotice below that the generated addresses are the same as are the privkey and pubkey but the encoding of the xprv and xpub are different.\n\n```\n ./hd-wallet-derive.php --coin=LTC --mnemonic=\"wagon rail round impulse donor radar escape harsh series\" --numderive=1 --includeroot --cols=path,address,xprv,xpub,privkey,pubkey -g\n\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n| path            | address                            | xprv                                                                                                            | xpub                                                                                                            | privkey                                              | pubkey                                                             |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n| m               | LKNY2uPMT9pXG1k9pHrfv5PAHXy5Skt4B5 | xprv9s21ZrQH143K277qXR6NRni1DS7qmSNBs96NmnF5VGdcejgrJtBHzRJYZxqDJZKX1pF5i6gmmDmWDbBCs4DcQ9T1bH65UttBRw2uMaNJnNQ | xpub661MyMwAqRbcEbCJdSdNnvejmTxLAu63EN1yaAeh3cAbXY1zrRVYYDd2RH3654fwTBL4HaFhoMSuo8h8T7iAM7sVLhgKU6WB2EAGTkQh4zu | T5z8xkPacjcxmaQuTnTvc9nJwguGyQdvsHBFhRceBS3vWG3rxSiM | 03f99450e4f69f1e03b778e60b0339a5a6a39525c071dfb0f41b55e1afe0fa7fdc |\n| m/44'/2'/0'/0/0 | LYy3dBHszRadxCVczpsxaND32FoaAa8nbk | xprvA2rhfN2XaYQLti4axzziLV6djZrjCo4Wbwi73sbiCVVba9av45Z2MGeKi14Eqgq7pUKgxHuYAdLZ5FYu8oANqeqkDgd3tFmFHvNv8CHzEfH | xpub6Fr44sZRQuxe7C9452Xihd3NHbhDcFnMyAdhrG1Kkq2aSwv4bcsGu4xoZFJuaQ165C7sp4H1WFVV2AoYZLQ7puBFsGqucYCtQpWAt487nr1 | TArerCDBMzqdgM3zprT7hJZobonS16BZgUaj2m7irgRynQ1TNW4e | 028278f02f088cf83910006ff226e35190abef67aee82e761a29f96a7a5833d048 |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n\n$ ./hd-wallet-derive.php --alt-extended=Ltub --coin=LTC --mnemonic=\"wagon rail round impulse donor radar escape harsh series\" --numderive=1 --includeroot --cols=path,address,xprv,xpub,privkey,pubkey -g\n\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n| path            | address                            | xprv                                                                                                            | xpub                                                                                                            | privkey                                              | pubkey                                                             |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n| m               | LKNY2uPMT9pXG1k9pHrfv5PAHXy5Skt4B5 | Ltpv71G8qDifUiNes5mQyK8zaCvkQhahrS3XH87vjGdWUvDhfYTjBWwrMG1CXjNEBGxhvvpMncLHvJUAD6JHGBCb3FpMYr3FnqwDEKeoR2568uZ | Ltub2SSUS19CirucUxUFDvdNenkxrGGtvgcBMeDxQFPoR71JFueoWRzHMs7Tn9Z7jU5C3PjdsheFeP6HuE4FN1ocC3eudqZn8nGDWivcNFPktRC | T5z8xkPacjcxmaQuTnTvc9nJwguGyQdvsHBFhRceBS3vWG3rxSiM | 03f99450e4f69f1e03b778e60b0339a5a6a39525c071dfb0f41b55e1afe0fa7fdc |\n| m/44'/2'/0'/0/0 | LYy3dBHszRadxCVczpsxaND32FoaAa8nbk | Ltpv7B6pvjLv4CjgjgiAQu3LUuKNvqKbHnjr1vjf1Mz9C95gaxMnviKai7LyfmbFiQUJjaty2oZ4Ki3D4kfyXv9MUmD6BFaECCpH6JzpBgw25UA | Ltub2cHAXWmTJMGeMZQzfWXiZV9bNQ1nN3JW6SqggLkS8KsHBKYsFdN1iiTEv7pwEoQLfQXTQBfZMH8s8GAfUEVZfpxgAQjNHDxvuKGWnWWk8Xv | TArerCDBMzqdgM3zprT7hJZobonS16BZgUaj2m7irgRynQ1TNW4e | 028278f02f088cf83910006ff226e35190abef67aee82e761a29f96a7a5833d048 |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------+--------------------------------------------------------------------+\n```\n\nnote: When deriving with --key=\"Ltub......\", the *--alt-extended=Ltub* flag must be included or\nan error will be generated.\n\nThe *--alt-extended=Ltub* applies to all LTC operations include key generation,\nkey derivation via --key or --mnemonic as well as to LTC testnet and segwit (y,z) keys.\n\n## Here we see Mtub key and new style 'M' p2sh address.\n```\n$ ./hd-wallet-derive.php --key-type=y --alt-extended=Ltub --coin=LTC --mnemonic=\"wagon rail round impulse donor radar escape harsh series\"  --numderive=1 --includeroot --cols=path,address,xpub -g\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                            | xpub                                                                                                            |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | MTcqc7d7YeCCqtznxqukXhvuXjFU3YiNYY | Mtub2mGjjfp7sYT6LFfN4HQzrsrU2ERLsJbgGkkBBeHgo7PBK1U2m69qyvmboMWhjNj7T2rSdBEp73SqnWfp5iDczHLWWBGCih5hnSzFkqKszC1 |\n| m/49'/2'/0'/0/0 | MDrdvYHZXqkT2pd7VDZgz2WUs8zg7ZfkDf | Mtub2wrQVfmfLAR5st3nERaqt9FYnD8guDyrjxew73rWq2zUHiV95434YnMjowEoq4723ZQ27Kw8i6vSRyQaCoraNPKpMHyaLhquS5Gkq7XNhjC |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\n## And a ttub testnet key\n```\n$ ./hd-wallet-derive.php  --alt-extended=Ltub --coin=LTC-test --mnemonic=\"wagon rail round impulse donor radar escape harsh series\"  --numderive=1 --includeroot --cols=path,address,xpub -g\n\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| path            | address                            | xpub                                                                                                            |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n| m               | mffY4kAWBX1inKXcMiqkTyXiwKCWC3fiH6 | ttub4XNESS7BCg9c1Teh7mfmHL5gLFFmJfs5TADpxkPThNp41RnVWdkwdBrW7tJkAPRjfQVJFSp3yoBdy4jS6fYkdDKSskLLpkXdX56FWPahTBW |\n| m/44'/1'/0'/0/0 | mnuJrsWK9XjTLME4GHo1tLNd6TFrGjtAaG | ttub4hLeb7yEPwSJkhbb5hjEuZ8BeYUaJJJNQvUSL92ohB3Kj8L6phZ2YSpAFisrjxowXYSDbYHxu46wfv5EqZKkM5E66mWhcA51bSPpj3z7o69 |\n+-----------------+------------------------------------+-----------------------------------------------------------------------------------------------------------------+\n```\n\n\n# Privacy and Security implications\n\nThis tool runs locally and does not make any requests to a server.\nThis eliminates many forms of leaks and privacy issues.\n\nThat said, any time when you are working with private keys you should\ntake serious security precautions.\n\nIn particular, be advised that a master xprv key exposes not only a single key,\nbut potentially all private keys in your wallet both receive and change\naddresses.\n\nFurther, when you run this tool in a terminal, the executed command(s) will\nusually be saved to a history file -- including your xprv or xpub key! You\nshould be very careful to either expunge the command(s), or move the funds to\nanother wallet, or be certain untrusted parties cannot access your machine.\n\nFinally, this tool depends on libraries written by other authors and they\nhave not been carefully audited for security.  So use at your own risk.\n\n\n# Use at your own risk.\n\nThe author makes no claims or guarantees of correctness.\n\nBy using this software you agree to take full responsibility for any losses\nincurred before, during, or after the usage, whatsoever the cause, and not to\nhold the software author liable in any manner.\n\n\n# Output formats\n\nThe report may be printed in the following formats:\n* plain      - an ascii formatted table, as above.  intended for humans.\n* csv        - CSV format.  For spreadsheet programs.\n* json       - raw json format.  for programs to read easily.\n* jsonpretty - pretty json format.  for programs or humans.\n* list       - single column list. for easy cut/paste.  uses first col.\n\n\n# Usage\n\n```\n   hd-wallet-derive.php\n\n   This script derives private keys and public addresses\n\n   Options:\n\n    -g                   go!  ( required )\n\n    --key=\u003ckey\u003e          xpriv or xpub key\n    --mnemonic=\u003cwords\u003e   bip39 seed words\n                           note: either key or nmemonic is required.\n\n    --mnemonic-pw=\u003cpw\u003e   optional password for mnemonic.\n\n    --addr-type=\u003ct\u003e      legacy | p2sh-segwit | bech32 | auto\n                            default = auto  (based on key-type)\n\n    --key-type=\u003ct\u003e       x | y | z\n                            default = x. applies to --mnemonic only.\n\n    --coin=\u003ccoin\u003e        Coin Symbol ( default = btc )\n                         See --helpcoins for a list.\n\n    --helpcoins          List all available coins/networks.\n                         --format applies to output.\n\n    --numderive=\u003cn\u003e      Number of keys to derive.  default=10\n\n    --startindex=\u003cn\u003e     Index to start deriving keys from.  default=0\n\n    --cols=\u003ccols\u003e        a csv list of columns, or \"all\"\n                         all:\n                          (path,address,xprv,xpub,privkey,pubkey,pubkeyhash,index)\n                         default:\n                          (path,address,privkey)\n\n    --bch-format=\u003cfmt\u003e   Bitcoin cash address format.\n                           legacy|cash   default=cash\n    --alt-extended=\u003cid\u003e  Use alternate extended keys. supported:\n                           LTC:  Ltub\n\n    --outfile=\u003cpath\u003e     specify output file path.\n    --format=\u003cformat\u003e    txt|md|csv|json|jsonpretty|html|list|all   default=txt\n\n                         if 'all' is specified then a file will be created\n                         for each format with appropriate extension.\n                         only works when outfile is specified.\n\n                         'list' prints only the first column. see --cols\n\n    --path=\u003cpath\u003e        bip32 path to derive, relative to provided key (m).\n                           ex: \"\", \"m/0\", \"m/1\"\n                           default = \"m\"\n                             if --mnemonic is used, then default is the\n                             bip44 path to extended key, eg m/44'/0'/0'/0\n                             which facilitates address derivation from\n                             mnemonic phrase.\n                           note: /x' generates hardened addrs; requires xprv.\n                           note: /x is implicit; m/x is equivalent to m.\n                           ex: m/0/x'\", \"m/1/x'\"\n                           for bitcoin-core hd-wallet use: m/0'/0'/x'\n                           for ledger-live use m/44'/60'/x'/0/0\n                           for trezor, mew use m/44'/60'/0'/0\n\n    --includeroot       include root key as first element of report.\n    --gen-key           generates a new key.\n    --gen-words=\u003cn\u003e     num words to generate. implies --gen-key.\n                           one of: [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]\n                           default = 24.\n\n    --logfile=\u003cfile\u003e    path to logfile. if not present logs to stdout.\n    --loglevel=\u003clevel\u003e  debug,info,specialinfo,warning,exception,fatalerror\n                          default = info\n\n```\n\n\n# Installation and Running.\n\nLinux Ubuntu 16.04 requirements:\n```\napt-get install php php-gmp php-mbstring php-mcrypt\n```\n\nBasics   ( see below for big performance speedup )\n```\n git clone https://github.com/dan-da/hd-wallet-derive\n cd hd-wallet-derive\n php -r \"readfile('https://getcomposer.org/installer');\" | php\n php composer.phar install\n```\n\nTry an example\n```\n$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c\n```\n\n## install secp256kp1 php extension for big speedup\n\nIt is really slow to generate keys in PHP.  For a huge speedup, you can install the\nsecp256k1 extension from:\n\n\u003ca href=\"https://github.com/Bit-Wasp/secp256k1-php\"\u003ehttps://github.com/Bit-Wasp/secp256k1-php\u003c/a\u003e\n\n\n# Thanks\n\nA big thank-you to the author of bitwasp/bitcoin-php.  This library does the\nheavy lifting of dealing with deterministic keys and all things bitcoin.\n\n\n# Todos\n\n* refactor under /src and make into a separate lib/package\nfor high level derivation operations.\n* add test cases, ideally for each coin.\n* web frontend, maybe just for xpub keys, or to run locally.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fhd-wallet-derive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-da%2Fhd-wallet-derive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fhd-wallet-derive/lists"}