github.com/lbryio/lbcd@v0.22.119/btcjson/chainsvrwscmds.go (about) 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. 5 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. 8 9 package btcjson 10 11 // AuthenticateCmd defines the authenticate JSON-RPC command. 12 type AuthenticateCmd struct { 13 Username string 14 Passphrase string 15 } 16 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{ 21 Username: username, 22 Passphrase: passphrase, 23 } 24 } 25 26 // NotifyBlocksCmd defines the notifyblocks JSON-RPC command. 27 type NotifyBlocksCmd struct{} 28 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{} 33 } 34 35 // StopNotifyBlocksCmd defines the stopnotifyblocks JSON-RPC command. 36 type StopNotifyBlocksCmd struct{} 37 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{} 42 } 43 44 // NotifyNewTransactionsCmd defines the notifynewtransactions JSON-RPC command. 45 type NotifyNewTransactionsCmd struct { 46 Verbose *bool `jsonrpcdefault:"false"` 47 } 48 49 // NewNotifyNewTransactionsCmd returns a new instance which can be used to issue 50 // a notifynewtransactions JSON-RPC command. 51 // 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{ 56 Verbose: verbose, 57 } 58 } 59 60 // SessionCmd defines the session JSON-RPC command. 61 type SessionCmd struct{} 62 63 // NewSessionCmd returns a new instance which can be used to issue a session 64 // JSON-RPC command. 65 func NewSessionCmd() *SessionCmd { 66 return &SessionCmd{} 67 } 68 69 // StopNotifyNewTransactionsCmd defines the stopnotifynewtransactions JSON-RPC command. 70 type StopNotifyNewTransactionsCmd struct{} 71 72 // NewStopNotifyNewTransactionsCmd returns a new instance which can be used to issue 73 // a stopnotifynewtransactions JSON-RPC command. 74 // 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{} 79 } 80 81 // NotifyReceivedCmd defines the notifyreceived JSON-RPC command. 82 // 83 // Deprecated: Use LoadTxFilterCmd instead. 84 type NotifyReceivedCmd struct { 85 Addresses []string 86 } 87 88 // NewNotifyReceivedCmd returns a new instance which can be used to issue a 89 // notifyreceived JSON-RPC command. 90 // 91 // Deprecated: Use NewLoadTxFilterCmd instead. 92 func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd { 93 return &NotifyReceivedCmd{ 94 Addresses: addresses, 95 } 96 } 97 98 // OutPoint describes a transaction outpoint that will be marshalled to and 99 // from JSON. 100 type OutPoint struct { 101 Hash string `json:"hash"` 102 Index uint32 `json:"index"` 103 } 104 105 // LoadTxFilterCmd defines the loadtxfilter request parameters to load or 106 // reload a transaction filter. 107 // 108 // NOTE: This is a btcd extension ported from github.com/decred/dcrd/dcrjson 109 // and requires a websocket connection. 110 type LoadTxFilterCmd struct { 111 Reload bool 112 Addresses []string 113 OutPoints []OutPoint 114 } 115 116 // NewLoadTxFilterCmd returns a new instance which can be used to issue a 117 // loadtxfilter JSON-RPC command. 118 // 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{ 123 Reload: reload, 124 Addresses: addresses, 125 OutPoints: outPoints, 126 } 127 } 128 129 // NotifySpentCmd defines the notifyspent JSON-RPC command. 130 // 131 // Deprecated: Use LoadTxFilterCmd instead. 132 type NotifySpentCmd struct { 133 OutPoints []OutPoint 134 } 135 136 // NewNotifySpentCmd returns a new instance which can be used to issue a 137 // notifyspent JSON-RPC command. 138 // 139 // Deprecated: Use NewLoadTxFilterCmd instead. 140 func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd { 141 return &NotifySpentCmd{ 142 OutPoints: outPoints, 143 } 144 } 145 146 // StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command. 147 // 148 // Deprecated: Use LoadTxFilterCmd instead. 149 type StopNotifyReceivedCmd struct { 150 Addresses []string 151 } 152 153 // NewStopNotifyReceivedCmd returns a new instance which can be used to issue a 154 // stopnotifyreceived JSON-RPC command. 155 // 156 // Deprecated: Use NewLoadTxFilterCmd instead. 157 func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd { 158 return &StopNotifyReceivedCmd{ 159 Addresses: addresses, 160 } 161 } 162 163 // StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command. 164 // 165 // Deprecated: Use LoadTxFilterCmd instead. 166 type StopNotifySpentCmd struct { 167 OutPoints []OutPoint 168 } 169 170 // NewStopNotifySpentCmd returns a new instance which can be used to issue a 171 // stopnotifyspent JSON-RPC command. 172 // 173 // Deprecated: Use NewLoadTxFilterCmd instead. 174 func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd { 175 return &StopNotifySpentCmd{ 176 OutPoints: outPoints, 177 } 178 } 179 180 // RescanCmd defines the rescan JSON-RPC command. 181 // 182 // Deprecated: Use RescanBlocksCmd instead. 183 type RescanCmd struct { 184 BeginBlock string 185 Addresses []string 186 OutPoints []OutPoint 187 EndBlock *string 188 } 189 190 // NewRescanCmd returns a new instance which can be used to issue a rescan 191 // JSON-RPC command. 192 // 193 // The parameters which are pointers indicate they are optional. Passing nil 194 // for optional parameters will use the default value. 195 // 196 // Deprecated: Use NewRescanBlocksCmd instead. 197 func NewRescanCmd(beginBlock string, addresses []string, outPoints []OutPoint, endBlock *string) *RescanCmd { 198 return &RescanCmd{ 199 BeginBlock: beginBlock, 200 Addresses: addresses, 201 OutPoints: outPoints, 202 EndBlock: endBlock, 203 } 204 } 205 206 // RescanBlocksCmd defines the rescan JSON-RPC command. 207 // 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. 212 BlockHashes []string 213 } 214 215 // NewRescanBlocksCmd returns a new instance which can be used to issue a rescan 216 // JSON-RPC command. 217 // 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} 222 } 223 224 func init() { 225 // The commands in this file are only usable by websockets. 226 flags := UFWebsocketOnly 227 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) 241 }