Skip to content

Commit 8e54c2d

Browse files
committed
tron check
1 parent 5d1527c commit 8e54c2d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/providers/mnemonic/provider.ts

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {accountInfo, derive, seedFromEntropy} from '@haqq/provider-web3-utils';
22
import {generateEntropy} from '@haqq/provider-web3-utils/src/native-modules';
33
import {Share, encryptShare} from '@haqq/shared-react-native';
44
import {entropyToMnemonic, mnemonicToEntropy, mnemonicToSeed} from 'bip39';
5+
import {hdkey} from 'ethereumjs-wallet';
56
import EncryptedStorage from 'react-native-encrypted-storage';
67

78
import {ProviderMnemonicBaseOptions} from './types';
@@ -149,6 +150,17 @@ export class ProviderMnemonicBase
149150

150151
const seed = await ProviderMnemonicBase.shareToSeed(share);
151152

153+
const entropyLength = parseInt(share.shareIndex, 10);
154+
const entropy = share.share
155+
.slice(-1 * entropyLength)
156+
.padStart(entropyLength, '0');
157+
158+
const hdwallet = hdkey.fromMasterSeed(Buffer.from(entropy, 'hex'));
159+
const derivationPath = "m/44'/195'/0'/0/0";
160+
const wallet = hdwallet.derivePath(derivationPath);
161+
const tronPrivateKey = wallet.getWallet().getPrivateKeyString();
162+
console.log('tronPrivateKey', tronPrivateKey);
163+
152164
const privateKey = await derive(seed, hdPath);
153165

154166
if (!privateKey) {

0 commit comments

Comments
 (0)