import { coerceMnemonicAccountType , generatePrivateKey , MNEMONIC_ACCOUNT_TYPE_CHOICES , privateKeyToPublicKey , } from 'src/lib/generate_utils' ; import yargs from 'yargs' ; interface Bip32Argv { mnemonic : string ; accountType : string ; index : number ; } export const command = 'public-key' ; export const describe = 'command for generating the public key using the bip32 standard' ; export const builder = ( argv ) => { return argv . option ( 'mnemonic' , { type : 'string' , description : 'BIP-39 mnemonic' , demandOption : 'Please specify a mnemonic from which to derive a public key' , alias : 'm' , } ) . option ( 'accountType' , { alias : 'a' , type : 'string' , choices : MNEMONIC_ACCOUNT_TYPE_CHOICES , required : true , } ) . option ( 'index' , { type : 'number' , description : 'Index of key to generate' , demandOption : 'Please specify a key index' , alias : 'i' , } ) ; } ; export const handler = async ( argv ) => { console . log ( privateKeyToPublicKey ( generatePrivateKey ( argv . mnemonic , coerceMnemonicAccountType ( argv . accountType ) , argv . index ) ) ) ; } ;