<p>See <a href="https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki" rel="nofollow noreferrer">BIP45</a>.</p>

<p>Electrum is ordering the pubkeys lexicographically, ie </p>

<ol>
<li><code>03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed</code></li>
<li><code>03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d5</code></li>
<li><code>03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a</code></li>
</ol>

<p>Note they're all <code>03</code>, so it's <code>72=&gt;f5=&gt;f9</code></p>

CC BY-SA 3.0
2017-03-08T12:54:30.423Z
Maybe you mean BIP45. "The indices can be determined independently by lexicographically sorting the purpose public keys of each cosigner." https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki
joe.js
CC BY-SA 3.0
2015-09-04T03:39:37.827Z
2017-03-09T00:34:47.917Z
2017-03-09T00:34:47.917Z
Wizard Of Ozzie
<p>Looking to create 2 of 3 multisig addresses with the electrum console with public keys (not the master public keys):</p>

<pre><code>electrum createmultisig 2 '["1st public key wallet 1", "1st public key wallet 2", "1st public key wallet 3"]'
</code></pre>

<p>This will out put an p2sh address and a redeemScript. The address however only match the first address in an electrum 2 of 3 multisig wallet if public keys are entered in the right order (that has a one in six chance).  </p>

<p>Electrum's 2 of 3 multisig wallets have consistent p2sh addresses no matter what order the master public keys are entered. How can createmultisig be used to be consistent with electrum's multisig wallets?</p>

<p>Edit: The suggested answer is the <code>addmultisigaddress</code> command from bitcoin-core (as I understand it correctly), thank you for the suggestion. However the question was how to do so with Electrum console (if possible).</p>

<p>The question is how to (re)create the correct first p2sh address of Electrum's multisig (2 of 3) wallet with master public keys as input, with only the first public keys of each of the master public keys and be consistent with Electrum's multisig (2 of 3) wallet all the time.  </p>

<p>Edit2: An example with actual master public keys and there public keys:  </p>

<pre><code>Master public key a: xpub661MyMwAqRbcFRS9DDMPDGhicAnYcsELaWwWSviE3nETgBBW6P6FqXCxDobD9h1BqXbjbMEsXkeXyrLUmxANvBw9hi4jxZKjLDyZk3hK7nT  
a's first public key a1: 03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed

Master public key b: xpub661MyMwAqRbcEqNp5KidkrqspVy5HmMTwuQguSa8LSu6WWDdYMMD13appqVrMgAZyc5FKxSnxuTqNoT2j9PYtFtF67MUNBEzifV6vnd5qW2  
b's first public key b1: 03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a

Master public key c: xpub661MyMwAqRbcEpBbahsh3vPcooVMbEfKAWCx7VNAyGokuShDN2FocJEa7mkcSAkWbkhbewN9TBW9AkoSJPGJoktCXZL98BGTCdZaspiebrA  
c's first public key c1: 03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f
</code></pre>

<p>The electrum's (GUI) option to create a multisig (2 of 3) wallet will take master public key a,b and c in any order and give a wallet with the first p2sh address: </p>

<pre><code>3HRmAEyoBwdHhdntJHFMeR8DxZyCgiaKzV
</code></pre>

<p>Electrum's console command createmultisig will output different p2sh address depending on the order of public keys. Trail and error will get the same p2sh address as the GUI, however my goal is to get the correct address without verifying consistently. </p>

<p>With <code>'["a1", "b1", "c1"]'</code>:  </p>

<pre><code>electrum createmultisig 2 -o '["03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed", "03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a", "03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f"]'

    {
    "address": "3EKHKsgn2smYcpeiD6zfR9sgrEp6PrqCTw", 
    "redeemScript": "522102ae1359d50bdc7d5b61c3bab9f293fc01cdab3c2b1151a7309fb2e28540d94e842102b0b20cb5e55204f63c016c3df94c3aadaed931370e49bb94097c97dff485032d2103d5196cd7f661deedb3f27fce93095554e72032c7fd26b1ddfaeac8d6f5d56d0553ae"
}
</code></pre>

<p>With <code>'["a1", "c1", "b1"]'</code>:  </p>

<pre><code>electrum createmultisig 2 -o '["03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed", "03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f", "03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a"]'

{
    "address": "3HRmAEyoBwdHhdntJHFMeR8DxZyCgiaKzV", 
    "redeemScript": "522103722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed2103f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f2103f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a53ae"
}
</code></pre>

<p>In this example I got "lucky" after the 2nd try and get the same p2sh address after 2 tries of the possible 6 permutations. My question however is how to get the correct order of public keys without verifying the GUI multi (2 of 3) wallet?</p>

CC BY-SA 3.0
2015-09-03T21:10:24.620Z
Are you seeking to use bitcoin-core's addmultisigaddress in a way consistent with electrum, or to use electrum's createmultisig in a way consistent with bitcoin-core?
Nick ODell
CC BY-SA 3.0
2015-09-03T21:17:52.423Z
Neither. Seeking to use electrum's createmultisig (console) to be consistent with electrum's multisig wallet (GUI). Want to get the first p2sh address of the electrum's multisig wallet (GUI) by using the first public key of each master public key used to create the electrum's multisig wallet (GUI) with electrum's createmultisig (console). The problem I encounter is that the multisig wallet accept master public key a,b and c in all possible orders and give the same first p2sh address. The createmultisig command with a1, b1 and c1 only one of the permutations give the same p2sh address
electrum question
<electrum><multi-signature>
How to create the same (2 of 3) multisig adresses as electrum's multisig wallets with createmultisig?
electrum question
# How to create the same (2 of 3) multisig adresses as electrum's multisig wallets with createmultisig?

