Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
33 lines
775 B
Go
33 lines
775 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
cmtos "git.cw.tr/mukan-network/mukan-consensus/libs/os"
|
|
"git.cw.tr/mukan-network/mukan-consensus/p2p"
|
|
)
|
|
|
|
// GenNodeKeyCmd allows the generation of a node key. It prints node's ID to
|
|
// the standard output.
|
|
var GenNodeKeyCmd = &cobra.Command{
|
|
Use: "gen-node-key",
|
|
Aliases: []string{"gen_node_key"},
|
|
Short: "Generate a node key for this node and print its ID",
|
|
RunE: genNodeKey,
|
|
}
|
|
|
|
func genNodeKey(*cobra.Command, []string) error {
|
|
nodeKeyFile := config.NodeKeyFile()
|
|
if cmtos.FileExists(nodeKeyFile) {
|
|
return fmt.Errorf("node key at %s already exists", nodeKeyFile)
|
|
}
|
|
|
|
nodeKey, err := p2p.LoadOrGenNodeKey(nodeKeyFile)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(nodeKey.ID())
|
|
return nil
|
|
}
|