Bitcoin Forum
May 10, 2024, 07:19:29 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Ian Coleman BIP39 / Derive P2SH addresses from Electrum generated Seed  (Read 745 times)
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18511


View Profile
June 08, 2020, 12:08:19 PM
 #21

21sats isn't actually creating an Electrum SegWit or Legacy wallet though. He is talking about going through the motions of doing that just so Electrum will generate a seed phrase for him. He then takes that seed phrase and restores a wallet with it, forcing it through as an invalid BIP39 phrase to create a nested SegWit wallet.

nc50lc's instructions are correct if OP has access to his master private key, with with caveat being that it is better to back up a seed phrase than it is a master private key.

The whole set up is still very suboptimal though. Better to just use a valid BIP39 seed.
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715368769
Hero Member
*
Offline Offline

Posts: 1715368769

View Profile Personal Message (Offline)

Ignore
1715368769
Reply with quote  #2

1715368769
Report to moderator
nc50lc
Legendary
*
Offline Offline

Activity: 2408
Merit: 5594


Self-proclaimed Genius


View Profile
June 08, 2020, 12:09:30 PM
 #22

-snip-
If @21sats used only step 1, he already has native segwit right?, step 4 must be select P2WPKH not P2WPKH nested in P2SH
another way if @21sats select legacy in begining, must be select BIP 32 to same with electrum legacy address
As per the first quoted post, 21sats forcibly used a SegWit Electrum seed phrase to create a P2SH-SegWit wallet.
Click the 1st quote in my previous reply to see the full post with the "same steps you've (21sats) mentioned".

He wanted to restore the same address using iancoleman (actually looking for the correct code to edit).
Since the issue was solved by the link, I just gave him a method to use iancoleman to restore those "P2WPKH nested in P2SH"
addresses without editing anything.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
21sats (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 10


View Profile
June 08, 2020, 01:33:25 PM
 #23

The method you used obviously works, but it's generally not recommended.

If you're going to use this method to store your funds there are some factors of which you should make note.  Since you're relying on a specific piece of software to decipher the correct derivation path, it's a good idea to make sure you always have a verified version stored locally.  You should also make backups of your wallet files and store them on another device.  Another pitfall is if you do lose all your backups and have to restore the wallet from the seed phrase several years from now, are you going to remember the steps you took?  You may want to include instructions for yourself and store them with the seed phrase, in case you forget.

If your goal is to have multiple desktop wallets, of different address types, that are all backed-up by one seed, you are probably better off starting with a Bip39 phrase.  The advantage is you can always restore it with many desktop clients or hardware wallets, and they'll be able to determine the correct derivation path without all fuss.  And of course, that includes Electrum.

All good, never stored funds on an Electrum generated wallet and not planing to do so, I just wanted to know how to do all of this out of curiosity. By now I'm using hardware wallets only and also keep my seeds safe in a unqiue way. I already donated to everyone years ago, learned the hard way how important the things you mentioned are. Btw, really appreciate the way you and everyone else is generously helping and answering questions in here!

Actually, you can use iancoleman without changing the source code.
All you need to do is to get your wallet's master private key and click the right options.

As the final goal of all this was to be able to bruteforce a wrong word of an incorrectly remembered 12 word seed phrase created by Electrum, while only knowing the incorrect seed and one correct address, I theoretically wasn't allowed to use the master private key. That's why I needed to go the long way of editing the source code.

Short answer: Electrum seed phrases and BIP39 seed phrases differ in the way they handle passphrases. Since you are entering the seed phrase as a BIP39 phrase, you use the BIP39 method, which uses the word "mnemonic" rather than the word "electrum".

Longer answer: When your seed phrase is used to generate your private keys, the first step is to pass it through a key stretching function called PBKDF2. The PBKDF2 function used has two input parameters. The first input parameter is your seed phrase. The second input parameter for BIP39 seeds is the word "mnemonic" concatenated with your passphrase. You can see this in lines 810 and 811 of the Electrum code here: https://github.com/spesmilo/electrum/blob/9d0bb295e6f55a2bff9f5b6770fa744c16af6e8a/electrum/keystore.py#L810.

Conversely, when using Electrum seeds, instead of using the word "mnemonic", it instead uses the word "electrum" concatenated with your passphrase. See line 164 here: https://github.com/spesmilo/electrum/blob/a0b096dcb2292c2826f7beae173c529d335142f0/electrum/mnemonic.py#L164.

Even although your seed was generated by Electrum, since we are using it as an (invalid) BIP39 seed we need to follow the BIP39 method. This will hold true even if you don't use a passphrase, as the word "mnemonic" will still be used as an input for PBKDF2, just without any additional characters attached.



I would echo DireWolfM14's warning above, though. This is a very non standard way to generate a wallet, and you could run in to serious problems down the line trying to recover it. If you want a P2WPKH-P2SH wallet in Electrum, then the best method is to generate a BIP39 phrase elsewhere and import it.

Got it, thanks again!
Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!