1 // Copyright (c) 2014-2016 The btcsuite developers
2 // Copyright (c) 2015-2016 The Decred developers
3 // Use of this source code is governed by an ISC
4 // license that can be found in the LICENSE file.
6 // NOTE: This file is intended to house the RPC commands that are supported by
7 // a chain server with btcd extensions.
11 // NodeSubCmd defines the type used in the addnode JSON-RPC command for the
13 type NodeSubCmd string
16 // NConnect indicates the specified host that should be connected to.
17 NConnect NodeSubCmd = "connect"
19 // NRemove indicates the specified peer that should be removed as a
21 NRemove NodeSubCmd = "remove"
23 // NDisconnect indicates the specified peer should be disonnected.
24 NDisconnect NodeSubCmd = "disconnect"
27 // NodeCmd defines the dropnode JSON-RPC command.
29 SubCmd NodeSubCmd `jsonrpcusage:"\"connect|remove|disconnect\""`
31 ConnectSubCmd *string `jsonrpcusage:"\"perm|temp\""`
34 // NewNodeCmd returns a new instance which can be used to issue a `node`
37 // The parameters which are pointers indicate they are optional. Passing nil
38 // for optional parameters will use the default value.
39 func NewNodeCmd(subCmd NodeSubCmd, target string, connectSubCmd *string) *NodeCmd {
43 ConnectSubCmd: connectSubCmd,
47 // DebugLevelCmd defines the debuglevel JSON-RPC command. This command is not a
48 // standard Bitcoin command. It is an extension for btcd.
49 type DebugLevelCmd struct {
53 // NewDebugLevelCmd returns a new DebugLevelCmd which can be used to issue a
54 // debuglevel JSON-RPC command. This command is not a standard Bitcoin command.
55 // It is an extension for btcd.
56 func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd {
57 return &DebugLevelCmd{
62 // GenerateCmd defines the generate JSON-RPC command.
63 type GenerateCmd struct {
67 // NewGenerateCmd returns a new instance which can be used to issue a generate
69 func NewGenerateCmd(numBlocks uint32) *GenerateCmd {
75 // GetBestBlockCmd defines the getbestblock JSON-RPC command.
76 type GetBestBlockCmd struct{}
78 // NewGetBestBlockCmd returns a new instance which can be used to issue a
79 // getbestblock JSON-RPC command.
80 func NewGetBestBlockCmd() *GetBestBlockCmd {
81 return &GetBestBlockCmd{}
84 // GetCurrentNetCmd defines the getcurrentnet JSON-RPC command.
85 type GetCurrentNetCmd struct{}
87 // NewGetCurrentNetCmd returns a new instance which can be used to issue a
88 // getcurrentnet JSON-RPC command.
89 func NewGetCurrentNetCmd() *GetCurrentNetCmd {
90 return &GetCurrentNetCmd{}
93 // GetHeadersCmd defines the getheaders JSON-RPC command.
95 // NOTE: This is a btcsuite extension ported from
96 // github.com/decred/dcrd/dcrjson.
97 type GetHeadersCmd struct {
98 BlockLocators []string `json:"blocklocators"`
99 HashStop string `json:"hashstop"`
102 // NewGetHeadersCmd returns a new instance which can be used to issue a
103 // getheaders JSON-RPC command.
105 // NOTE: This is a btcsuite extension ported from
106 // github.com/decred/dcrd/dcrjson.
107 func NewGetHeadersCmd(blockLocators []string, hashStop string) *GetHeadersCmd {
108 return &GetHeadersCmd{
109 BlockLocators: blockLocators,
114 // VersionCmd defines the version JSON-RPC command.
116 // NOTE: This is a btcsuite extension ported from
117 // github.com/decred/dcrd/dcrjson.
118 type VersionCmd struct{}
120 // NewVersionCmd returns a new instance which can be used to issue a JSON-RPC
123 // NOTE: This is a btcsuite extension ported from
124 // github.com/decred/dcrd/dcrjson.
125 func NewVersionCmd() *VersionCmd { return new(VersionCmd) }
128 // No special flags for commands in this file.
129 flags := UsageFlag(0)
131 MustRegisterCmd("debuglevel", (*DebugLevelCmd)(nil), flags)
132 MustRegisterCmd("node", (*NodeCmd)(nil), flags)
133 MustRegisterCmd("generate", (*GenerateCmd)(nil), flags)
134 MustRegisterCmd("getbestblock", (*GetBestBlockCmd)(nil), flags)
135 MustRegisterCmd("getcurrentnet", (*GetCurrentNetCmd)(nil), flags)
136 MustRegisterCmd("getheaders", (*GetHeadersCmd)(nil), flags)
137 MustRegisterCmd("version", (*VersionCmd)(nil), flags)