Bitcoin Forum
April 02, 2020, 07:01:02 PM *
News: Latest Bitcoin Core release: 0.19.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What happens if I send LTC to a segwit address BTC that starts with 3?  (Read 310 times)
Forsyth Jones
Sr. Member
****
Offline Offline

Activity: 924
Merit: 397


I love Bitcoin!


View Profile WWW
June 12, 2019, 03:12:01 AM
Merited by arthurbonora (1)
 #1

Imagine that someone was withdrawing LTC in exchange and mistakenly copied a bitcoin address segwit-p2sh (starts with 3), has there any way to recover those funds? some way to convert the bitcoin private key to Litecoin (or any other currency that is compatible with P2SH addresses)

OBS: Relax, guys, nobody lost funds, this is just a question that arose in my head like many others, respond without haste
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1585854062
Hero Member
*
Offline Offline

Posts: 1585854062

View Profile Personal Message (Offline)

Ignore
1585854062
Reply with quote  #2

1585854062
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 1960
Merit: 2533


Remember tonight for it's the beginning of forever


View Profile
June 12, 2019, 03:56:28 AM
 #2

as far as i know both bitcoin and litecoin use the same method to get the output script for a P2SH which also includes the witness nested in script hash types. so the only thing you would need to do is to import the same key in the other coin's wallet and select the same address type to be derived from its (compressed) public key.

Khaos77
Member
**
Offline Offline

Activity: 462
Merit: 72

Flag Day ☺


View Profile
June 12, 2019, 05:06:08 AM
Last edit: June 12, 2019, 06:37:16 AM by Khaos77
 #3

as far as i know both bitcoin and litecoin use the same method to get the output script for a P2SH which also includes the witness nested in script hash types. so the only thing you would need to do is to import the same key in the other coin's wallet and select the same address type to be derived from its (compressed) public key.

Not thinking that would work.
I think the generated private keys would be different.

How would the private key be the exact same, between the BTC & LTC network for the public address?


pooya87
Legendary
*
Offline Offline

Activity: 1960
Merit: 2533


Remember tonight for it's the beginning of forever


View Profile
June 12, 2019, 05:24:18 AM
Merited by joniboini (2), ETFbitcoin (1)
 #4

How would the private key be the exact same, between the BTC & LTC network for the public address?

private key is just a number so that is no the place you should look. what you should look into is the type of the curve and then the script types they create. since LTC is the exact copy of bitcoin, it also uses the same curve so the same number (private key) corresponds to the same public key. and since both use the same hash functions, they both come up with the same hash. and since they also use the same script structure (OP_HASH160 <20 byte> OP_EQUAL) then the scripts are also the same. the only thing different would be address format which is the base58 encoding (first byte) which doesn't matter at all.

Khaos77
Member
**
Offline Offline

Activity: 462
Merit: 72

Flag Day ☺


View Profile
June 12, 2019, 06:33:12 AM
Merited by xandry (2), HCP (2), Forsyth Jones (2), joniboini (2), odolvlobo (1), ETFbitcoin (1)
 #5

How would the private key be the exact same, between the BTC & LTC network for the public address?

private key is just a number so that is no the place you should look. what you should look into is the type of the curve and then the script types they create. since LTC is the exact copy of bitcoin, it also uses the same curve so the same number (private key) corresponds to the same public key. and since both use the same hash functions, they both come up with the same hash. and since they also use the same script structure (OP_HASH160 <20 byte> OP_EQUAL) then the scripts are also the same. the only thing different would be address format which is the base58 encoding (first byte) which doesn't matter at all.

Looks like you are right, it can be done.   Smiley

found the following.
https://www.reddit.com/r/Bitcoin/comments/byk9qc/help_needed_stupid_me_sent_litcoin_from_trezor_to/eqk63ut/

