import * as bip39 from 'bip39'; import { Address, PrivateKey } from '../src/crypto'; // tslint:disable-next-line:no-var-requires const HDKey = require('@ont-community/hdkey-secp256r1'); // tslint:disable:no-console describe('test bip44', () => { test('test_24', () => { // tslint:disable-next-line:max-line-length const mnemonic = 'hill ready family useful detect bacon visit canoe recall circle topple claw sheriff universe robust lounge cluster duty vast excuse weasel grunt junk actor'; const seed = bip39.mnemonicToSeedHex(mnemonic); console.log('seed:', seed); const hdkey = HDKey.fromMasterSeed(Buffer.from(seed, 'hex')); console.log('root:', hdkey.privateExtendedKey); // tslint:disable-next-line:quotemark const path = "m/44'/1024'/0'/0/0"; const leaf = hdkey.derive(path); console.log('leaf:', leaf.privateExtendedKey); const privateKey = new PrivateKey(Buffer.from(leaf.privateKey).toString('hex')); console.log('private key:', privateKey.key); console.log('WIF key:', privateKey.serializeWIF()); const publicKey = privateKey.getPublicKey(); console.log('public key:', publicKey.key); const address = Address.fromPubKey(publicKey); console.log('address', address.toBase58()); expect(address.toBase58()).toBe('AM57cppabEf4JeBXXGAPvRSLmYpqTmQ3sS'); }); });