1 package btcjson
2 3 // NodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.
4 type NodeSubCmd string
5 6 const (
7 // NConnect indicates the specified host that should be connected to.
8 NConnect NodeSubCmd = "connect"
9 // NRemove indicates the specified peer that should be removed as a persistent peer.
10 NRemove NodeSubCmd = "remove"
11 // NDisconnect indicates the specified peer should be disonnected.
12 NDisconnect NodeSubCmd = "disconnect"
13 )
14 15 // NodeCmd defines the dropnode JSON-RPC command.
16 type NodeCmd struct {
17 SubCmd NodeSubCmd `jsonrpcusage:"\"connect|remove|disconnect\""`
18 Target string
19 ConnectSubCmd *string `jsonrpcusage:"\"perm|temp\""`
20 }
21 22 // NewNodeCmd returns a new instance which can be used to issue a `node` JSON-RPC command. The parameters which are
23 // pointers indicate they are optional. Passing nil for optional parameters will use the default value.
24 func NewNodeCmd(subCmd NodeSubCmd, target string, connectSubCmd *string) *NodeCmd {
25 return &NodeCmd{
26 SubCmd: subCmd,
27 Target: target,
28 ConnectSubCmd: connectSubCmd,
29 }
30 }
31 32 // DebugLevelCmd defines the debuglevel JSON-RPC command. This command is not a standard Bitcoin command. It is an
33 // extension for pod.
34 type DebugLevelCmd struct {
35 LevelSpec string
36 }
37 38 // NewDebugLevelCmd returns a new DebugLevelCmd which can be used to issue a debuglevel JSON-RPC command. This command
39 // is not a standard Bitcoin command. It is an extension for pod.
40 func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd {
41 return &DebugLevelCmd{
42 LevelSpec: levelSpec,
43 }
44 }
45 46 // GenerateCmd defines the generate JSON-RPC command.
47 type GenerateCmd struct {
48 NumBlocks uint32
49 }
50 51 // NewGenerateCmd returns a new instance which can be used to issue a generate JSON-RPC command.
52 func NewGenerateCmd(numBlocks uint32) *GenerateCmd {
53 return &GenerateCmd{
54 NumBlocks: numBlocks,
55 }
56 }
57 58 // GetBestBlockCmd defines the getbestblock JSON-RPC command.
59 type GetBestBlockCmd struct{}
60 61 // NewGetBestBlockCmd returns a new instance which can be used to issue a getbestblock JSON-RPC command.
62 func NewGetBestBlockCmd() *GetBestBlockCmd {
63 return &GetBestBlockCmd{}
64 }
65 66 // GetCurrentNetCmd defines the getcurrentnet JSON-RPC command.
67 type GetCurrentNetCmd struct{}
68 69 // NewGetCurrentNetCmd returns a new instance which can be used to issue a getcurrentnet JSON-RPC command.
70 func NewGetCurrentNetCmd() *GetCurrentNetCmd {
71 return &GetCurrentNetCmd{}
72 }
73 74 // GetHeadersCmd defines the getheaders JSON-RPC command. NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
75 type GetHeadersCmd struct {
76 BlockLocators []string `json:"blocklocators"`
77 HashStop string `json:"hashstop"`
78 }
79 80 // NewGetHeadersCmd returns a new instance which can be used to issue a getheaders JSON-RPC command. NOTE: This is a btcsuite extension ported from
81 // github.com/decred/dcrd/dcrjson.
82 func NewGetHeadersCmd(blockLocators []string, hashStop string) *GetHeadersCmd {
83 return &GetHeadersCmd{
84 BlockLocators: blockLocators,
85 HashStop: hashStop,
86 }
87 }
88 89 // VersionCmd defines the version JSON-RPC command. NOTE: This is a btcsuite extension ported from github.com/decred/dcrd/dcrjson.
90 type VersionCmd struct{}
91 92 // NewVersionCmd returns a new instance which can be used to issue a JSON-RPC version command. NOTE: This is a btcsuite extension ported from
93 // github.com/decred/dcrd/dcrjson.
94 func NewVersionCmd() *VersionCmd {
95 return new(VersionCmd)
96 }
97 func init() {
98 99 // No special flags for commands in this file.
100 flags := UsageFlag(0)
101 MustRegisterCmd("debuglevel", (*DebugLevelCmd)(nil), flags)
102 MustRegisterCmd("node", (*NodeCmd)(nil), flags)
103 MustRegisterCmd("generate", (*GenerateCmd)(nil), flags)
104 MustRegisterCmd("getbestblock", (*GetBestBlockCmd)(nil), flags)
105 MustRegisterCmd("getcurrentnet", (*GetCurrentNetCmd)(nil), flags)
106 MustRegisterCmd("getheaders", (*GetHeadersCmd)(nil), flags)
107 MustRegisterCmd("version", (*VersionCmd)(nil), flags)
108 }
109