github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/getdccs.go (about) 1 // Copyright (c) 2017-2019 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 "fmt" 9 10 v1 "github.com/decred/politeia/politeiawww/api/cms/v1" 11 "github.com/decred/politeia/politeiawww/cmd/shared" 12 ) 13 14 // GetDCCsCmd gets all dccs by status. 15 type GetDCCsCmd struct { 16 Args struct { 17 Status int `long:"status"` 18 } 19 } 20 21 // Execute executes the get dccs command. 22 func (cmd *GetDCCsCmd) Execute(args []string) error { 23 // Get server public key 24 vr, err := client.Version() 25 if err != nil { 26 return err 27 } 28 29 gdr, err := client.GetDCCs( 30 &v1.GetDCCs{ 31 Status: v1.DCCStatusT(cmd.Args.Status), 32 }) 33 if err != nil { 34 return err 35 } 36 37 // Verify dcc censorship records 38 for _, p := range gdr.DCCs { 39 err := verifyDCC(p, vr.PubKey) 40 if err != nil { 41 return fmt.Errorf("unable to verify dcc %v: %v", 42 p.CensorshipRecord.Token, err) 43 } 44 } 45 46 // Print user invoices 47 return shared.PrintJSON(gdr) 48 }