Multiformat HD Wallet tools
mhdw
is a command-line application to handle Hierarchical Deterministic Key creation and derivation.
HD wallets (see BIP32) are used by multiple cryptocurrencies.
mdhw
allows to generate a master seed, which can be then used to produce the master private and public keys, and derivate payment addresses and WIF (Wallet Import Format) files for different cryptocurrencies.
Currently it supports:
- Bitcoin
- Zcash
- Ethereum
- Decred
mhdw
is a diverging fork of hdkeyutils
. While hdkeyutils
saves and loads a master bitcoin-formatted key to perform derivation, mhdw
saves and loads the original seed and uses it to recreate the key. This allows to more easily incorporate additional key formats, as Decred. Multisig key handling and operations are not supported for the moment.
go get github.com/hsanjuan/mhdw
NAME:
mhdw - A command line utility for manipulating HD wallet keys
USAGE:
mhdw [global options] command [command options] [arguments...]
VERSION:
0.0.1
COMMANDS:
seed utilities to generate and handle multipurpose key-seeds
priv tools for working with HD master/derived private keys
pub tools for working with HD public keys and addresses
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
The seed is the key that holds any cryptocurrency sent to any of the subsequently derived addresses. Keep in mind that:
- You should not lose the seed
- You should keep it safe
- You should make sure that a generated seed is truly random and cannot be re-generated by someone else
mhdw
can generate random seeds with the mhdw seed gen
command:
$ mhdw seed gen foo bar
Seed has been written to "seed.hex"
This is the mnemonic representation of the seed that is used to build your
private key and your HD wallets. Keep it safe!
-------------------------------------------------------------------------
<list of 65 words>
-------------------------------------------------------------------------
The result is a 512-bit seed which is hex-encoded and written to a file.
The command also prints a mnemonic representation of the seed (1-word per byte + 1 checksum word), which can be used to backup the seed offline or memorize it. mhdw
provides utilities to recover the seed file from a mnemonic list of words and vice-versa.
To generate a payment address do:
$ mhdw pub child --format
You can then send cryptocurrency to that address.
When you want to manage that money or move it somewhere else, you will need to generate the corresponding private key using the same index
:
$ mhdw priv child --format
The result can be imported as follows:
- Bitcoin:
bitcoin-cli importprivkey "<result>" true
- Zcash:
zcash-cli importprivkey "<result>" true
- Decred:
dcrctl --wallet importprivkey "<result>" true
- Ethereum (store result in file):
geth account import key.eth
In Bitcoin and Zcash, the amount received by the address will appear as unspent with listunspent
and it can be moved out of the address by creating a raw transaction. For example:
$ zcash-cli createrawtransaction '[{"txid":"<txid_as_shown_by_listunspent>", "vout":<vout_shown_for_the_chosen_tx_in_listunspent>"}]' '{"<destinationaddress>":"<amount - fee>"}'
<raw_tx>
$ zcash-cli signrawtransaction "<raw_tx>"
{
"hex": "<signed_tx>",
"complete": true
}
$ zcash-cli sendrawtransaction "<signed_tx>"
In Ethereum, the imported key will become a new account which can be handled like any other accounts in geth
.
In Decred, the imported key will become part of the imported
pseudo-account and the associated credits will be shown as spendable and can be used as normal.