1 package btcjson
2 3 const (
4 // BlockConnectedNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a
5 // block has been connected. NOTE: Deprecated. Use FilteredBlockConnectedNtfnMethod instead.
6 BlockConnectedNtfnMethod = "blockconnected"
7 // BlockDisconnectedNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a
8 // block has been disconnected. NOTE: Deprecated. Use FilteredBlockDisconnectedNtfnMethod instead.
9 BlockDisconnectedNtfnMethod = "blockdisconnected"
10 // FilteredBlockConnectedNtfnMethod is the new method used for notifications from the chain server that a block has
11 // been connected.
12 FilteredBlockConnectedNtfnMethod = "filteredblockconnected"
13 // FilteredBlockDisconnectedNtfnMethod is the new method used for notifications from the chain server that a block
14 // has been disconnected.
15 FilteredBlockDisconnectedNtfnMethod = "filteredblockdisconnected"
16 // RecvTxNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a transaction
17 // which pays to a registered address has been processed. NOTE: Deprecated. Use RelevantTxAcceptedNtfnMethod and
18 // FilteredBlockConnectedNtfnMethod instead.
19 RecvTxNtfnMethod = "recvtx"
20 // RedeemingTxNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a
21 // transaction which spends a registered outpoint has been processed. NOTE: Deprecated. Use
22 // RelevantTxAcceptedNtfnMethod and FilteredBlockConnectedNtfnMethod instead.
23 RedeemingTxNtfnMethod = "redeemingtx"
24 // RescanFinishedNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a
25 // legacy, deprecated rescan operation has finished. NOTE: Deprecated. Not used with rescanblocks command.
26 RescanFinishedNtfnMethod = "rescanfinished"
27 // RescanProgressNtfnMethod is the legacy, deprecated method used for notifications from the chain server that a
28 // legacy, deprecated rescan operation this is underway has made progress. NOTE: Deprecated. Not used with
29 // rescanblocks command.
30 RescanProgressNtfnMethod = "rescanprogress"
31 // TxAcceptedNtfnMethod is the method used for notifications from the chain server that a transaction has been
32 // accepted into the mempool.
33 TxAcceptedNtfnMethod = "txaccepted"
34 // TxAcceptedVerboseNtfnMethod is the method used for notifications from the chain server that a transaction has
35 // been accepted into the mempool. This differs from TxAcceptedNtfnMethod in that it provides more details in the
36 // notification.
37 TxAcceptedVerboseNtfnMethod = "txacceptedverbose"
38 // RelevantTxAcceptedNtfnMethod is the new method used for notifications from the chain server that inform a client
39 // that a transaction that matches the loaded filter was accepted by the mempool.
40 RelevantTxAcceptedNtfnMethod = "relevanttxaccepted"
41 )
42 43 // BlockConnectedNtfn defines the blockconnected JSON-RPC notification. NOTE: Deprecated. Use FilteredBlockConnectedNtfn
44 // instead.
45 type BlockConnectedNtfn struct {
46 Hash string
47 Height int32
48 Time int64
49 }
50 51 // NewBlockConnectedNtfn returns a new instance which can be used to issue a blockconnected JSON-RPC notification.
52 //
53 // NOTE: Deprecated. Use NewFilteredBlockConnectedNtfn instead.
54 func NewBlockConnectedNtfn(hash string, height int32, time int64) *BlockConnectedNtfn {
55 return &BlockConnectedNtfn{
56 Hash: hash,
57 Height: height,
58 Time: time,
59 }
60 }
61 62 // BlockDisconnectedNtfn defines the blockdisconnected JSON-RPC notification.
63 //
64 // NOTE: Deprecated. Use FilteredBlockDisconnectedNtfn instead.
65 type BlockDisconnectedNtfn struct {
66 Hash string
67 Height int32
68 Time int64
69 }
70 71 // NewBlockDisconnectedNtfn returns a new instance which can be used to issue a blockdisconnected JSON-RPC notification.
72 //
73 // NOTE: Deprecated. Use NewFilteredBlockDisconnectedNtfn instead.
74 func NewBlockDisconnectedNtfn(hash string, height int32, time int64) *BlockDisconnectedNtfn {
75 return &BlockDisconnectedNtfn{
76 Hash: hash,
77 Height: height,
78 Time: time,
79 }
80 }
81 82 // FilteredBlockConnectedNtfn defines the filteredblockconnected JSON-RPC notification.
83 type FilteredBlockConnectedNtfn struct {
84 Height int32
85 Header string
86 SubscribedTxs []string
87 }
88 89 // NewFilteredBlockConnectedNtfn returns a new instance which can be used to issue a filteredblockconnected JSON-RPC notification.
90 func NewFilteredBlockConnectedNtfn(height int32, header string, subscribedTxs []string) *FilteredBlockConnectedNtfn {
91 return &FilteredBlockConnectedNtfn{
92 Height: height,
93 Header: header,
94 SubscribedTxs: subscribedTxs,
95 }
96 }
97 98 // FilteredBlockDisconnectedNtfn defines the filteredblockdisconnected JSON-RPC notification.
99 type FilteredBlockDisconnectedNtfn struct {
100 Height int32
101 Header string
102 }
103 104 // NewFilteredBlockDisconnectedNtfn returns a new instance which can be used to issue a filteredblockdisconnected
105 // JSON-RPC notification.
106 func NewFilteredBlockDisconnectedNtfn(height int32, header string) *FilteredBlockDisconnectedNtfn {
107 return &FilteredBlockDisconnectedNtfn{
108 Height: height,
109 Header: header,
110 }
111 }
112 113 // BlockDetails describes details of a tx in a block.
114 type BlockDetails struct {
115 Height int32 `json:"height"`
116 Hash string `json:"hash"`
117 Index int `json:"index"`
118 Time int64 `json:"time"`
119 }
120 121 // RecvTxNtfn defines the recvtx JSON-RPC notification.
122 //
123 // NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
124 type RecvTxNtfn struct {
125 HexTx string
126 Block *BlockDetails
127 }
128 129 // NewRecvTxNtfn returns a new instance which can be used to issue a recvtx JSON-RPC notification.
130 //
131 // NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and NewFilteredBlockConnectedNtfn instead.
132 func NewRecvTxNtfn(hexTx string, block *BlockDetails) *RecvTxNtfn {
133 return &RecvTxNtfn{
134 HexTx: hexTx,
135 Block: block,
136 }
137 }
138 139 // RedeemingTxNtfn defines the redeemingtx JSON-RPC notification.
140 //
141 // NOTE: Deprecated. Use RelevantTxAcceptedNtfn and FilteredBlockConnectedNtfn instead.
142 type RedeemingTxNtfn struct {
143 HexTx string
144 Block *BlockDetails
145 }
146 147 // NewRedeemingTxNtfn returns a new instance which can be used to issue a redeemingtx JSON-RPC notification.
148 //
149 // NOTE: Deprecated. Use NewRelevantTxAcceptedNtfn and NewFilteredBlockConnectedNtfn instead.
150 func NewRedeemingTxNtfn(hexTx string, block *BlockDetails) *RedeemingTxNtfn {
151 return &RedeemingTxNtfn{
152 HexTx: hexTx,
153 Block: block,
154 }
155 }
156 157 // RescanFinishedNtfn defines the rescanfinished JSON-RPC notification.
158 //
159 // NOTE: Deprecated. Not used with rescanblocks command.
160 type RescanFinishedNtfn struct {
161 Hash string
162 Height int32
163 Time int64
164 }
165 166 // NewRescanFinishedNtfn returns a new instance which can be used to issue a rescanfinished JSON-RPC notification.
167 //
168 // NOTE: Deprecated. Not used with rescanblocks command.
169 func NewRescanFinishedNtfn(hash string, height int32, time int64) *RescanFinishedNtfn {
170 return &RescanFinishedNtfn{
171 Hash: hash,
172 Height: height,
173 Time: time,
174 }
175 }
176 177 // RescanProgressNtfn defines the rescanprogress JSON-RPC notification.
178 //
179 // NOTE: Deprecated. Not used with rescanblocks command.
180 type RescanProgressNtfn struct {
181 Hash string
182 Height int32
183 Time int64
184 }
185 186 // NewRescanProgressNtfn returns a new instance which can be used to issue a rescanprogress JSON-RPC notification.
187 //
188 // NOTE: Deprecated. Not used with rescanblocks command.
189 func NewRescanProgressNtfn(hash string, height int32, time int64) *RescanProgressNtfn {
190 return &RescanProgressNtfn{
191 Hash: hash,
192 Height: height,
193 Time: time,
194 }
195 }
196 197 // TxAcceptedNtfn defines the txaccepted JSON-RPC notification.
198 type TxAcceptedNtfn struct {
199 TxID string
200 Amount float64
201 }
202 203 // NewTxAcceptedNtfn returns a new instance which can be used to issue a txaccepted JSON-RPC notification.
204 func NewTxAcceptedNtfn(txHash string, amount float64) *TxAcceptedNtfn {
205 return &TxAcceptedNtfn{
206 TxID: txHash,
207 Amount: amount,
208 }
209 }
210 211 // TxAcceptedVerboseNtfn defines the txacceptedverbose JSON-RPC notification.
212 type TxAcceptedVerboseNtfn struct {
213 RawTx TxRawResult
214 }
215 216 // NewTxAcceptedVerboseNtfn returns a new instance which can be used to issue a txacceptedverbose JSON-RPC notification.
217 func NewTxAcceptedVerboseNtfn(rawTx TxRawResult) *TxAcceptedVerboseNtfn {
218 return &TxAcceptedVerboseNtfn{
219 RawTx: rawTx,
220 }
221 }
222 223 // RelevantTxAcceptedNtfn defines the parameters to the relevanttxaccepted JSON-RPC notification.
224 type RelevantTxAcceptedNtfn struct {
225 Transaction string `json:"transaction"`
226 }
227 228 // NewRelevantTxAcceptedNtfn returns a new instance which can be used to issue a relevantxaccepted JSON-RPC notification.
229 func NewRelevantTxAcceptedNtfn(txHex string) *RelevantTxAcceptedNtfn {
230 return &RelevantTxAcceptedNtfn{Transaction: txHex}
231 }
232 func init() {
233 234 // The commands in this file are only usable by websockets and are notifications.
235 flags := UFWebsocketOnly | UFNotification
236 MustRegisterCmd(BlockConnectedNtfnMethod, (*BlockConnectedNtfn)(nil), flags)
237 MustRegisterCmd(BlockDisconnectedNtfnMethod, (*BlockDisconnectedNtfn)(nil), flags)
238 MustRegisterCmd(FilteredBlockConnectedNtfnMethod, (*FilteredBlockConnectedNtfn)(nil), flags)
239 MustRegisterCmd(FilteredBlockDisconnectedNtfnMethod, (*FilteredBlockDisconnectedNtfn)(nil), flags)
240 MustRegisterCmd(RecvTxNtfnMethod, (*RecvTxNtfn)(nil), flags)
241 MustRegisterCmd(RedeemingTxNtfnMethod, (*RedeemingTxNtfn)(nil), flags)
242 MustRegisterCmd(RescanFinishedNtfnMethod, (*RescanFinishedNtfn)(nil), flags)
243 MustRegisterCmd(RescanProgressNtfnMethod, (*RescanProgressNtfn)(nil), flags)
244 MustRegisterCmd(TxAcceptedNtfnMethod, (*TxAcceptedNtfn)(nil), flags)
245 MustRegisterCmd(TxAcceptedVerboseNtfnMethod, (*TxAcceptedVerboseNtfn)(nil), flags)
246 MustRegisterCmd(RelevantTxAcceptedNtfnMethod, (*RelevantTxAcceptedNtfn)(nil), flags)
247 }
248