WIF = base58check encode ([version byte][private key][checksum])
version byte = 80 for mainnet, ef for testnet and regtest
checksum = first 4 bytes of double SHA256 of private key
In this example
-
private key = 619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb9
> export PRIV_KEY=619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb9
Add version byte in front of private key (ef for regtest)
> export VER=ef
> echo ${VER}${PRIV_KEY}
ef619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb9
Network | Version Byte (Hex) |
---|---|
mainnet | 80 |
testnet | ef |
regtest | ef |
> echo ${VER}${PRIV_KEY} -n | xxd -r -p | openssl dgst -sha256 -binary | openssl dgst -sha256
5ea6574663729d86cdc55bc9b7b47eda13a7ae8e4c7bc7084e248f8ddd755cbc
Take the first 4 bytes of the double SHA256 hash
5ea65746
> export CHECKSUM=5ea65746
> echo ${VER}${PRIV_KEY}${CHECKSUM}
ef619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb95ea65746
4. Convert to Base58Check (encoder)
92KuV1Mtf9jTttTrw1yawobsa9uCZGbfpambH8H1Y7KfdDxxc4d
In bitcoin-qt console
> importprivkey 92KuV1Mtf9jTttTrw1yawobsa9uCZGbfpambH8H1Y7KfdDxxc4d "test-priv-key"
null
> getaddressesbyaccount "test-priv-key"
[
"mi7uHKSho5sj9EwN8Tat4GuLu5ZjbJqT4Q"
]