parseethwallet

package
v0.1.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParseETHWalletCmd = &cobra.Command{
	Use:   "parseethwallet [flags]",
	Short: "Extract the private key from an eth wallet.",
	Long:  usage,
	RunE: func(cmd *cobra.Command, args []string) error {

		if *inputRawHexPrivateKey != "" {
			trimmedHexPrivateKey := strings.TrimPrefix(*inputRawHexPrivateKey, "0x")
			ks := keystore.NewKeyStore(*inputKeyStoreDirectory, keystore.StandardScryptN, keystore.StandardScryptP)
			pk, err := crypto.HexToECDSA(trimmedHexPrivateKey)
			if err != nil {
				return err
			}
			_, err = ks.ImportECDSA(pk, *inputPassword)
			if err != nil {
				return err
			}
			return nil
		}

		rawData, err := getInputData(cmd, args)
		if err != nil {
			return err
		}
		k := new(gethkeystore.RawKeystoreData)
		err = json.Unmarshal(rawData, &k)
		if err != nil {
			return err
		}
		d, err := keystore.DecryptDataV3(k.Crypto, *inputPassword)
		if err != nil {
			return err
		}
		ok := toOutputKey(d)
		outData, err := json.Marshal(ok)
		if err != nil {
			return err
		}
		fmt.Println(string(outData))
		return nil
	},
	Args: func(cmd *cobra.Command, args []string) error {
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL