/
getdccs.go
48 lines (40 loc) · 983 Bytes
/
getdccs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2017-2019 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"fmt"
v1 "github.com/decred/politeia/politeiawww/api/cms/v1"
"github.com/decred/politeia/politeiawww/cmd/shared"
)
// GetDCCsCmd gets all dccs by status.
type GetDCCsCmd struct {
Args struct {
Status int `long:"status"`
}
}
// Execute executes the get dccs command.
func (cmd *GetDCCsCmd) Execute(args []string) error {
// Get server public key
vr, err := client.Version()
if err != nil {
return err
}
gdr, err := client.GetDCCs(
&v1.GetDCCs{
Status: v1.DCCStatusT(cmd.Args.Status),
})
if err != nil {
return err
}
// Verify dcc censorship records
for _, p := range gdr.DCCs {
err := verifyDCC(p, vr.PubKey)
if err != nil {
return fmt.Errorf("unable to verify dcc %v: %v",
p.CensorshipRecord.Token, err)
}
}
// Print user invoices
return shared.PrintJSON(gdr)
}