Fix Public/PrivateKey configuration type mismatch

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello 2023-11-16 12:44:44 +02:00
parent c9472add87
commit 780763eaf8

View file

@ -322,6 +322,15 @@ func ReadConfig(conf []byte) *NodeConfig {
} }
} }
} }
// Ensure PublicKey and PrivateKey are KeyBytes
if privatekey, ok := dat["PrivateKey"]; ok {
if privstr, err := hex.DecodeString(privatekey.(string)); err == nil {
priv := ed25519.PrivateKey(privstr)
pub := priv.Public().(ed25519.PublicKey)
dat["PrivateKey"] = KeyBytes(priv[:])
dat["PublicKey"] = KeyBytes(pub[:])
}
}
// Sanitise the config // Sanitise the config
confJson, err := json.Marshal(dat) confJson, err := json.Marshal(dat)
if err != nil { if err != nil {