Same question as What BIP32 derivation path does Electrum use?
but for multisig. thanks.
Electrum uses BIP45.
m / purpose' / cosigner_index / change / address_index
Example for non-change of the first cosigner and first address: m / 45' / 0 / 0 / 0
See: https://bitcointalk.org/index.php?topic=1634517.15 and https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki
After a lot of struggle, I found out that Electrum uses following root derivation for normal and multisig wallets. For example:
root/0/0
for each cosigner. Example:
m/44'/0'/0'
==> shared root key (x)
x/0/0
==> address for first receiving multisig (derive in all cosigners shared keys. all 3 keys must be lexicographically ordered).
some semi-compatible form of BIP45 for hardware wallets. Didn't test it but here's the code: https://github.com/spesmilo/electrum/blob/master/lib/base_wizard.py#L220
refs:
What BIP32 derivation path does Electrum use?
Here's a descriptor for a 2-of-3 created by Electrum.
Receive addresses:
sh(sortedmulti(2,XPUB_1/0/*,XPUB_2/0/*,XPUB_3/0/*))
Change addresses:
sh(sortedmulti(2,XPUB_1/1/*,XPUB_2/1/*,XPUB_3/1/*))
(Replace XPUB_1
, XPUB_2
, and XPUB_3
with your three master public keys )
Here is what works for me when using bip32gen from bip32utils to generate the public keys which are used in the transaction, starting from an xprv master key.
For each xprv master key of a cosigner, use 0/0 for the first receiving address, 0/1 for the second, 1/0 for the first change address, 1/1 for the second change address.
Then use the corresponding public key for each cosigner, sorted into lexicographic order, when constructing the redeem script, and generate the corresponding p2sh address for each address which will be generated by Electrum.
So far as I can tell, there are no purpose codes or cosigner index, as per BIP44 or BIP45. This is with Electrum 3.2.3.
refs: https://bitcointalk.org/index.php?topic=1819380 https://bitcointalk.org/index.php?topic=1816926.msg18101203#msg18101203
See this other stackexchange discussion: What BIP32 derivation path does Electrum use?