mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 18:37:26 +08:00
* initial auto-update * working link, update, and testing docker container and scripts * refactor packages/folders * move files to proper folders * fix typos Closes #421 * optimize rpm imports * optimize channel imports * Refactor split command to allow testing of split operations Closes #338 * modify split and test for folder changes * remove alias * fix docker warning about FROM and AS being in different letter case Closes #422 * QClient Account Command * Display transaction details and confirmation prompts for transfer and merge commands * build qclient docker improvements * update build args for mpfr.so.6 * update install and node commands * remove NodeConfig check for qclient node commands * udpate * working node commands * update commands * move utils and rename package --------- Co-authored-by: Vasyl Tretiakov <vasyl.tretiakov@gmail.com> Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com> Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com> Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package utils
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/libp2p/go-libp2p/core/crypto"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
"source.quilibrium.com/quilibrium/monorepo/node/config"
|
|
)
|
|
|
|
func GetPeerIDFromConfig(cfg *config.Config) peer.ID {
|
|
peerPrivKey, err := hex.DecodeString(cfg.P2P.PeerPrivKey)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error unmarshaling peerkey"))
|
|
}
|
|
|
|
privKey, err := crypto.UnmarshalEd448PrivateKey(peerPrivKey)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error unmarshaling peerkey"))
|
|
}
|
|
|
|
pub := privKey.GetPublic()
|
|
id, err := peer.IDFromPublicKey(pub)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error getting peer id"))
|
|
}
|
|
|
|
return id
|
|
}
|
|
|
|
func GetPrivKeyFromConfig(cfg *config.Config) (crypto.PrivKey, error) {
|
|
peerPrivKey, err := hex.DecodeString(cfg.P2P.PeerPrivKey)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error unmarshaling peerkey"))
|
|
}
|
|
|
|
privKey, err := crypto.UnmarshalEd448PrivateKey(peerPrivKey)
|
|
return privKey, err
|
|
}
|
|
|
|
func IsExistingNodeVersion(version string) bool {
|
|
return FileExists(filepath.Join(NodeDataPath, version))
|
|
}
|
|
|
|
func CheckForSystemd() bool {
|
|
// Check if systemctl command exists
|
|
_, err := exec.LookPath("systemctl")
|
|
return err == nil
|
|
}
|
|
|
|
func LoadNodeConfig(configDirectory string) (*config.Config, error) {
|
|
NodeConfig, err := config.LoadConfig(configDirectory, "", false)
|
|
if err != nil {
|
|
fmt.Printf("invalid config directory: %s\n", configDirectory)
|
|
os.Exit(1)
|
|
}
|
|
return NodeConfig, nil
|
|
}
|