forked from eoscanada/eosc
/
systemRegproducer.go
35 lines (28 loc) · 971 Bytes
/
systemRegproducer.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
package cmd
import (
"context"
"fmt"
"github.com/sebastianmontero/eos-go/ecc"
"github.com/sebastianmontero/eos-go/system"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var systemRegisterProducerCmd = &cobra.Command{
Use: "regproducer [account_name] [public_key] [website_url]",
Short: "Register an account as a block producer candidate.",
Args: cobra.ExactArgs(3),
Run: func(cmd *cobra.Command, args []string) {
api := getAPI()
accountName := toAccount(args[0], "account name")
publicKey, err := ecc.NewPublicKey(args[1])
errorCheck(fmt.Sprintf("%q invalid public key", args[1]), err)
websiteURL := args[2]
pushEOSCActions(context.Background(), api,
system.NewRegProducer(accountName, publicKey, websiteURL, uint16(viper.GetInt("system-regproducer-cmd-location"))),
)
},
}
func init() {
systemCmd.AddCommand(systemRegisterProducerCmd)
systemRegisterProducerCmd.Flags().IntP("location", "", 0, "Location number (reserved)")
}