According to this example:

Redeem Script: 2 PubKey1 PubKey2 PubKey3 PubKey4 PubKey5 5 OP_CHECKMULTISIG

Locking Script: OP_HASH160 <20-byte hash of redeem script> OP_EQUAL

Unlocking Script: Sig1 Sig2 redeem script

I want to calculate the <20-byte hash of redeem script> with BitcoinJ but i don't know how to do it.

This <20-byte hash of redeem script> is the result of :

RIPEMD160(SHA256(PubKey1.getPublicKeyAsHex() || PubKey2.getPublicKeyAsHex() || PubKey3.getPublicKeyAsHex() || PubKey4.getPublicKeyAsHex() || PubKey5.getPublicKeyAsHex())) or RIPEMD160(SHA256(input))???

The input (which is String type) from above is the concatenation of each public key of all participants in the redeem script.

And if <20-byte hash of redeem script> it is not the result that i mentioned above...how can i estimate this hash with BitcoinJ?

  • 1
    I found that the hash is the hash of the redeem script encoded as hex bytes. I build a redeem script using the ScriptBuilder class and then i got the bytes of the script and perform the sha256 and ripemd160 hashes on those bytes to get the hash. I think this is the whole procedure...if I am not mistaken.
    – gtopal
    Jan 5 '16 at 12:29

Your Answer

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

Browse other questions tagged or ask your own question.