github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/userinvoices.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 "github.com/decred/politeia/politeiawww/api/cms/v1" 11 "github.com/decred/politeia/politeiawww/cmd/shared" 12 ) 13 14 // UserInvoicesCmd gets the invoices for the specified user. 15 type UserInvoicesCmd struct { 16 Args struct { 17 //UserID string `positional-arg-name:"userID"` // User ID 18 } `positional-args:"true" required:"true"` 19 } 20 21 // Execute executes the user invoices command. 22 func (cmd *UserInvoicesCmd) Execute(args []string) error { 23 // Get server public key 24 vr, err := client.Version() 25 if err != nil { 26 return err 27 } 28 29 // Get user invoices 30 uir, err := client.UserInvoices( 31 &v1.UserInvoices{}) 32 if err != nil { 33 return err 34 } 35 36 // Verify invoice censorship records 37 for _, p := range uir.Invoices { 38 err := verifyInvoice(p, vr.PubKey) 39 if err != nil { 40 return fmt.Errorf("unable to verify invoice %v: %v", 41 p.CensorshipRecord.Token, err) 42 } 43 } 44 45 // Print user invoices 46 return shared.PrintJSON(uir) 47 } 48 49 // userInvoicesHelpMsg is the output of the help command when 'userinvoices' 50 // is specified. 51 const userInvoicesHelpMsg = `userinvoices "userID" 52 53 Fetch all invoices submitted by a specific user. 54 55 Arguments: 56 1. userID (string, required) User id 57 58 Result: 59 { 60 "invoices": [ 61 { 62 ... 63 } 64 ] 65 }`