Open ffrediani opened 6 months ago
`
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)
}
})()
@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.
It is a bit annoying to be forced to use 24-word if you wish 12-word as that provides a good security already.
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.
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.
Can't Mytonwallet simply accept 12-word in order to restore a wallet ?
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.
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 ?
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?
@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 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.
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.
@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 ?
Just choose "24 Secret Words" and paste your hex private key.
Are you kidding or is this an easter egg?
Ok I see the function made the latest update - thanks! But a couple issues have now presented themselves:
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.
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 https://github.com/trustwallet/wallet-core/issues/3898
@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.
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.
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 ?
@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 @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?
@Ajaxy I changed this line to get values at m/44'/607'/0'
:
const seedContainer = derivePath(`m/44'/607'/${index}'`, seed.toString('hex'));
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
This resolves the issue of jettons inadvertently sent to trust wallet. Modifying the above file to m/44'/607'/${index}'
was the fix.
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 ?