github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/btcjson/chainsvrwscmds.go (about) 1 // Copyright (c) 2014-2015 The btcsuite developers 2 // Copyright (c) 2016 The Dash 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 type NotifyReceivedCmd struct { 83 Addresses []string 84 } 85 86 // NewNotifyReceivedCmd returns a new instance which can be used to issue a 87 // notifyreceived JSON-RPC command. 88 func NewNotifyReceivedCmd(addresses []string) *NotifyReceivedCmd { 89 return &NotifyReceivedCmd{ 90 Addresses: addresses, 91 } 92 } 93 94 // OutPoint describes a transaction outpoint that will be marshalled to and 95 // from JSON. 96 type OutPoint struct { 97 Hash string `json:"hash"` 98 Index uint32 `json:"index"` 99 } 100 101 // NotifySpentCmd defines the notifyspent JSON-RPC command. 102 type NotifySpentCmd struct { 103 OutPoints []OutPoint 104 } 105 106 // NewNotifySpentCmd returns a new instance which can be used to issue a 107 // notifyspent JSON-RPC command. 108 func NewNotifySpentCmd(outPoints []OutPoint) *NotifySpentCmd { 109 return &NotifySpentCmd{ 110 OutPoints: outPoints, 111 } 112 } 113 114 // StopNotifyReceivedCmd defines the stopnotifyreceived JSON-RPC command. 115 type StopNotifyReceivedCmd struct { 116 Addresses []string 117 } 118 119 // NewStopNotifyReceivedCmd returns a new instance which can be used to issue a 120 // stopnotifyreceived JSON-RPC command. 121 func NewStopNotifyReceivedCmd(addresses []string) *StopNotifyReceivedCmd { 122 return &StopNotifyReceivedCmd{ 123 Addresses: addresses, 124 } 125 } 126 127 // StopNotifySpentCmd defines the stopnotifyspent JSON-RPC command. 128 type StopNotifySpentCmd struct { 129 OutPoints []OutPoint 130 } 131 132 // NewStopNotifySpentCmd returns a new instance which can be used to issue a 133 // stopnotifyspent JSON-RPC command. 134 func NewStopNotifySpentCmd(outPoints []OutPoint) *StopNotifySpentCmd { 135 return &StopNotifySpentCmd{ 136 OutPoints: outPoints, 137 } 138 } 139 140 // RescanCmd defines the rescan JSON-RPC command. 141 type RescanCmd struct { 142 BeginBlock string 143 Addresses []string 144 OutPoints []OutPoint 145 EndBlock *string 146 } 147 148 // NewRescanCmd returns a new instance which can be used to issue a rescan 149 // JSON-RPC command. 150 // 151 // The parameters which are pointers indicate they are optional. Passing nil 152 // for optional parameters will use the default value. 153 func NewRescanCmd(beginBlock string, addresses []string, outPoints []OutPoint, endBlock *string) *RescanCmd { 154 return &RescanCmd{ 155 BeginBlock: beginBlock, 156 Addresses: addresses, 157 OutPoints: outPoints, 158 EndBlock: endBlock, 159 } 160 } 161 162 func init() { 163 // The commands in this file are only usable by websockets. 164 flags := UFWebsocketOnly 165 166 MustRegisterCmd("authenticate", (*AuthenticateCmd)(nil), flags) 167 MustRegisterCmd("notifyblocks", (*NotifyBlocksCmd)(nil), flags) 168 MustRegisterCmd("notifynewtransactions", (*NotifyNewTransactionsCmd)(nil), flags) 169 MustRegisterCmd("notifyreceived", (*NotifyReceivedCmd)(nil), flags) 170 MustRegisterCmd("notifyspent", (*NotifySpentCmd)(nil), flags) 171 MustRegisterCmd("session", (*SessionCmd)(nil), flags) 172 MustRegisterCmd("stopnotifyblocks", (*StopNotifyBlocksCmd)(nil), flags) 173 MustRegisterCmd("stopnotifynewtransactions", (*StopNotifyNewTransactionsCmd)(nil), flags) 174 MustRegisterCmd("stopnotifyspent", (*StopNotifySpentCmd)(nil), flags) 175 MustRegisterCmd("stopnotifyreceived", (*StopNotifyReceivedCmd)(nil), flags) 176 MustRegisterCmd("rescan", (*RescanCmd)(nil), flags) 177 }