1 // Copyright (c) 2014-2017 The btcsuite developers
2 // Copyright (c) 2015-2017 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, but are only available via websockets.
11 // AuthenticateCmd defines the authenticate JSON-RPC command.
12 type AuthenticateCmd struct {
17 // NewAuthenticateCmd returns a new instance which can be used to issue an
18 // authenticate JSON-RPC command.
19 func NewAuthenticateCmd(username, passphrase string) *AuthenticateCmd {
20 return &AuthenticateCmd{
22 Passphrase: passphrase,
26 // NotifyBlocksCmd defines the notifyblocks JSON-RPC command.
27 type NotifyBlocksCmd struct{}
29 // NewNotifyBlocksCmd returns a new instance which can be used to issue a
30 // notifyblocks JSON-RPC command.
31 func NewNotifyBlocksCmd() *NotifyBlocksCmd {
32 return &NotifyBlocksCmd{}
35 // StopNotifyBlocksCmd defines the stopnotifyblocks JSON-RPC command.
36 type StopNotifyBlocksCmd struct{}
38 // NewStopNotifyBlocksCmd returns a new instance which can be used to issue a
39 // stopnotifyblocks JSON-RPC command.
40 func NewStopNotifyBlocksCmd() *StopNotifyBlocksCmd {
41 return &StopNotifyBlocksCmd{}
44 // NotifyNewTransactionsCmd defines the notifynewtransactions JSON-RPC command.
45 type NotifyNewTransactionsCmd struct {
46 Verbose *bool `jsonrpcdefault:"false"`
49 // NewNotifyNewTransactionsCmd returns a new instance which can be used to issue
50 // a notifynewtransactions JSON-RPC command.
52 // The parameters which are pointers indicate they are optional. Passing nil
53 // for optional parameters will use the default value.
54 func NewNotifyNewTransactionsCmd(verbose *bool) *NotifyNewTransactionsCmd {
55 return &NotifyNewTransactionsCmd{
60 // SessionCmd defines the session JSON-RPC command.
61 type SessionCmd struct{}
63 // NewSessionCmd returns a new instance which can be used to issue a session
65 func NewSessionCmd() *SessionCmd {
69 // StopNotifyNewTransactionsCmd defines the stopnotifynewtransactions JSON-RPC command.
70 type StopNotifyNewTransactionsCmd struct{}
72 // NewStopNotifyNewTransactionsCmd returns a new instance which can be used to issue
73 // a stopnotifynewtransactions JSON-RPC command.
75 // The parameters which are pointers indicate they are optional. Passing nil
76 // for optional parameters will use the default value.
77 func NewStopNotifyNewTransactionsCmd() *StopNotifyNewTransactionsCmd {
78 return &StopNotifyNewTransactionsCmd{}
81 // NotifyReceivedCmd defines the notifyreceived JSON-RPC command.
83 // NOTE: Deprecated. Use LoadTxFilterCmd instead.
84 type NotifyReceivedCmd struct {
88 // NewNotifyReceivedCmd returns a new instance which can be used to issue a
89 // notifyreceived JSON-RPC command.
91 // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
92 func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd {
93 return &NotifyReceivedCmd{
98 // OutPoint describes a transaction outpoint that will be marshalled to and
100 type OutPoint struct {
101 Hash string `json:"hash"`
102 Index uint32 `json:"index"`
105 // LoadTxFilterCmd defines the loadtxfilter request parameters to load or
106 // reload a transaction filter.
108 // NOTE: This is a btcd extension ported from github.com/decred/dcrd/dcrjson
109 // and requires a websocket connection.
110 type LoadTxFilterCmd struct {
116 // NewLoadTxFilterCmd returns a new instance which can be used to issue a
117 // loadtxfilter JSON-RPC command.
119 // NOTE: This is a btcd extension ported from github.com/decred/dcrd/dcrjson
120 // and requires a websocket connection.
121 func NewLoadTxFilterCmd(reload bool, addresses []string, outPoints []OutPoint) *LoadTxFilterCmd {
122 return &LoadTxFilterCmd{
124 Addresses: addresses,
125 OutPoints: outPoints,
129 // NotifySpentCmd defines the notifyspent JSON-RPC command.
131 // NOTE: Deprecated. Use LoadTxFilterCmd instead.
132 type NotifySpentCmd struct {
136 // NewNotifySpentCmd returns a new instance which can be used to issue a
137 // notifyspent JSON-RPC command.
139 // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
140 func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd {
141 return &NotifySpentCmd{
142 OutPoints: outPoints,
146 // StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command.
148 // NOTE: Deprecated. Use LoadTxFilterCmd instead.
149 type StopNotifyReceivedCmd struct {
153 // NewStopNotifyReceivedCmd returns a new instance which can be used to issue a
154 // stopnotifyreceived JSON-RPC command.
156 // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
157 func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd {
158 return &StopNotifyReceivedCmd{
159 Addresses: addresses,
163 // StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command.
165 // NOTE: Deprecated. Use LoadTxFilterCmd instead.
166 type StopNotifySpentCmd struct {
170 // NewStopNotifySpentCmd returns a new instance which can be used to issue a
171 // stopnotifyspent JSON-RPC command.
173 // NOTE: Deprecated. Use NewLoadTxFilterCmd instead.
174 func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd {
175 return &StopNotifySpentCmd{
176 OutPoints: outPoints,
180 // RescanCmd defines the rescan JSON-RPC command.
182 // NOTE: Deprecated. Use RescanBlocksCmd instead.
183 type RescanCmd struct {
190 // NewRescanCmd returns a new instance which can be used to issue a rescan
193 // The parameters which are pointers indicate they are optional. Passing nil
194 // for optional parameters will use the default value.
196 // NOTE: Deprecated. Use NewRescanBlocksCmd instead.
197 func NewRescanCmd(beginBlock string, addresses []string, outPoints []OutPoint, endBlock *string) *RescanCmd {
199 BeginBlock: beginBlock,
200 Addresses: addresses,
201 OutPoints: outPoints,
206 // RescanBlocksCmd defines the rescan JSON-RPC command.
208 // NOTE: This is a btcd extension ported from github.com/decred/dcrd/dcrjson
209 // and requires a websocket connection.
210 type RescanBlocksCmd struct {
211 // Block hashes as a string array.
215 // NewRescanBlocksCmd returns a new instance which can be used to issue a rescan
218 // NOTE: This is a btcd extension ported from github.com/decred/dcrd/dcrjson
219 // and requires a websocket connection.
220 func NewRescanBlocksCmd(blockHashes []string) *RescanBlocksCmd {
221 return &RescanBlocksCmd{BlockHashes: blockHashes}
225 // The commands in this file are only usable by websockets.
226 flags := UFWebsocketOnly
228 MustRegisterCmd("authenticate", (*AuthenticateCmd)(nil), flags)
229 MustRegisterCmd("loadtxfilter", (*LoadTxFilterCmd)(nil), flags)
230 MustRegisterCmd("notifyblocks", (*NotifyBlocksCmd)(nil), flags)
231 MustRegisterCmd("notifynewtransactions", (*NotifyNewTransactionsCmd)(nil), flags)
232 MustRegisterCmd("notifyreceived", (*NotifyReceivedCmd)(nil), flags)
233 MustRegisterCmd("notifyspent", (*NotifySpentCmd)(nil), flags)
234 MustRegisterCmd("session", (*SessionCmd)(nil), flags)
235 MustRegisterCmd("stopnotifyblocks", (*StopNotifyBlocksCmd)(nil), flags)
236 MustRegisterCmd("stopnotifynewtransactions", (*StopNotifyNewTransactionsCmd)(nil), flags)
237 MustRegisterCmd("stopnotifyspent", (*StopNotifySpentCmd)(nil), flags)
238 MustRegisterCmd("stopnotifyreceived", (*StopNotifyReceivedCmd)(nil), flags)
239 MustRegisterCmd("rescan", (*RescanCmd)(nil), flags)
240 MustRegisterCmd("rescanblocks", (*RescanBlocksCmd)(nil), flags)