[How-To] Ways to use 12 word seeds (BIP39) in Bitcoin Core v22.0 (testnet)

[How-To] Ways to use 12 word seeds (BIP39) in Bitcoin Core v22.0 (testnet)

^(Disclaimer: BIP39 does not backup wallet metadata (scripts), so not all “restorations” will work. And if they do, rescans may be needed and exiting labeling won’t be restored)

Here are a few ways, some good, and some bad, to use BIP39 in conjunction with Bitcoin-Core. You should note that the generation of these BIP39 seeds is done outside of Bitcoin-Core so should be thought of as insecure as a general rule. I provide a way to do it in Electrum on tails, so that may help.

BIP39 is a simple way to encode a secret into a mnemonic. This is useful for memorization and archiving. The BIP39 process converts this mnemonic + passphrase combination into a seed used in BIP32, BIP44, BIP49, BIP84 and BIP86.

Bitcoin Core supports a variety of wallets, but a simple classification of them would be “Legacy” (P2PKH), “Legacy Segwit” (P2SH-P2WPKH), “Native Segwit” (P2WPKH) and “Taproot” (P2TR). And these 4 wallet types are supported by two formats, “Conventional” (Berkley-DB) and “Descriptor” (SQLite DB). Descriptor wallets can support all 4 types, and Conventional wallets do not support Taproot. Unless you run Bitcoin-Core in “nowallet” mode, you are defaulted with a Native-Segwit conventional wallet.

Descriptor wallets use a BIP32-Extended-Privte-Key (tprv). BIP39 is well formed to feed secrets into BIP32, so pairing BIP39 and BIP32 is pretty easy. Conventional wallets, on the other-hand, require a 128-bit seed called “hdseed” in WIF encoding. This is the same format that bitcoin private keys are in. Unfortunately BIP39 usually outputs a 512-bit seed not a 128-bit seed. So a bit of “creativity” is required. “Creativity” is a curse word in standards and cryptography so my creative approaches are the “bad-kind”.

So here are three ways you can use 12-word seeds for simple backup in Bitcoin-Core:

1. Pair a [HW wallet](

Christmas Hardware Wallet Nov 2021 pricelist from Bitcoin

) to Bitcoin-Core, since most already work on BIP39
2. Make a [descriptor wallet](
), since you can easily go from BIP39 to BIP32
3. Use a “creative” approach to cherry-pick a WIF from a BIP39 derivation

### #1 – Pairing with HW wallet

This is usually done with [HWI](
). Some people have forked the code and used it in a nice skinned GUI, but I can’t recall the name. Maybe someone can post it here. I did it all through command-line and did a fairly [detailed writeup](

Windows / Linux Guide to using Trezor with Bitcoin Core (HWI) from Bitcoin

). It’s pretty easy, just hard to guess the skillset of the reader.

### #2 – Make a descriptor wallet

Descriptor wallets are all pretty straightforward. You simply use BIP39 to make a 512-bit seed, and use it with BIP32 to create a tprv. I have a fairly detailed [writeup on it for Taproot](

[HowTo] Create and use a Taproot wallet on Testnet in Bitcoin Core v22.0 from Bitcoin


### #3 – “Creative” cherry-picked WIF

This will not cover Taproot since those wallets must be descriptor wallets currently. I remind you that creativity is bad, but here’s the basic approach. Simply create a traditional BIP39 wallet and use the “first” address at the standard derivations for legacy (`m/44’/1’/0’/0/0`), legacy-segwit (`m/49’/1’/0’/0/0`), and native-segwit (`m/84’/1’/0’/0/0`) specs. Here’s what you will need to do:

1. Perform steps [I, II, and III](

[HowTo] Create and use a Taproot wallet on Testnet in Bitcoin Core v22.0 from Bitcoin

) my taproot writeup
2. Replace “bech32m” in step III with “legacy”, “p2sh-segwit”, or “bech32” as needed
3. Perform step [IV.1, IV.2, IV.3](

[HowTo] Create and use a Taproot wallet on Testnet in Bitcoin Core v22.0 from Bitcoin

) from my taproot writeup
4. On [Ian’s site](
), pick tab “BIP44”, “BIP49”, or “BIP84” for legacy, legacy-segwit, or native-segwit
5. Copy the the first private key WIF for each tab as your hdseed
6. In Bitcoin-Core, choose “Create Wallet” from the “File” menu
7. Select “Make Blank Wallet”, name and create your wallet
8. Open the Bitcoin-core console and ensure the wallet selector is on your wallet
9. Run the `sethdseed true “__WIF__”` replacing “__WIF__” with the WIF from step #5

If you read the full (long) taproot writeup referenced earlier, this might make more sense. I provide more detail on similar steps.

### Simpler Shortcut

Most of this can be done pretty simply in python, and [here are 40 lines](https://github.com/brianddk/reddit/blob/7c985ea/python/hdseed.py) to do it, but running python code to make private keys is sketchy. To this point, I wrote this to work against the electrum libraries and can be run inside the electrum wallet directly. And electrum is pre-installed in tails, so perhaps that is simpler for you, IDK. But only run this script if you understand the 40 lines being run. The point is to put you more at ease, not less at ease.

1. Download the script to `C:WindowsTemphdseed.py` (or wherever)
2. Review the 40 lines and ensure you understand enough to decide if it is safe
3. Boot tails and launch Electrum on Testnet (not mainnet)
4. Copy the script to tails (`/tmp/hdseed.py`)
5. In Electrum open the console
6. In the Electrum console run the command below:

`with open(“/tmp/hdseed.py”) as f: exec(f.read())`

You should get a seed mnemonic, a `tprv` for descriptor wallets, and three hdseeds for conventional wallets.

View Reddit by brianddkView Source

Post Views:

Source link


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *