Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: tekbe on May 05, 2019, 01:22:51 PM



Title: Create Bitcoin Core hd wallet from word list / mnemonic
Post by: tekbe on May 05, 2019, 01:22:51 PM
To have a way of (re-)creating Bitcoin Core wallets out of a word list I wrote a bash script.

https://github.com/tekbe/wallet-tools (https://github.com/tekbe/wallet-tools)

How it works:

  • Bitcoin Core allows you to create a deterministic wallet (https://en.bitcoinwiki.org/wiki/Deterministic_wallet) from a seed
  • Bitcoin Explorer (https://github.com/libbitcoin/libbitcoin-explorer) allows you create such seeds from a word list

This can basically be done with two lines in the terminal:

Code:
$ echo "my random and secret word list" | bx mnemonic-to-seed | bx hd-new | bx hd-to-ec | bx ec-to-wif
L26zbMQRXyhUaaHcTQ13mzHWBauMPsG2qrmZQHx5QpYmMMFkhcWn
$ bitcoin-cli sethdseed true "L26zbMQRXyhUaaHcTQ13mzHWBauMPsG2qrmZQHx5QpYmMMFkhcWn"

A random word list can also be created with Bitcoin Explorer:

Code:
$ bx seed | bx mnemonic-new
sadness arrow artefact expect office carry fatal tape radar ladder dirt hawk echo bone exile uphold topple local

The script provides some extra convenience. Hope it's useful.


Title: Re: Bitcoin core hd wallet from mnemonic
Post by: tekbe on May 06, 2019, 02:23:56 AM
i wonder why you use mnemonic seed with 18 words which isn't common?

The readme was misleading: 9, 12, 15, 18 or 21 words are fine (everything that "bx mnemonic-to-seed" accepts as input).


Title: Re: Bitcoin core hd wallet from mnemonic
Post by: croxNN on August 31, 2019, 08:45:37 AM
Hello all!

I'm trying understand HD wallets in bitcoin core implementation and got stuck. Here it is:

$ bx seed | bx mnemonic-new -l en
reward awake later spot grass list peanut clog hurry guess question father leg dress only reunion horn napkin

$ echo "reward awake later spot grass list peanut clog hurry guess question father leg dress only reunion horn napkin" | bx mnemonic-to-seed | bx hd-new | bx hd-to-ec | bx ec-to-wif
L1G3dzjDmkPNkrYLs2L9pTbF9BZ4XThqkXVtDxcrP887uPYRjriG

That WIF key L1G3dzjDmkPNkrYLs2L9pTbF9BZ4XThqkXVtDxcrP887uPYRjriG should be ok for sethdseed? Right?

So next:
$ bitcoin-cli createwallet test
{
  "name": "test",
  "warning": ""
}


$ bitcoin-cli -rpcwallet=test sethdseed true L1G3dzjDmkPNkrYLs2L9pTbF9BZ4XThqkXVtDxcrP887uPYRjriG
error code: -5
error message:
Invalid private key


What's wrong?

Thanks in advance.


Title: Re: Bitcoin core hd wallet from mnemonic
Post by: croxNN on August 31, 2019, 09:01:15 AM
UPD: Resolved. It needs to use  -v 239 for testnet in bx ec-to-wif command