Quote
Here is how to do it:

    Take a Bitcoin private key in WIF (wallet import format).

    Convert it to hexadecimal format.

    Add "b0" in front of it and "01" at the end of it.

    Calculate a double SHA256 hash of the resulting string as a hex (use https://www.fileformat.info/tool/hash.htm and use the field Binary hash / Hex bytes).

    Add first 8 symbols from the result of step 4 to the resulting string of step 3.

    Convert the resulting hex string to WIF using https://incoherency.co.uk/base58/

    The result is a Litecoin private key in WIF (wallet import format).

Example:

    Bitcoin private key (WIF): KzNDQwKngvExhYzGhsMhHjeacwB9L1Asgo293Kf8TPMutvfr89wv

    Converting to hex format: 5de30ea8c8a415f7b8a0286a033c9ff9e94415326c405cf0ce611df1067ecec6

    Add "b0" in front of it and "01" at the end of it: b05de30ea8c8a415f7b8a0286a033c9ff9e94415326c405cf0ce611df1067ecec601

    First round of hash: 254609e251aeb830ce0e8c37f75b76a15795d550c410b8bdda32394c1d9a7e6d

    Second round of hash: 103087d15075dd2464c0b49dabce677e36d68179fbb871cd1f846be451946e37

    "b05de30ea8c8a415f7b8a0286a033c9ff9e94415326c405cf0ce611df1067ecec601" + "103087d1" = b05de30ea8c8a415f7b8a0286a033c9ff9e94415326c405cf0ce611df1067ecec601103087d1

    Converting to WIF: T6CUrgcy6JDZUPd9FWJZW6BxZnpTQ6BmVzvPu8Hg2MY5QpCvzyjN

    Result: we converted Bitcoin private key "KzNDQwKngvExhYzGhsMhHjeacwB9L1Asgo293Kf8TPMutvfr89wv" to Litecoin private key "T6CUrgcy6JDZUPd9FWJZW6BxZnpTQ6BmVzvPu8Hg2MY5QpCvzyjN".

Proof that it works:

Bitcoin private key: KzNDQwKngvExhYzGhsMhHjeacwB9L1Asgo293Kf8TPMutvfr89wv

Litecoin private key: T6CUrgcy6JDZUPd9FWJZW6BxZnpTQ6BmVzvPu8Hg2MY5QpCvzyjN

Use https://www.bitaddress.org (go to "Wallet Details" and enter the Bitcoin private key).

Use https://liteaddress.org (go to "Wallet Details" and enter the Litecoin private key).

You will see that for both Bitcoin and Litecoin the hex format private keys (and the uncompressed public keys) are identical. This means that these keys will "unlock" an identical SegWit address on both networks.

Forsyth Jones
Sr. Member
****
Offline Offline

Activity: 924
Merit: 397


I love Bitcoin!


View Profile WWW
June 13, 2019, 12:43:30 AM
 #6

@Khaos77 thank you I did the tests following the article quoted and it worked! Now I'd like to know which wallet I still see UTXO non-spent from an address litecoin P2SH started with 3? Litecoin Core?
HCP
Legendary
*
Offline Offline

Activity: 1288
Merit: 2299

<insert witty quote here>


View Profile
June 13, 2019, 07:25:51 AM
 #7

You should be able to use Litecoin Core or Electrum-LTC to import the private key

Electrum-LTC also has the advantage of not requiring that you sync the entire blockchain.

Forsyth Jones
Sr. Member
****
Offline Offline

Activity: 924
Merit: 397


I love Bitcoin!


View Profile WWW
June 13, 2019, 04:56:30 PM
 #8

You should be able to use Litecoin Core or Electrum-LTC to import the private key

Electrum-LTC also has the advantage of not requiring that you sync the entire blockchain.
but how to import the private key with the prefix "3"?

in "info" I have only these instructions:

Code:
WIF keys are typed in Electrum, based on script type.

A few examples:
p2pkh:T4PsyoR5gC8B...       -> LXqi2tzER...
p2wpkh-p2sh:T4PsyoR5gC8B... -> MUuWxSpVC...
p2wpkh:T4PsyoR5gC8B...       -> ltc1q3fjf...
pereira4
Legendary
*
Offline Offline

Activity: 1610
Merit: 1171


View Profile
June 18, 2019, 01:10:31 AM
 #9

You should be able to use Litecoin Core or Electrum-LTC to import the private key

Electrum-LTC also has the advantage of not requiring that you sync the entire blockchain.
but how to import the private key with the prefix "3"?

in "info" I have only these instructions:

Code:
WIF keys are typed in Electrum, based on script type.

A few examples:
p2pkh:T4PsyoR5gC8B...       -> LXqi2tzER...
p2wpkh-p2sh:T4PsyoR5gC8B... -> MUuWxSpVC...
p2wpkh:T4PsyoR5gC8B...       -> ltc1q3fjf...


Im more familiar with Core but the way Electrum works, it basically forces you to create a brand new wallet in order to import keys.

So backup your current wallet, and simply follow the GUI... click on "Import Bitcoin addresses or private keys" and enter the addresses during the wizard:

HCP
Legendary
*
Offline Offline

Activity: 1288
Merit: 2299

<insert witty quote here>


View Profile
June 19, 2019, 09:33:58 PM
 #10

but how to import the private key with the prefix "3"?
in "info" I have only these instructions:
Code:
WIF keys are typed in Electrum, based on script type.

A few examples:
p2pkh:T4PsyoR5gC8B...        -> LXqi2tzER...
p2wpkh-p2sh:T4PsyoR5gC8B... -> MUuWxSpVC...
p2wpkh:T4PsyoR5gC8B...      -> ltc1q3fjf...
I assume you mean 'import the private key for the address that has "3" prefix'... the private key itself should most likely start with a "T"

Theoretically... the SegWit private key that you generated, should be able to be imported as "p2wpkh-p2sh"... it will create an address that starts with "M", but it should be the "same" as the address that starts with a "3"... You can check this by using the Litecoin P2SH address converter here: https://litecoin-project.github.io/p2sh-convert/

Litecoin switched to using "M" prefix to try and prevent people from accidentally sending Litecoin to Bitcoin addresses Wink

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!