<html><head></head><body>
    <font size="-1">Hi Michele,<br/>
      <br/>
      You are seeing this discrepancy due to the address types in use.
      addmultisigaddress uses the default address type of the wallet,
      which is p2sh-segwit. createmultisig uses a default address type
      of legacy. To have createmultisig get addmultisigaddress&#39;s result,
      you need to add the string &#34;p2sh-segwit&#34; to the end of your
      command. To have addmultisigaddress get createmultisig&#39;s result,
      you need to add the string &#34;legacy&#34; to the end of your command.</font><br/>
    <br/>
    <div class="moz-cite-prefix">On 4/19/19 7:53 AM, Michele Federici
      via bitcoin-dev wrote:<br/>
    </div>
    <blockquote type="cite" cite="mid:298ab7b97f0f34b6ef0e4b8345a942b3d77296d5.camel@federici.tech">
      <pre class="moz-quote-pre" wrap="">Hi everyone,

I&#39;m writing here because I didn&#39;t find any resources in the docs or
somewhere else online explaining this, I don&#39;t get if this is a bug or
I&#39;m missing something.

I was working on a function to derive the pay-to-script-hash from a
multisig script and I was checking the results against the bitcoin
core&#39;s `addmultisigaddress` output, although I was quite sure that my
implementation was correct, my output address was different.
By chance, I then tried the `createmultisigaddress` method, using the
same public keys, and this time the output was matching with mine.

I thought the outputs of `addmultisigaddress` and
`createmultisigaddress` were supposed to be the same, but instead are
inconsistent from each other:

```
bitcoin-cli addmultisigaddress 1
&#39;[&#34;045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0c
e382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d&#34;,&#34;02ac46
c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831&#34;,&#34;0224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07&#34;]&#39;
{
&#34;address&#34;: &#34;36ULucjWUTrDvaJzCyhFoVbDoNS6Zum2Du&#34;,
&#34;redeemScript&#34;:
&#34;5141045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c
0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d2102ac4
6c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831210224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e0753ae&#34;
}
```

```
bitcoin-cli createmultisig 1
&#39;[&#34;045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0c
e382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d&#34;,&#34;02ac46
c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831&#34;,&#34;0224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07&#34;]&#39;
{
&#34;address&#34;: &#34;3GiimyxF1R5VixfBFAbQZbuy9EesD2r6n1&#34;,
&#34;redeemScript&#34;:
&#34;5141045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c
0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d2102ac4
6c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831210224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e0753ae&#34;
}
```

I was also pretty confused by the fact that the `redeemScript` is the
same, only the addresses are different, and calling `decodescript` with
it I get the same address as `createmultisig`:

```
bitcoin-cli decodescript
&#34;5141045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c
0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d2102ac4
6c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831210224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e0753ae&#34;
{
&#34;asm&#34;: &#34;1
045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0ce38
2458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d
02ac46c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831
0224a4dc5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07 3
OP_CHECKMULTISIG&#34;,
&#34;reqSigs&#34;: 1,
&#34;type&#34;: &#34;multisig&#34;,
&#34;addresses&#34;: [
&#34;12PfkcWheYsfFddWfHhaXpFDVx78gnKQ9k&#34;,
&#34;1AYLXzXd6N2avqW4j8Gyhb8jb2jXvNPyuV&#34;,
&#34;1PWsxtcBMRHTSX2L7wrXgwnFigHD3KhbFT&#34;
],
&#34;p2sh&#34;: &#34;3GiimyxF1R5VixfBFAbQZbuy9EesD2r6n1&#34;
}
```

I don&#39;t understand, how can this be possible?

Thank you,
Michele
_______________________________________________
bitcoin-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@lists.linuxfoundation.org</a>
<a class="moz-txt-link-freetext" href="https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev">https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev</a>
</pre>
    </blockquote>
    <br/>
  

</body></html>