I was analyzing a Bitcoin transaction that works both with Segwit and non-Segwit for multisig Scripts. Here is the transaction: https://www.blockchain.com/en/btc/tx/80975cddebaa93aa21a6477c0d050685d6820fa1068a2731db0f39b535cbd369

Note that on indexes 0, 1 and 2 we have the unlocking script in the scriptsig filed and on index 3 it is using witness program. No problems until now.

What is bugging me is why when I get the redeem script from indexes 0, 1 and 2 and execute the ripemd60, sha256, create checksum and encode to base58 it generates the Public address as we can see in the screen of blockchain.com. But when I do the very same thing using the redeem script which is in the witness section, it returns to me a completely different address, why is that happening?

Also, what is the scriptSig on the index 3? How it is generated?


Redeem Script of index 0:


The address generated from index 0 using my script:


It is the same as the transaction.

Redeem Script of index 3 (Segwit):


The address generated from index 3 using my script:


Address from the transaction recovered from blockchain.com


1 Answer 1


You are computing just the P2SH address for the segwit script. However it is not just P2SH, it is a Segwit script wrapped inside of a P2SH. You actually have to first take the witnessScript (the multisig script or segwit redeemScript) and make a P2WSH output script with it. Then this script becomes the redeemScript for the P2SH script.

So given


as the witnessScript, you produce


as the redeemScript. This is a P2WSH output script. This is then hashed to create the hash in the P2SH script:


which has an address of

  • Is there any BIP that defines it? Feb 18, 2020 at 15:59
  • 1
    BIP 141.
    – Ava Chow
    Feb 18, 2020 at 16:04
  • So for us to generate the redeemScript from witnessScript we need to ripemd160 them? Feb 18, 2020 at 16:17
  • No. You have to SHA256 the witnessScript. Then put that into a p2wsh script. Then hash160 that script for the p2sh address.
    – Ava Chow
    Feb 18, 2020 at 16:39
  • For native Segwit we don't need this right? Since we won't have the sigScript field anymore. Feb 18, 2020 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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