-
Notifications
You must be signed in to change notification settings - Fork 7
/
ethereum.go
35 lines (30 loc) · 1.29 KB
/
ethereum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package importer
import (
"fmt"
"log"
"code.vegaprotocol.io/vegacapsule/ethereum"
vegagen "code.vegaprotocol.io/vegacapsule/generator/vega"
"code.vegaprotocol.io/vegacapsule/types"
"code.vegaprotocol.io/vegacapsule/utils"
)
func importEthereumKey(nodeSet types.NodeSet, ethereumPrivateKey string) (*ethereum.KeyStore, error) {
log.Println("... importing ethereum private key")
importedKeystore, err := ethereum.ImportPrivateKeyIntoKeystore(ethereumPrivateKey, nodeSet.Vega.NodeWalletInfo.EthereumPassFilePath, vegagen.EthereumWalletPath(nodeSet.Vega.HomeDir))
if err != nil {
return nil, fmt.Errorf("failed to import private ethereum key into node keystore: %w", err)
}
log.Println("... adding ethereum wallet to the nodewallet")
ethImportArgs := []string{
"nodewallet", "import", "--force",
"--home", nodeSet.Vega.HomeDir,
"--chain", types.NodeWalletChainTypeEthereum,
"--passphrase-file", nodeSet.Vega.NodeWalletPassFilePath,
"--output", "json",
"--wallet-passphrase-file", nodeSet.Vega.NodeWalletInfo.EthereumPassFilePath,
"--wallet-path", importedKeystore.FilePath,
}
if _, err := utils.ExecuteBinary(nodeSet.Vega.BinaryPath, ethImportArgs, nil); err != nil {
return nil, fmt.Errorf("failed to import ethereum into vega node wallet: %w", err)
}
return importedKeystore, nil
}