litecore-archive / litecore

A full stack for litecoin and blockchain-based applications
https://litecore.io/
Other
45 stars 47 forks source link

M addresses don't work #5

Closed karelbilek closed 7 years ago

karelbilek commented 7 years ago

For some reason, M-addresses don't work with insight, insight-api and litecore websocket API

example: this transaction is displayed with the M addresses

https://insight.litecore.io/tx/c9403d4bc1a09bb52cf8c5db5e0e3ecf38dfd22c83610fb1c6416d665a240040

but clicking on any of the addresses shows an error

https://insight.litecore.io/address/MUbHn23ZL733kCUbvQ88ZhVSWMdFQMEoV8

If I instead get the 3-address, it doesn't work either.

https://insight.litecore.io/address/3NP9U8dbNzBcwhChpX8nk4F3Bf2oSucXj1

This also applies to all the API calls (I think it is the same error). I can't find where it is at the bitcore stack right now exactly.

karelbilek commented 7 years ago

A-ha, I got it. The error is actually from the c++ layer, not from the javascript layer.

It's because litecore is downloading this litecoin-litecore version

https://github.com/litecoin-project/litecore-litecoin/commits/v0.13.2.1-litecore-rc1

that's outdated and doesn't have the new address prefix.

losh11 commented 7 years ago

Just ran litecoin-litecore 0.13.2.1 rc1 on my system, all multisig addresses seem to be working correctly.

createmultisig 2 '["LUww6kWcvyxpNhXMQuXw34Pu7RVYJ5jEfq","LZDaX6KgLtRaM7ZN29Di74iMTqrezj6NbZ","LXVL1huTGYgzUvumRxVpbiWVwT9Nj7vhvk"]'

{
  "address": "MVCNRYZhAY9FAR2UkcnJkn1jvanTP1QES1",
  "redeemScript": "522103ac93aef434de5b030eafdb030e4db43ba563c1414f21495834fece5ff03394c1210383f7fdb75a64d511451d542eb3924dc0d48f6e58fc8142eefbe7d9e5ac915eaa21029f078983a908cd962a9d0f206f931561c7e57d1939c9eb9eb1034053e2987c7c53ae"
}

Are you sure that's the issue?

karelbilek commented 7 years ago

Interesting. But the error seems to be from litecoind somehow...

On May 11, 2017 7:41 PM, "Loshan T" notifications@github.com wrote:

Just ran litecoin-litecore 0.13.2.1 rc1 on my system, all multisig addresses seem to be working correctly.

createmultisig 2 '["LUww6kWcvyxpNhXMQuXw34Pu7RVYJ5jEfq","LZDaX6KgLtRaM7ZN29Di74iMTqrezj6NbZ","LXVL1huTGYgzUvumRxVpbiWVwT9Nj7vhvk"]'

{ "address": "MVCNRYZhAY9FAR2UkcnJkn1jvanTP1QES1", "redeemScript": "522103ac93aef434de5b030eafdb030e4db43ba563c1414f21495834fece5ff03394c1210383f7fdb75a64d511451d542eb3924dc0d48f6e58fc8142eefbe7d9e5ac915eaa21029f078983a908cd962a9d0f206f931561c7e57d1939c9eb9eb1034053e2987c7c53ae" }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/litecoin-project/litecore/issues/5#issuecomment-300863820, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGZ8VZQA2b4sTTArQzECBYiT3vRrpBaks5r40g2gaJpZM4NYKcC .

losh11 commented 7 years ago

I think it's something to do with insight-api or litecore-lib...

http://insight.litecore.io/api/addr/3NP9U8dbNzBcwhChpX8nk4F3Bf2oSucXj1 API returns Invalid address: Address has mismatched network type.. Code:1

karelbilek commented 7 years ago

Nope, it's indeed an issue with the litecore-litecoin fork.

./litecoin-cli getaddresstxids '{"addresses":["MUbHn23ZL733kCUbvQ88ZhVSWMdFQMEoV8"]}'

error code: -5
error message:
Invalid address

It's probably something with the fact that you have two different P2SH prefixes now and the address index doesn't count with that. Please fix that in the address index patch

karelbilek commented 7 years ago

IMHO it should be enough to add SCRIPT_ADDRESS2 whenever there is SCRIPT_ADDRESS here

https://github.com/litecoin-project/litecore-litecoin/blob/f3b80661ae103a0382ce36de7cc0752c8b83d420/src/base58.cpp

losh11 commented 7 years ago

That's the dev branch (old version), the latest release of litecore-litecoin is from the 0.13-master branch, which hasn't been switched to default yet.

karelbilek commented 7 years ago

There was one place that didn't have the second SCRIPT_ADDRESS which caused the error.

I have fixed the issue and made a PR; I can confirm insight/bitcore works now, including all the websocket APIs (that we need for trezor web wallet :))