Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //src/wallet.ts
- // 개인키 의 위치를 설정한다.
- const privateKeyLocation = 'node/wallet/private_key';
- // 개인키가 생성되는 과정이다.
- const generatePrivatekey = (): string => {
- const keyPair = EC.genKeyPair();
- const privateKey = keyPair.getPrivate();
- return privateKey.toString(16);
- };
- // 개인키가 지갑에 저장되는 과정이다.
- const initWallet = () => {
- //이미 개인키가 존재한다면 덮어쓰지는 않는다.
- if (existsSync(privateKeyLocation)) {
- return;
- }
- const newPrivateKey = generatePrivatekey();
- writeFileSync(privateKeyLocation, newPrivateKey);
- console.log('new wallet with private key created');
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement