node: create valid key file when an empty description is provided

Fixes certusone/wormhole#257

Change-Id: If0d9883513f4908cdd8303f24a999d1d612fad30
This commit is contained in:
Leopold Schabel 2021-07-26 20:04:40 +02:00 committed by Leopold Schabel
parent 270bd78e98
commit 933442ac8a
1 changed files with 7 additions and 4 deletions

View File

@ -114,10 +114,13 @@ func writeGuardianKey(key *ecdsa.PrivateKey, description string, filename string
return fmt.Errorf("failed to open file: %w", err) return fmt.Errorf("failed to open file: %w", err)
} }
a, err := armor.Encode(f, GuardianKeyArmoredBlock, map[string]string{ headers := map[string]string{
"Description": description,
"PublicKey": ethcrypto.PubkeyToAddress(key.PublicKey).String(), "PublicKey": ethcrypto.PubkeyToAddress(key.PublicKey).String(),
}) }
if description != "" {
headers["Description"] = description
}
a, err := armor.Encode(f, GuardianKeyArmoredBlock, headers)
if err != nil { if err != nil {
panic(err) panic(err)
} }