(Asked by: username_0 on 2015-09-03)

Looking to create 2 of 3 multisig addresses with the electrum console with public keys (not the master public keys):
electrum createmultisig 2 '["1st public key wallet 1", "1st public key wallet 2", "1st public key wallet 3"]'

This will out put an p2sh address and a redeemScript. The address however only match the first address in an electrum 2 of 3 multisig wallet if public keys are entered in the right order (that has a one in six chance).  
Electrum's 2 of 3 multisig wallets have consistent p2sh addresses no matter what order the master public keys are entered. How can createmultisig be used to be consistent with electrum's multisig wallets?
Edit: The suggested answer is the addmultisigaddress command from bitcoin-core (as I understand it correctly), thank you for the suggestion. However the question was how to do so with Electrum console (if possible).
The question is how to (re)create the correct first p2sh address of Electrum's multisig (2 of 3) wallet with master public keys as input, with only the first public keys of each of the master public keys and be consistent with Electrum's multisig (2 of 3) wallet all the time.  
Edit2: An example with actual master public keys and there public keys:  
Master public key a: xpub661MyMwAqRbcFRS9DDMPDGhicAnYcsELaWwWSviE3nETgBBW6P6FqXCxDobD9h1BqXbjbMEsXkeXyrLUmxANvBw9hi4jxZKjLDyZk3hK7nT  
a's first public key a1: 03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed

Master public key b: xpub661MyMwAqRbcEqNp5KidkrqspVy5HmMTwuQguSa8LSu6WWDdYMMD13appqVrMgAZyc5FKxSnxuTqNoT2j9PYtFtF67MUNBEzifV6vnd5qW2  
b's first public key b1: 03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a

Master public key c: xpub661MyMwAqRbcEpBbahsh3vPcooVMbEfKAWCx7VNAyGokuShDN2FocJEa7mkcSAkWbkhbewN9TBW9AkoSJPGJoktCXZL98BGTCdZaspiebrA  
c's first public key c1: 03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f

The electrum's (GUI) option to create a multisig (2 of 3) wallet will take master public key a,b and c in any order and give a wallet with the first p2sh address: 
3HRmAEyoBwdHhdntJHFMeR8DxZyCgiaKzV

Electrum's console command createmultisig will output different p2sh address depending on the order of public keys. Trail and error will get the same p2sh address as the GUI, however my goal is to get the correct address without verifying consistently. 
With '["a1", "b1", "c1"]':  
electrum createmultisig 2 -o '["03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed", "03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a", "03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f"]'

    {
    "address": "3EKHKsgn2smYcpeiD6zfR9sgrEp6PrqCTw", 
    "redeemScript": "522102ae1359d50bdc7d5b61c3bab9f293fc01cdab3c2b1151a7309fb2e28540d94e842102b0b20cb5e55204f63c016c3df94c3aadaed931370e49bb94097c97dff485032d2103d5196cd7f661deedb3f27fce93095554e72032c7fd26b1ddfaeac8d6f5d56d0553ae"
}

With '["a1", "c1", "b1"]':  
electrum createmultisig 2 -o '["03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed", "03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f", "03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a"]'

{
    "address": "3HRmAEyoBwdHhdntJHFMeR8DxZyCgiaKzV", 
    "redeemScript": "522103722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed2103f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d519f2103f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a53ae"
}

In this example I got "lucky" after the 2nd try and get the same p2sh address after 2 tries of the possible 6 permutations. My question however is how to get the correct order of public keys without verifying the GUI multi (2 of 3) wallet?

**Tags:** electrum, multi-signature

> **Comments:**
> **username_1**: Are you seeking to use bitcoin-core's addmultisigaddress in a way consistent with electrum, or to use electrum's createmultisig in a way consistent with bitcoin-core?  
> **username_0**: Neither. Seeking to use electrum's createmultisig (console) to be consistent with electrum's multisig wallet (GUI). Want to get the first p2sh address of the electrum's multisig wallet (GUI) by using the first public key of each master public key used to create the electrum's multisig wallet (GUI) with electrum's createmultisig (console). The problem I encounter is that the multisig wallet accept master public key a,b and c in all possible orders and give the same first p2sh address. The createmultisig command with a1, b1 and c1 only one of the permutations give the same p2sh address  

---

## 1 answers

### Answer by username_2 on 2015-09-04. Score: 7

See [BIP45](https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki).

Electrum is ordering the pubkeys lexicographically, ie

1. `03722ef79a70b43843c642f3495d2b9b8a6403189d52a04ecac652c133f7940fed`
2. `03f5ce19296793c6695bfefd7ead459a3f88ef776d8fc08b470dbc749d266d5`
3. `03f9652bfbbfb426eb2011db774c97866e00effdf954cc225807f89b23150dda3a`

Note they're all `03`, so it's `72=>f5=>f9`

> **Comments:**
> **username_3**: Maybe you mean BIP45. "The indices can be determined independently by lexicographically sorting the purpose public keys of each cosigner." https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki  

---

