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 websocket notifications that are
7 // supported by a chain server.
12 // BlockConnectedNtfnMethod is the legacy, deprecated method used for
13 // notifications from the chain server that a block has been connected.
15 // NOTE: Deprecated. Use FilteredBlockConnectedNtfnMethod instead.
16 BlockConnectedNtfnMethod = "blockconnected"
18 // BlockDisconnectedNtfnMethod is the legacy, deprecated method used for
19 // notifications from the chain server that a block has been
22 // NOTE: Deprecated. Use FilteredBlockDisconnectedNtfnMethod instead.
23 BlockDisconnectedNtfnMethod = "blockdisconnected"
25 // FilteredBlockConnectedNtfnMethod is the new method used for
26 // notifications from the chain server that a block has been connected.
27 FilteredBlockConnectedNtfnMethod = "filteredblockconnected"
29 // FilteredBlockDisconnectedNtfnMethod is the new method used for
30 // notifications from the chain server that a block has been
32 FilteredBlockDisconnectedNtfnMethod = "filteredblockdisconnected"
34 // RecvTxNtfnMethod is the legacy, deprecated method used for
35 // notifications from the chain server that a transaction which pays to
36 // a registered address has been processed.
38 // NOTE: Deprecated. Use RelevantTxAcceptedNtfnMethod and
39 // FilteredBlockConnectedNtfnMethod instead.
40 RecvTxNtfnMethod = "recvtx"
42 // RedeemingTxNtfnMethod is the legacy, deprecated method used for
43 // notifications from the chain server that a transaction which spends a
44 // registered outpoint has been processed.
46 // NOTE: Deprecated. Use RelevantTxAcceptedNtfnMethod and
47 // FilteredBlockConnectedNtfnMethod instead.
48 RedeemingTxNtfnMethod = "redeemingtx"
50 // RescanFinishedNtfnMethod is the legacy, deprecated method used for
51 // notifications from the chain server that a legacy, deprecated rescan
52 // operation has finished.
54 // NOTE: Deprecated. Not used with rescanblocks command.
55 RescanFinishedNtfnMethod = "rescanfinished"
57 // RescanProgressNtfnMethod is the legacy, deprecated method used for
58 // notifications from the chain server that a legacy, deprecated rescan
59 // operation this is underway has made progress.
61 // NOTE: Deprecated. Not used with rescanblocks command.
62 RescanProgressNtfnMethod = "rescanprogress"
64 // TxAcceptedNtfnMethod is the method used for notifications from the
65 // chain server that a transaction has been accepted into the mempool.
66 TxAcceptedNtfnMethod = "txaccepted"
68 // TxAcceptedVerboseNtfnMethod is the method used for notifications from
69 // the chain server that a transaction has been accepted into the
70 // mempool. This differs from TxAcceptedNtfnMethod in that it provides
71 // more details in the notification.
72 TxAcceptedVerboseNtfnMethod = "txacceptedverbose"
74 // RelevantTxAcceptedNtfnMethod is the new method used for notifications
75 // from the chain server that inform a client that a transaction that
76 // matches the loaded filter was accepted by the mempool.
77 RelevantTxAcceptedNtfnMethod = "relevanttxaccepted"
80 // BlockConnectedNtfn defines the blockconnected JSON-RPC notification.
82 // NOTE: Deprecated. Use FilteredBlockConnectedNtfn instead.
83 type BlockConnectedNtfn struct {
89 // NewBlockConnectedNtfn returns a new instance which can be used to issue a
90 // blockconnected JSON-RPC notification.
92 // NOTE: Deprecated. Use NewFilteredBlockConnectedNtfn instead.
93 func NewBlockConnectedNtfn(hash string, height int32, time int64) *BlockConnectedNtfn {
94 return &BlockConnectedNtfn{
101 // BlockDisconnectedNtfn defines the blockdisconnected JSON-RPC notification.
103 // NOTE: Deprecated. Use FilteredBlockDisconnectedNtfn instead.
104 type BlockDisconnectedNtfn struct {
110 // NewBlockDisconnectedNtfn returns a new instance which can be used to issue a
111 // blockdisconnected JSON-RPC notification.
113 // NOTE: Deprecated. Use NewFilteredBlockDisconnectedNtfn instead.
114 func NewBlockDisconnectedNtfn(hash string, height int32, time int64) *BlockDisconnectedNtfn {
115 return &BlockDisconnectedNtfn{
122 // FilteredBlockConnectedNtfn defines the filteredblockconnected JSON-RPC
124 type FilteredBlockConnectedNtfn struct {
127 SubscribedTxs []string
130 // NewFilteredBlockConnectedNtfn returns a new instance which can be used to
131 // issue a filteredblockconnected JSON-RPC notification.
132 func NewFilteredBlockConnectedNtfn(height int32, header string, subscribedTxs []string) *FilteredBlockConnectedNtfn {
133 return &FilteredBlockConnectedNtfn{
136 SubscribedTxs: subscribedTxs,
140 // FilteredBlockDisconnectedNtfn defines the filteredblockdisconnected JSON-RPC
142 type FilteredBlockDisconnectedNtfn struct {
147 // NewFilteredBlockDisconnectedNtfn returns a new instance which can be used to
148 // issue a filteredblockdisconnected JSON-RPC notification.
149 func NewFilteredBlockDisconnectedNtfn(height int32, header string) *FilteredBlockDisconnectedNtfn {
150 return &FilteredBlockDisconnectedNtfn{
156 // BlockDetails describes details of a tx in a block.
157 type BlockDetails struct {
158 Height int32 `json:"height"`
159 Hash string `json:"hash"`
160 Index int `json:"index"`
161 Time int64 `json:"time"`
164 // RecvTxNtfn defines the recvtx JSON-RPC notification.
166 // NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn
168 type RecvTxNtfn struct {
173 // NewRecvTxNtfn returns a new instance which can be used to issue a recvtx
174 // JSON-RPC notification.
176 // NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and
177 // NewFilteredBlockConnectedNtfn instead.
178 func NewRecvTxNtfn(hexTx string, block *BlockDetails) *RecvTxNtfn {
185 // RedeemingTxNtfn defines the redeemingtx JSON-RPC notification.
187 // NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn
189 type RedeemingTxNtfn struct {
194 // NewRedeemingTxNtfn returns a new instance which can be used to issue a
195 // redeemingtx JSON-RPC notification.
197 // NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and
198 // NewFilteredBlockConnectedNtfn instead.
199 func NewRedeemingTxNtfn(hexTx string, block *BlockDetails) *RedeemingTxNtfn {
200 return &RedeemingTxNtfn{
206 // RescanFinishedNtfn defines the rescanfinished JSON-RPC notification.
208 // NOTE: Deprecated. Not used with rescanblocks command.
209 type RescanFinishedNtfn struct {
215 // NewRescanFinishedNtfn returns a new instance which can be used to issue a
216 // rescanfinished JSON-RPC notification.
218 // NOTE: Deprecated. Not used with rescanblocks command.
219 func NewRescanFinishedNtfn(hash string, height int32, time int64) *RescanFinishedNtfn {
220 return &RescanFinishedNtfn{
227 // RescanProgressNtfn defines the rescanprogress JSON-RPC notification.
229 // NOTE: Deprecated. Not used with rescanblocks command.
230 type RescanProgressNtfn struct {
236 // NewRescanProgressNtfn returns a new instance which can be used to issue a
237 // rescanprogress JSON-RPC notification.
239 // NOTE: Deprecated. Not used with rescanblocks command.
240 func NewRescanProgressNtfn(hash string, height int32, time int64) *RescanProgressNtfn {
241 return &RescanProgressNtfn{
248 // TxAcceptedNtfn defines the txaccepted JSON-RPC notification.
249 type TxAcceptedNtfn struct {
254 // NewTxAcceptedNtfn returns a new instance which can be used to issue a
255 // txaccepted JSON-RPC notification.
256 func NewTxAcceptedNtfn(txHash string, amount float64) *TxAcceptedNtfn {
257 return &TxAcceptedNtfn{
263 // TxAcceptedVerboseNtfn defines the txacceptedverbose JSON-RPC notification.
264 type TxAcceptedVerboseNtfn struct {
268 // NewTxAcceptedVerboseNtfn returns a new instance which can be used to issue a
269 // txacceptedverbose JSON-RPC notification.
270 func NewTxAcceptedVerboseNtfn(rawTx TxRawResult) *TxAcceptedVerboseNtfn {
271 return &TxAcceptedVerboseNtfn{
276 // RelevantTxAcceptedNtfn defines the parameters to the relevanttxaccepted
277 // JSON-RPC notification.
278 type RelevantTxAcceptedNtfn struct {
279 Transaction string `json:"transaction"`
282 // NewRelevantTxAcceptedNtfn returns a new instance which can be used to issue a
283 // relevantxaccepted JSON-RPC notification.
284 func NewRelevantTxAcceptedNtfn(txHex string) *RelevantTxAcceptedNtfn {
285 return &RelevantTxAcceptedNtfn{Transaction: txHex}
289 // The commands in this file are only usable by websockets and are
291 flags := UFWebsocketOnly | UFNotification
293 MustRegisterCmd(BlockConnectedNtfnMethod, (*BlockConnectedNtfn)(nil), flags)
294 MustRegisterCmd(BlockDisconnectedNtfnMethod, (*BlockDisconnectedNtfn)(nil), flags)
295 MustRegisterCmd(FilteredBlockConnectedNtfnMethod, (*FilteredBlockConnectedNtfn)(nil), flags)
296 MustRegisterCmd(FilteredBlockDisconnectedNtfnMethod, (*FilteredBlockDisconnectedNtfn)(nil), flags)
297 MustRegisterCmd(RecvTxNtfnMethod, (*RecvTxNtfn)(nil), flags)
298 MustRegisterCmd(RedeemingTxNtfnMethod, (*RedeemingTxNtfn)(nil), flags)
299 MustRegisterCmd(RescanFinishedNtfnMethod, (*RescanFinishedNtfn)(nil), flags)
300 MustRegisterCmd(RescanProgressNtfnMethod, (*RescanProgressNtfn)(nil), flags)
301 MustRegisterCmd(TxAcceptedNtfnMethod, (*TxAcceptedNtfn)(nil), flags)
302 MustRegisterCmd(TxAcceptedVerboseNtfnMethod, (*TxAcceptedVerboseNtfn)(nil), flags)
303 MustRegisterCmd(RelevantTxAcceptedNtfnMethod, (*RelevantTxAcceptedNtfn)(nil), flags)