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.
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.
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.
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!