public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* [bitcoin-dev] Using the same public keys, the p2sh returned by `addmultisigaddress` differs from the one returned by `createmultisigaddress`
@ 2019-04-19 11:53 Michele Federici
  2019-04-19 14:30 ` Andrew Chow
  0 siblings, 1 reply; 2+ messages in thread
From: Michele Federici @ 2019-04-19 11:53 UTC (permalink / raw)
  To: bitcoin-dev

[-- Attachment #1: Type: text/plain, Size: 3228 bytes --]

Hi everyone,

I'm writing here because I didn't find any resources in the docs or
somewhere else online explaining this, I don't get if this is a bug or
I'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'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
'["045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0c
e382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d","02ac46
c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831","0224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07"]'
{
"address": "36ULucjWUTrDvaJzCyhFoVbDoNS6Zum2Du",
"redeemScript":
"5141045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c
0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d2102ac4
6c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831210224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e0753ae"
}
```

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

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
"5141045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c
0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d2102ac4
6c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831210224a4dc
5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e0753ae"
{
"asm": "1
045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0ce38
2458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d
02ac46c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831
0224a4dc5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07 3
OP_CHECKMULTISIG",
"reqSigs": 1,
"type": "multisig",
"addresses": [
"12PfkcWheYsfFddWfHhaXpFDVx78gnKQ9k",
"1AYLXzXd6N2avqW4j8Gyhb8jb2jXvNPyuV",
"1PWsxtcBMRHTSX2L7wrXgwnFigHD3KhbFT"
],
"p2sh": "3GiimyxF1R5VixfBFAbQZbuy9EesD2r6n1"
}
```

I don't understand, how can this be possible?

Thank you,
Michele

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-19 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 11:53 [bitcoin-dev] Using the same public keys, the p2sh returned by `addmultisigaddress` differs from the one returned by `createmultisigaddress` Michele Federici
2019-04-19 14:30 ` Andrew Chow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox