Parsing an input script of a transaction, I’ve come across two public keys in the script. Either public key is 33 byte long.

I know how to transform a single 33 byte long public into an address.

What is the mechanism of obtaining an address from two or more public keys?

Note I’m not interested in the bitcoind technique via the createmultisig command.


I answer my question for the benefit of future generations of readers.

If you have only one 33-byte-long public key, you obtain an address by applying a standard technique that consists of 5-7 steps, depending on how you view the technique.

If you have more than one 33-byte-long public keys, you have to construct a so-called redemption script or, in bitcoin parlance, redeemscript. After you’ve constructed the redemption script, you apply the standard technique to the entire redemption script.

Technically, a redemption script is a byte array. Suppose you have two public keys. Conceptually, your byte array should look like this:

[OP_1][length of public key 1][public key 1][length of public key 2][public key 2][OP_2][OP_CHECKMULTISIG]

In my question, I said that I had parsed the input script of a transaction. Therefore, I didn’t have to construct the array. The redemption-script array was already in the input script. I made a “mistake” of extracting the public keys from the redemption script, believing I should massage only the public keys. I should have taken all the bytes of the redemption-script array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.