github.com/decred/politeia@v1.4.0/politeiawww/cmd/pictl/cmdproposaltimestamps.go (about) 1 // Copyright (c) 2020-2021 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 rcv1 "github.com/decred/politeia/politeiawww/api/records/v1" 9 pclient "github.com/decred/politeia/politeiawww/client" 10 ) 11 12 // cmdProposalTimestamps retrieves the timestamps for a politeiawww proposal. 13 type cmdProposalTimestamps struct { 14 Args struct { 15 Token string `positional-arg-name:"token" required:"true"` 16 Version uint32 `positional-arg-name:"version" optional:"true"` 17 } `positional-args:"true"` 18 } 19 20 // Execute executes the cmdProposalTimestamps command. 21 // 22 // This function satisfies the go-flags Commander interface. 23 func (c *cmdProposalTimestamps) Execute(args []string) error { 24 // Setup client 25 opts := pclient.Opts{ 26 HTTPSCert: cfg.HTTPSCert, 27 Cookies: cfg.Cookies, 28 HeaderCSRF: cfg.CSRF, 29 Verbose: cfg.Verbose, 30 RawJSON: cfg.RawJSON, 31 } 32 pc, err := pclient.New(cfg.Host, opts) 33 if err != nil { 34 return err 35 } 36 37 // Get timestamps 38 t := rcv1.Timestamps{ 39 Token: c.Args.Token, 40 Version: c.Args.Version, 41 } 42 tr, err := pc.RecordTimestamps(t) 43 if err != nil { 44 return err 45 } 46 47 // Verify timestamps 48 err = pclient.RecordTimestampsVerify(*tr) 49 if err != nil { 50 return err 51 } 52 53 // Print timestamps 54 printJSON(tr) 55 56 return nil 57 } 58 59 // proposalTimestampsHelpMsg is printed to stdout by the help command. 60 const proposalTimestampsHelpMsg = `proposaltimestamps [flags] "token" "version" 61 62 Fetch the timestamps a proposal version. The timestamp contains all necessary 63 data to verify that user submitted proposal data has been timestamped onto the 64 decred blockchain. 65 66 This command defaults to requesting vetted proposals unless the --unvetted flag 67 is used. 68 69 Arguments: 70 1. token (string, required) Record token 71 2. version (uint32, optional) Record version 72 `