from mnemonic to hashing ripemd160
I'll use links to technical articles to minimize this since that's longer than you think:
Electrum will have to derive your 'Master Private Key' to start its keypool derivation.
From your 12-word 'Seed Phrase', it does these exact steps to get your 'Seed' except the default passphrase is "
electrum" instead of "
mnemonic".
Mnemonic to Seed:
https://learnmeabitcoin.com/technical/keys/hd-wallets/mnemonic-seed/#mnemonic-to-seedWith the 'Seed', create the 'Master Private Key'.
Seed to Master Private Key:
https://learnmeabitcoin.com/technical/keys/hd-wallets/extended-keys/#master-extended-keyThen with the Master Private Key (
m), derive the Extended Private Key at:
m/0h.
Notes: You can get it with
getmasterprivate() command in the console or CLI (
Electrum calls it "Master Private Key");
Its pair 'Master Public Key' can seen in "
Wallet->Information" window and its derivation path.
With the Extended (
Master) Private Key (
m), derive the 1st to 20th receiving addresses with the derivation path:
m/0/0 to
m/0/19And the 1st to 10th change address with the derivation path:
m/1/0 to
m/1/9 (
generate more if the last one is used)
(
you can check that with each address' "Right-click->Details" in 'Addresses' tab)
Child key derivation is explained here:
https://learnmeabitcoin.com/technical/keys/hd-wallets/extended-keys/#child-key-derivationBut since you're going to create a tool, skip the terminologies used by Electrum and go straight from the actual master private key created from the seed.
Which gives you the derivation path: Seed --seed-to-master-prvKey--> m/0h/0/0 (
for the first receiving address) and m/0h/1/0 (
for the first change address)
With the child private key of your (
first) address derived, calculate its pair Public key in compressed format.
More info here:
https://learnmeabitcoin.com/technical/keys/public-key/With that compressed public key, encode the Native SegWit (
bech32 - P2WPKH) address.
Bech32 encoded address step by step guide:
https://bitcointalk.org/index.php?topic=4992632.0Tool:
https://learnmeabitcoin.com/technical/keys/address/#p2wpkh
Note: Those are specific to the latest default "
Standard" wallet, other wallet types including "
old" and legacy p2pkh electrum wallet have different derivation path from m.