func isDigest(digest string) bool {
	return v2.RegexpSHA256.MatchString(digest)
}
isDigest determines if a string is a valid SHA256 digest.
package main
import (
	"bytes"
	"crypto/sha256"
	"crypto/tls"
	"encoding/hex"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"net"
	"net/http"
	"net/url"
	"os"
	"reflect"
	"strconv"
	v1 "github.com/decred/dcrtime/api/v1"
	v2 "github.com/decred/dcrtime/api/v2"
	"github.com/decred/dcrtime/merkle"
	"github.com/decred/dcrtime/util"
)
const (
	dcrtimeClientID = "dcrtime cli"
)
var (
	testnet   = flag.Bool("testnet", false, "Use testnet port")
	debug     = flag.Bool("debug", false, "Print JSON that is sent to server")
	printJSON = flag.Bool("json", false, "Print JSON response from server")
	fileOnly  = flag.Bool("file", false, "Treat digests and timestamps "+
		"as file names")
	host     = flag.String("h", "", "Timestamping host")
	port     = flag.String("p", "", "Timestamping host port")
	trial    = flag.Bool("t", false, "Trial run, don't contact server")
	verbose  = flag.Bool("v", false, "Verbose")
	digest   = flag.String("digest", "", "Submit a raw 256 bit digest to anchor")
	apiToken = flag.String("apitoken", "", "Token for accessing privileged API"+
		" resources")
	balance = flag.Bool("balance", false, "Display the connected server's"+
		" wallet balance. An API Token is required")
	lastAnchor = flag.Bool("lastanchor", false, "Display last anchored"+
		" timestamp details")
	apiVersion = flag.Int("api", v2.APIVersion,
		"Inform the API version to be used by the cli (1 or 2)")
	skipVerify = flag.Bool("skipverify", false, "Skip TLS certificates"+
		"verification (not recommended)")
)
func normalizeAddress(addr, defaultPort string) string {
	_, _, err := net.SplitHostPort(addr)
	if err != nil {
		return net.JoinHostPort(addr, defaultPort)
	}
	return addr
}
func isDir(filename string) bool {
	fi, err := os.Stat(filename)
	if err != nil {
		return false
	}
	return fi.Mode().IsDir()
}
func isFile(filename string) bool {
	fi, err := os.Stat(filename)
	if err != nil {
		return false
	}
	return fi.Mode().IsRegular()
}