What is the difference between P2SH redeem script on Bitcoin and on Litecoin?

I am building a service that is based on multisig wallets. My current progress is so that I’ve implemented the multisigs for Bitcoin network and it works fine. Now I am on Litecoin and I am facing some issues and would appreciate any help or guidance on that.

Disclaimer: This may be related to how Electrum-LTC works, I am not sure. I am happy to hear experts oppinion on that.

On Bitcoin network your multisig wallet is composed of 3 parts:

0 <Sig1> <Sig2> ... <SigM>

Redeem script
M <PubKey1> <PubKey2> ... <PubKeyN> N OP_CHECKMULTISIG

OP_HASH160 <Redeem script hash> OP_EQUAL

And that works just fine with my implementation. I can generate 2-of-2 multisig with Electrum (btc) and sign it with both keys, both with my code and with Electrum wallets. Outcome transaction in both cases is correct and accepted by network.

Now, for Litecoin I am using Electrum-ltc and the process is exactly the same. I can successfully generate multisig address on Litecoin

Suppose I Have following  Redeem script
2 028c895128a8113bb5d599b4f463df685220ba726fc664013b3df56cb0bae74dc4 02c09fdcf2cd2281ac5d35dedb8b19499db847fad469c151428d28c9cf1aabf435 2 OP_CHECKMULTISIG

The address I see in Electrum-ltc matches the one I generated myself which tells me I am on the right way.

However, when I sing a transaction with wallet a redeem script in the transaction hex looks totally different and does not match my manually generated redeem script

Manually generated redeem script

broken apart
52 - OP_2
21028c895128a8113bb5d599b4f463df685220ba726fc664013b3df56cb0bae74dc4 - PubKey1
2102c09fdcf2cd2281ac5d35dedb8b19499db847fad469c151428d28c9cf1aabf435 - PubKey2
52 - OP_2

And here is a redeem script that I get from Electrum-ltc once I signed transaction with one key


broken apart
52 - OP_2
52 - OP_2

So, what this thing the middle? And why it does not match my redeem script? Is this a bug with Electrum-ltc or I am missing something. Would appreciate any feedback.

Source link

Leave a Comment

Your email address will not be published.