Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot restore wallet from 12-word secret phrase #62

Open
ffrediani opened this issue Apr 26, 2024 · 24 comments
Open

Cannot restore wallet from 12-word secret phrase #62

ffrediani opened this issue Apr 26, 2024 · 24 comments

Comments

@ffrediani
Copy link

I am trying to use MyTonWallet restoring a previous wallet I had however MyTonWallet required 24-word secret phrase to restore and doesn't give the option to use 12-word. If it was possible to generate a secret key with 12-word in another wallet software why isn't possible to use in MyTonWallet ?

@kraken7984
Copy link

`

@snowkidind
Copy link

This issue arises from people who have initialized a wallet in Trust wallet which ambiguously creates a TON wallet from 12 words using their method. Trust wallet does not support Jettons at all, and people need to import the 12 word key in order to retrieve Jettons erroneously sent to trust wallet recipient address.

I've tried to create a program using the tonweb package to create a transaction from 12 word but was able to generate addresses but unable to create addresses consistent with the output of trust wallet.

Example


const { mnemonicToSeed } = require('tonweb-mnemonic')

const mnemonic = "the quick brown fox....."

;(async () => {
  try {
    const provider = tonweb.provider
    const seed = await mnemonicToSeed([mnemonic])
    const keyPair = tonweb.utils.nacl.sign.keyPair.fromSeed(seed)
    const wallet = new tonweb.wallet.all.v4R2(provider, {
      publicKey: keyPair.publicKey,
      wc: 0
    })
    const address = await wallet.getAddress()
    const nonBounceableAddress = address.toString(true, true, false)
    const balance = await provider.getBalance(nonBounceableAddress)
    console.log(nonBounceableAddress, balance)
  } catch (error) {
    console.log(error)
  }
})()

@mytonwalletorg
Copy link
Owner

@snowkidind I do not think tonweb-mnemonic supports passing 12-word mnemonic to mnemonicToSeed.

The proper solution here would be to write code that will extract the private key of a TON wallet based on 12-word mnemonic. We recently implemented a very similar approach for extracting from Ledger's 24-word mnemonic here: https://github.com/mytonwalletorg/ton-ledger-export/blob/master/src/index.js

You can try to adapt that code from Ledger's 24 words to Trust's 12 words.

Then the received private key (hex string) can be imported directly in MyTonWallet.

@ffrediani
Copy link
Author

It is a bit annoying to be forced to use 24-word if you wish 12-word as that provides a good security already.

@mytonwalletorg
Copy link
Owner

There is no difference 12 or 24 words — if they are from Trust Wallet, they will not be accepted by MyTonWallet. So extracting the private key would be the solution.

@ffrediani
Copy link
Author

ffrediani commented May 17, 2024

12-word is simpler to store, so giving the use the possibility to choose either 12 or 24 would be better rather than just have 24 as an option, then any 12 or 24 word can be used on any Hot Wallet software that supports the coin.

@ffrediani
Copy link
Author

Can't Mytonwallet simply accept 12-word in order to restore a wallet ?

@snowkidind
Copy link

Then the received private key (hex string) can be imported directly in MyTonWallet.

I see no feature that allows this type of import. Desktop, browser extension or mobile.

@ffrediani
Copy link
Author

What would be the block for Mytonwallet to accept 12 word recovery phrase along with the existing 24 word and also give the user the option to generate new seed with 12 word as well ?

@snowkidind
Copy link

So... yeah following up on finding my friends funds. Still no function to import address by private key. Are there any plans to add this?

Screenshot 2024-06-05 at 10 42 54 AM

@ffrediani
Copy link
Author

@mytonwalletorg what would take to develop a way to allow the create or import 12-word seed phrase on mytonwallet interface instead of just 24. Even if it uses another method, as long it has enough security is fine.
In other words how to avoid having to import a private key through a manual process and making it more friendly to the user without have to do trough commands.

@snowkidind the scenario you describe is pretty much what brought me here. Thanks for sharing your tentative. Perhaps a solution can be found to that that allows the user to choose either 12 or 24 words when creating or importing a wallet.

@AghilndR
Copy link

AghilndR commented Jun 5, 2024

@mytonwalletorg what would take to develop a way to allow the create or import 12-word seed phrase on mytonwallet interface instead of just 24. Even if it uses another method, as long it has enough security is fine. In other words how to avoid having to import a private key through a manual process and making it more friendly to the user without have to do trough commands.

@snowkidind the scenario you describe is pretty much what brought me here. Thanks for sharing your tentative. Perhaps a solution can be found to that that allows the user to choose either 12 or 24 words when creating or importing a wallet.

@mytonwalletorg
Copy link
Owner

So... yeah following up on finding my friends funds. Still no function to import address by private key. Are there any plans to add this?

Just choose "24 Secret Words" and paste your hex private key.

@ffrediani
Copy link
Author

@mytonwalletorg do you think is doable to have also the option to enter a 12-word seed or give the user option to generate both as per his preference ?

@snowkidind
Copy link

Just choose "24 Secret Words" and paste your hex private key.

Are you kidding or is this an easter egg?

@snowkidind
Copy link

Ok I see the function made the latest update - thanks! But a couple issues have now presented themselves:

  1. the wallet derivation path isnt the same as the one trust wallet uses, so its no bueno. I am not sure which method trust wallet used so this is ambiguous. perhaps I can reach out to them and get an answer.

  2. Now that I've successfully imported the wrong version of my friends wallet into myTonWallet, I want to remove it without wiping the 10 other wallets from different seed phrases I have within the app. How does one remove a single address from MTW?

I have notified trust wallet of their issue
trustwallet/wallet-core#3898

@ffrediani
Copy link
Author

@snowkidind please do so. TrustWallet is very very bad at communication. Very bad support system, they loose emails in between the interaction and are unable to be aware of the issue. But above all this issue needs to be treated.

Seems MyTonWallet needs these improvements and being limited to 24-word only is not a good thing. Add the 12-word support whenever possible please.

@mytonwalletorg
Copy link
Owner

2. Now that I've successfully imported the wrong version of my friends wallet into myTonWallet, I want to remove it without wiping the 10 other wallets from different seed phrases I have within the app. How does one remove a single address from MTW?

Just use Settings > Exit or Remove Wallet.

@AghilndR
Copy link

I am trying to use MyTonWallet restoring a previous wallet I had however MyTonWallet required 24-word secret phrase to restore and doesn't give the option to use 12-word. If it was possible to generate a secret key with 12-word in another wallet software why isn't possible to use in MyTonWallet ?

@seriabov
Copy link

@snowkidind @mytonwalletorg Trust wallet uses m/44'/607'/0' as derivation path for TON. I changed the derivation path here - https://github.com/mytonwalletorg/ton-ledger-export/blob/master/src/index.js and it works with 12-word phrase

@Ajaxy
Copy link

Ajaxy commented Jul 21, 2024

@snowkidind @mytonwalletorg Trust wallet uses m/44'/607'/0' as derivation path for TON. I changed the derivation path here - https://github.com/mytonwalletorg/ton-ledger-export/blob/master/src/index.js and it works with 12-word phrase

Can you please provide a code example or a diff?

@seriabov
Copy link

@Ajaxy I changed this line to get values at m/44'/607'/0':

const seedContainer = derivePath(`m/44'/607'/${index}'`, seed.toString('hex'));

@ffrediani
Copy link
Author

Great thing. Hopefully 12 words can ve a standard option as well in order to make it more like most wallets.

@snowkidind @mytonwalletorg Trust wallet uses m/44'/607'/0' as derivation path for TON. I changed the derivation path here - https://github.com/mytonwalletorg/ton-ledger-export/blob/master/src/index.js and it works with 12-word phrase

@snowkidind
Copy link

snowkidind commented Aug 2, 2024

This resolves the issue of jettons inadvertently sent to trust wallet. Modifying the above file to m/44'/607'/${index}' was the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants