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