createMultiSigOutputScript with Addresses not ECKeys

24 views
Skip to first unread message

vg-coder

unread,
Nov 22, 2017, 9:44:25 AM11/22/17
to bitcoinj
Hi all!

I am testing some easy smart contracts and I got a doubt. Why do we need the ECKey in createMultiSigOutputScript instead of using Address?
Is there no way to achieve the same with the addresses instead of using keys?, since normally, between two parties, we interchange addresses not public keys.

Kind regards,

Ishmael Riles

unread,
Dec 4, 2017, 2:19:51 PM12/4/17
to bitcoinj
The multisig script is created from the public keys. An address is a hash of the public key, the hash goes only one way so you can not derive the public key from the address.

vg-coder

unread,
Dec 5, 2017, 3:23:56 AM12/5/17
to bitcoinj
Thanks for the answer Ishmael. However, that is not exactly the answer that I was looking for. I guess that my question was not deep enough and not properly asked. I'll rephrase:

In a common ScriptPubKey to pay a single recipient, we use the bitcoin address (hash of the public key):
scriptPubKey: OP_HASH160 <scriptHash> OP_EQUAL 

However, in a multisig (what I guess that createMultiSigOutputScript creates), the Script requires the public keys:
script: OP_m <pubKey1> ... OP_n OP_CHECKMULTISIG

Since I guess that there is no way to do a multisig with bitcoin addresses instead of public keys, then my question is: why was this created like that?,
instead of being more consistent and using addresses like in the scriptPubKey?

Kind regards,
V

Ishmael Riles

unread,
Dec 9, 2017, 1:28:58 AM12/9/17
to bitc...@googlegroups.com
I'm not an expert in bitcoinj or bitcoin script but I know that the redeem scripts for multi sig p2sh address and pay-to-pub-key-hash addresses both require public key(s). You need them to verify the signatures, so it kind has to work like that.

Also, in both cases the scriptPubKey only requires a hash. For p2sh it's a hash of the script that contains public keys (in most cases) or with p2pkh it's just a hash of the public key.



--
You received this message because you are subscribed to a topic in the Google Groups "bitcoinj" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bitcoinj/_kfzvTAFUZs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitcoinj+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages