diff --git a/.changelog/3858.feature.md b/.changelog/3858.feature.md new file mode 100644 index 00000000000..c94b949ead5 --- /dev/null +++ b/.changelog/3858.feature.md @@ -0,0 +1 @@ +go/oasis-node/cmd/genesis: Display doc's hash and SHA256 checksum with `check` diff --git a/go/oasis-node/cmd/genesis/genesis.go b/go/oasis-node/cmd/genesis/genesis.go index 0ffd80ebaf1..495a192077a 100644 --- a/go/oasis-node/cmd/genesis/genesis.go +++ b/go/oasis-node/cmd/genesis/genesis.go @@ -4,6 +4,7 @@ package genesis import ( "bytes" "context" + "crypto/sha256" "encoding/json" "errors" "fmt" @@ -700,6 +701,19 @@ func doCheckGenesis(cmd *cobra.Command, args []string) { } os.Exit(1) } + + fmt.Println("genesis file is valid and in canonical form") + fmt.Printf("genesis document's hash: %s\n", doc.ChainContext()) + fmt.Printf("genesis file's SHA256 checksum: ") + + sha256Hasher := sha256.New() + _, herr := sha256Hasher.Write(actualGenesis) + switch herr { + case nil: + fmt.Printf("%x\n", sha256Hasher.Sum(nil)) + default: + fmt.Println("[unknown]") + } } // Register registers the genesis sub-command and all of it's children.