1 //go:generate go run -tags generate ./genapi/.
2 // generated; DO NOT EDIT
3 4 package chainrpc
5 6 import (
7 "io"
8 "net/rpc"
9 "time"
10 11 "github.com/p9c/p9/pkg/qu"
12 13 "github.com/p9c/p9/pkg/btcjson"
14 )
15 16 // API stores the channel, parameters and result values from calls via
17 // the channel
18 type API struct {
19 Ch interface{}
20 Params interface{}
21 Result interface{}
22 }
23 24 // CAPI is the central structure for configuration and access to a
25 // net/rpc API access endpoint for this RPC API
26 type CAPI struct {
27 Timeout time.Duration
28 quit qu.C
29 }
30 31 // NewCAPI returns a new CAPI
32 func NewCAPI(quit qu.C, timeout ...time.Duration) (c *CAPI) {
33 c = &CAPI{quit: quit}
34 if len(timeout)>0 {
35 c.Timeout = timeout[0]
36 } else {
37 c.Timeout = time.Second * 5
38 }
39 return
40 }
41 42 // Wrappers around RPC calls
43 type CAPIClient struct {
44 *rpc.Client
45 }
46 47 // New creates a new client for a kopach_worker.
48 // Note that any kind of connection can be used here, other than the StdConn
49 func NewCAPIClient(conn io.ReadWriteCloser) *CAPIClient {
50 return &CAPIClient{rpc.NewClient(conn)}
51 }
52 53 type (
54 // None means no parameters it is not checked so it can be nil
55 None struct{}
56 // AddNodeRes is the result from a call to AddNode
57 AddNodeRes struct { Res *None; Err error }
58 // CreateRawTransactionRes is the result from a call to CreateRawTransaction
59 CreateRawTransactionRes struct { Res *string; Err error }
60 // DecodeRawTransactionRes is the result from a call to DecodeRawTransaction
61 DecodeRawTransactionRes struct { Res *btcjson.TxRawDecodeResult; Err error }
62 // DecodeScriptRes is the result from a call to DecodeScript
63 DecodeScriptRes struct { Res *btcjson.DecodeScriptResult; Err error }
64 // EstimateFeeRes is the result from a call to EstimateFee
65 EstimateFeeRes struct { Res *float64; Err error }
66 // GenerateRes is the result from a call to Generate
67 GenerateRes struct { Res *[]string; Err error }
68 // GetAddedNodeInfoRes is the result from a call to GetAddedNodeInfo
69 GetAddedNodeInfoRes struct { Res *[]btcjson.GetAddedNodeInfoResultAddr; Err error }
70 // GetBestBlockRes is the result from a call to GetBestBlock
71 GetBestBlockRes struct { Res *btcjson.GetBestBlockResult; Err error }
72 // GetBestBlockHashRes is the result from a call to GetBestBlockHash
73 GetBestBlockHashRes struct { Res *string; Err error }
74 // GetBlockRes is the result from a call to GetBlock
75 GetBlockRes struct { Res *btcjson.GetBlockVerboseResult; Err error }
76 // GetBlockChainInfoRes is the result from a call to GetBlockChainInfo
77 GetBlockChainInfoRes struct { Res *btcjson.GetBlockChainInfoResult; Err error }
78 // GetBlockCountRes is the result from a call to GetBlockCount
79 GetBlockCountRes struct { Res *int64; Err error }
80 // GetBlockHashRes is the result from a call to GetBlockHash
81 GetBlockHashRes struct { Res *string; Err error }
82 // GetBlockHeaderRes is the result from a call to GetBlockHeader
83 GetBlockHeaderRes struct { Res *btcjson.GetBlockHeaderVerboseResult; Err error }
84 // GetBlockTemplateRes is the result from a call to GetBlockTemplate
85 GetBlockTemplateRes struct { Res *string; Err error }
86 // GetCFilterRes is the result from a call to GetCFilter
87 GetCFilterRes struct { Res *string; Err error }
88 // GetCFilterHeaderRes is the result from a call to GetCFilterHeader
89 GetCFilterHeaderRes struct { Res *string; Err error }
90 // GetConnectionCountRes is the result from a call to GetConnectionCount
91 GetConnectionCountRes struct { Res *int32; Err error }
92 // GetCurrentNetRes is the result from a call to GetCurrentNet
93 GetCurrentNetRes struct { Res *string; Err error }
94 // GetDifficultyRes is the result from a call to GetDifficulty
95 GetDifficultyRes struct { Res *float64; Err error }
96 // GetGenerateRes is the result from a call to GetGenerate
97 GetGenerateRes struct { Res *bool; Err error }
98 // GetHashesPerSecRes is the result from a call to GetHashesPerSec
99 GetHashesPerSecRes struct { Res *float64; Err error }
100 // GetHeadersRes is the result from a call to GetHeaders
101 GetHeadersRes struct { Res *[]string; Err error }
102 // GetInfoRes is the result from a call to GetInfo
103 GetInfoRes struct { Res *btcjson.InfoChainResult0; Err error }
104 // GetMempoolInfoRes is the result from a call to GetMempoolInfo
105 GetMempoolInfoRes struct { Res *btcjson.GetMempoolInfoResult; Err error }
106 // GetMiningInfoRes is the result from a call to GetMiningInfo
107 GetMiningInfoRes struct { Res *btcjson.GetMiningInfoResult; Err error }
108 // GetNetTotalsRes is the result from a call to GetNetTotals
109 GetNetTotalsRes struct { Res *btcjson.GetNetTotalsResult; Err error }
110 // GetNetworkHashPSRes is the result from a call to GetNetworkHashPS
111 GetNetworkHashPSRes struct { Res *[]btcjson.GetPeerInfoResult; Err error }
112 // GetPeerInfoRes is the result from a call to GetPeerInfo
113 GetPeerInfoRes struct { Res *[]btcjson.GetPeerInfoResult; Err error }
114 // GetRawMempoolRes is the result from a call to GetRawMempool
115 GetRawMempoolRes struct { Res *[]string; Err error }
116 // GetRawTransactionRes is the result from a call to GetRawTransaction
117 GetRawTransactionRes struct { Res *string; Err error }
118 // GetTxOutRes is the result from a call to GetTxOut
119 GetTxOutRes struct { Res *string; Err error }
120 // HelpRes is the result from a call to Help
121 HelpRes struct { Res *string; Err error }
122 // NodeRes is the result from a call to Node
123 NodeRes struct { Res *None; Err error }
124 // PingRes is the result from a call to Ping
125 PingRes struct { Res *None; Err error }
126 // ResetChainRes is the result from a call to ResetChain
127 ResetChainRes struct { Res *None; Err error }
128 // RestartRes is the result from a call to Restart
129 RestartRes struct { Res *None; Err error }
130 // SearchRawTransactionsRes is the result from a call to SearchRawTransactions
131 SearchRawTransactionsRes struct { Res *[]btcjson.SearchRawTransactionsResult; Err error }
132 // SendRawTransactionRes is the result from a call to SendRawTransaction
133 SendRawTransactionRes struct { Res *None; Err error }
134 // SetGenerateRes is the result from a call to SetGenerate
135 SetGenerateRes struct { Res *None; Err error }
136 // StopRes is the result from a call to Stop
137 StopRes struct { Res *None; Err error }
138 // SubmitBlockRes is the result from a call to SubmitBlock
139 SubmitBlockRes struct { Res *string; Err error }
140 // UptimeRes is the result from a call to Uptime
141 UptimeRes struct { Res *btcjson.GetMempoolInfoResult; Err error }
142 // ValidateAddressRes is the result from a call to ValidateAddress
143 ValidateAddressRes struct { Res *btcjson.ValidateAddressChainResult; Err error }
144 // VerifyChainRes is the result from a call to VerifyChain
145 VerifyChainRes struct { Res *bool; Err error }
146 // VerifyMessageRes is the result from a call to VerifyMessage
147 VerifyMessageRes struct { Res *bool; Err error }
148 // VersionRes is the result from a call to Version
149 VersionRes struct { Res *map[string]btcjson.VersionResult; Err error }
150 )
151 152 // RPCHandlersBeforeInit are created first and are added to the main list
153 // when the init runs.
154 //
155 // - Fn is the handler function
156 //
157 // - Call is a channel carrying a struct containing parameters and error that is
158 // listened to in RunAPI to dispatch the calls
159 //
160 // - Result is a bundle of command parameters and a channel that the result will be sent
161 // back on
162 //
163 // Get and save the Result function's return, and you can then call the call functions
164 // check, result and wait functions for asynchronous and synchronous calls to RPC functions
165 var RPCHandlersBeforeInit = map[string]CommandHandler{
166 "addnode":{
167 Fn: HandleAddNode, Call: make(chan API, 32),
168 Result: func() API { return API{Ch: make(chan AddNodeRes)} }},
169 "createrawtransaction":{
170 Fn: HandleCreateRawTransaction, Call: make(chan API, 32),
171 Result: func() API { return API{Ch: make(chan CreateRawTransactionRes)} }},
172 "decoderawtransaction":{
173 Fn: HandleDecodeRawTransaction, Call: make(chan API, 32),
174 Result: func() API { return API{Ch: make(chan DecodeRawTransactionRes)} }},
175 "decodescript":{
176 Fn: HandleDecodeScript, Call: make(chan API, 32),
177 Result: func() API { return API{Ch: make(chan DecodeScriptRes)} }},
178 "estimatefee":{
179 Fn: HandleEstimateFee, Call: make(chan API, 32),
180 Result: func() API { return API{Ch: make(chan EstimateFeeRes)} }},
181 "generate":{
182 Fn: HandleGenerate, Call: make(chan API, 32),
183 Result: func() API { return API{Ch: make(chan GenerateRes)} }},
184 "getaddednodeinfo":{
185 Fn: HandleGetAddedNodeInfo, Call: make(chan API, 32),
186 Result: func() API { return API{Ch: make(chan GetAddedNodeInfoRes)} }},
187 "getbestblock":{
188 Fn: HandleGetBestBlock, Call: make(chan API, 32),
189 Result: func() API { return API{Ch: make(chan GetBestBlockRes)} }},
190 "getbestblockhash":{
191 Fn: HandleGetBestBlockHash, Call: make(chan API, 32),
192 Result: func() API { return API{Ch: make(chan GetBestBlockHashRes)} }},
193 "getblock":{
194 Fn: HandleGetBlock, Call: make(chan API, 32),
195 Result: func() API { return API{Ch: make(chan GetBlockRes)} }},
196 "getblockchaininfo":{
197 Fn: HandleGetBlockChainInfo, Call: make(chan API, 32),
198 Result: func() API { return API{Ch: make(chan GetBlockChainInfoRes)} }},
199 "getblockcount":{
200 Fn: HandleGetBlockCount, Call: make(chan API, 32),
201 Result: func() API { return API{Ch: make(chan GetBlockCountRes)} }},
202 "getblockhash":{
203 Fn: HandleGetBlockHash, Call: make(chan API, 32),
204 Result: func() API { return API{Ch: make(chan GetBlockHashRes)} }},
205 "getblockheader":{
206 Fn: HandleGetBlockHeader, Call: make(chan API, 32),
207 Result: func() API { return API{Ch: make(chan GetBlockHeaderRes)} }},
208 "getblocktemplate":{
209 Fn: HandleGetBlockTemplate, Call: make(chan API, 32),
210 Result: func() API { return API{Ch: make(chan GetBlockTemplateRes)} }},
211 "getcfilter":{
212 Fn: HandleGetCFilter, Call: make(chan API, 32),
213 Result: func() API { return API{Ch: make(chan GetCFilterRes)} }},
214 "getcfilterheader":{
215 Fn: HandleGetCFilterHeader, Call: make(chan API, 32),
216 Result: func() API { return API{Ch: make(chan GetCFilterHeaderRes)} }},
217 "getconnectioncount":{
218 Fn: HandleGetConnectionCount, Call: make(chan API, 32),
219 Result: func() API { return API{Ch: make(chan GetConnectionCountRes)} }},
220 "getcurrentnet":{
221 Fn: HandleGetCurrentNet, Call: make(chan API, 32),
222 Result: func() API { return API{Ch: make(chan GetCurrentNetRes)} }},
223 "getdifficulty":{
224 Fn: HandleGetDifficulty, Call: make(chan API, 32),
225 Result: func() API { return API{Ch: make(chan GetDifficultyRes)} }},
226 "getgenerate":{
227 Fn: HandleGetGenerate, Call: make(chan API, 32),
228 Result: func() API { return API{Ch: make(chan GetGenerateRes)} }},
229 "gethashespersec":{
230 Fn: HandleGetHashesPerSec, Call: make(chan API, 32),
231 Result: func() API { return API{Ch: make(chan GetHashesPerSecRes)} }},
232 "getheaders":{
233 Fn: HandleGetHeaders, Call: make(chan API, 32),
234 Result: func() API { return API{Ch: make(chan GetHeadersRes)} }},
235 "getinfo":{
236 Fn: HandleGetInfo, Call: make(chan API, 32),
237 Result: func() API { return API{Ch: make(chan GetInfoRes)} }},
238 "getmempoolinfo":{
239 Fn: HandleGetMempoolInfo, Call: make(chan API, 32),
240 Result: func() API { return API{Ch: make(chan GetMempoolInfoRes)} }},
241 "getmininginfo":{
242 Fn: HandleGetMiningInfo, Call: make(chan API, 32),
243 Result: func() API { return API{Ch: make(chan GetMiningInfoRes)} }},
244 "getnettotals":{
245 Fn: HandleGetNetTotals, Call: make(chan API, 32),
246 Result: func() API { return API{Ch: make(chan GetNetTotalsRes)} }},
247 "getnetworkhashps":{
248 Fn: HandleGetNetworkHashPS, Call: make(chan API, 32),
249 Result: func() API { return API{Ch: make(chan GetNetworkHashPSRes)} }},
250 "getpeerinfo":{
251 Fn: HandleGetPeerInfo, Call: make(chan API, 32),
252 Result: func() API { return API{Ch: make(chan GetPeerInfoRes)} }},
253 "getrawmempool":{
254 Fn: HandleGetRawMempool, Call: make(chan API, 32),
255 Result: func() API { return API{Ch: make(chan GetRawMempoolRes)} }},
256 "getrawtransaction":{
257 Fn: HandleGetRawTransaction, Call: make(chan API, 32),
258 Result: func() API { return API{Ch: make(chan GetRawTransactionRes)} }},
259 "gettxout":{
260 Fn: HandleGetTxOut, Call: make(chan API, 32),
261 Result: func() API { return API{Ch: make(chan GetTxOutRes)} }},
262 "help":{
263 Fn: HandleHelp, Call: make(chan API, 32),
264 Result: func() API { return API{Ch: make(chan HelpRes)} }},
265 "node":{
266 Fn: HandleNode, Call: make(chan API, 32),
267 Result: func() API { return API{Ch: make(chan NodeRes)} }},
268 "ping":{
269 Fn: HandlePing, Call: make(chan API, 32),
270 Result: func() API { return API{Ch: make(chan PingRes)} }},
271 "resetchain":{
272 Fn: HandleResetChain, Call: make(chan API, 32),
273 Result: func() API { return API{Ch: make(chan ResetChainRes)} }},
274 "restart":{
275 Fn: HandleRestart, Call: make(chan API, 32),
276 Result: func() API { return API{Ch: make(chan RestartRes)} }},
277 "searchrawtransactions":{
278 Fn: HandleSearchRawTransactions, Call: make(chan API, 32),
279 Result: func() API { return API{Ch: make(chan SearchRawTransactionsRes)} }},
280 "sendrawtransaction":{
281 Fn: HandleSendRawTransaction, Call: make(chan API, 32),
282 Result: func() API { return API{Ch: make(chan SendRawTransactionRes)} }},
283 "setgenerate":{
284 Fn: HandleSetGenerate, Call: make(chan API, 32),
285 Result: func() API { return API{Ch: make(chan SetGenerateRes)} }},
286 "stop":{
287 Fn: HandleStop, Call: make(chan API, 32),
288 Result: func() API { return API{Ch: make(chan StopRes)} }},
289 "submitblock":{
290 Fn: HandleSubmitBlock, Call: make(chan API, 32),
291 Result: func() API { return API{Ch: make(chan SubmitBlockRes)} }},
292 "uptime":{
293 Fn: HandleUptime, Call: make(chan API, 32),
294 Result: func() API { return API{Ch: make(chan UptimeRes)} }},
295 "validateaddress":{
296 Fn: HandleValidateAddress, Call: make(chan API, 32),
297 Result: func() API { return API{Ch: make(chan ValidateAddressRes)} }},
298 "verifychain":{
299 Fn: HandleVerifyChain, Call: make(chan API, 32),
300 Result: func() API { return API{Ch: make(chan VerifyChainRes)} }},
301 "verifymessage":{
302 Fn: HandleVerifyMessage, Call: make(chan API, 32),
303 Result: func() API { return API{Ch: make(chan VerifyMessageRes)} }},
304 "version":{
305 Fn: HandleVersion, Call: make(chan API, 32),
306 Result: func() API { return API{Ch: make(chan VersionRes)} }},
307 308 }
309 310 // API functions
311 //
312 // The functions here provide access to the RPC through a convenient set of functions
313 // generated for each call in the RPC API to request, check for, access the results and
314 // wait on results
315 316 317 // AddNode calls the method with the given parameters
318 func (a API) AddNode(cmd *btcjson.AddNodeCmd) (e error) {
319 RPCHandlers["addnode"].Call <-API{a.Ch, cmd, nil}
320 return
321 }
322 323 // AddNodeChk checks if a new message arrived on the result channel and
324 // returns true if it does, as well as storing the value in the Result field
325 func (a API) AddNodeChk() (isNew bool) {
326 select {
327 case o := <-a.Ch.(chan AddNodeRes):
328 if o.Err != nil {
329 a.Result = o.Err
330 } else {
331 a.Result = o.Res
332 }
333 isNew = true
334 default:
335 }
336 return
337 }
338 339 // AddNodeGetRes returns a pointer to the value in the Result field
340 func (a API) AddNodeGetRes() (out *None, e error) {
341 out, _ = a.Result.(*None)
342 e, _ = a.Result.(error)
343 return
344 }
345 346 // AddNodeWait calls the method and blocks until it returns or 5 seconds passes
347 func (a API) AddNodeWait(cmd *btcjson.AddNodeCmd) (out *None, e error) {
348 RPCHandlers["addnode"].Call <-API{a.Ch, cmd, nil}
349 select {
350 case <-time.After(time.Second*5):
351 break
352 case o := <-a.Ch.(chan AddNodeRes):
353 out, e = o.Res, o.Err
354 }
355 return
356 }
357 358 // CreateRawTransaction calls the method with the given parameters
359 func (a API) CreateRawTransaction(cmd *btcjson.CreateRawTransactionCmd) (e error) {
360 RPCHandlers["createrawtransaction"].Call <-API{a.Ch, cmd, nil}
361 return
362 }
363 364 // CreateRawTransactionChk checks if a new message arrived on the result channel and
365 // returns true if it does, as well as storing the value in the Result field
366 func (a API) CreateRawTransactionChk() (isNew bool) {
367 select {
368 case o := <-a.Ch.(chan CreateRawTransactionRes):
369 if o.Err != nil {
370 a.Result = o.Err
371 } else {
372 a.Result = o.Res
373 }
374 isNew = true
375 default:
376 }
377 return
378 }
379 380 // CreateRawTransactionGetRes returns a pointer to the value in the Result field
381 func (a API) CreateRawTransactionGetRes() (out *string, e error) {
382 out, _ = a.Result.(*string)
383 e, _ = a.Result.(error)
384 return
385 }
386 387 // CreateRawTransactionWait calls the method and blocks until it returns or 5 seconds passes
388 func (a API) CreateRawTransactionWait(cmd *btcjson.CreateRawTransactionCmd) (out *string, e error) {
389 RPCHandlers["createrawtransaction"].Call <-API{a.Ch, cmd, nil}
390 select {
391 case <-time.After(time.Second*5):
392 break
393 case o := <-a.Ch.(chan CreateRawTransactionRes):
394 out, e = o.Res, o.Err
395 }
396 return
397 }
398 399 // DecodeRawTransaction calls the method with the given parameters
400 func (a API) DecodeRawTransaction(cmd *btcjson.DecodeRawTransactionCmd) (e error) {
401 RPCHandlers["decoderawtransaction"].Call <-API{a.Ch, cmd, nil}
402 return
403 }
404 405 // DecodeRawTransactionChk checks if a new message arrived on the result channel and
406 // returns true if it does, as well as storing the value in the Result field
407 func (a API) DecodeRawTransactionChk() (isNew bool) {
408 select {
409 case o := <-a.Ch.(chan DecodeRawTransactionRes):
410 if o.Err != nil {
411 a.Result = o.Err
412 } else {
413 a.Result = o.Res
414 }
415 isNew = true
416 default:
417 }
418 return
419 }
420 421 // DecodeRawTransactionGetRes returns a pointer to the value in the Result field
422 func (a API) DecodeRawTransactionGetRes() (out *btcjson.TxRawDecodeResult, e error) {
423 out, _ = a.Result.(*btcjson.TxRawDecodeResult)
424 e, _ = a.Result.(error)
425 return
426 }
427 428 // DecodeRawTransactionWait calls the method and blocks until it returns or 5 seconds passes
429 func (a API) DecodeRawTransactionWait(cmd *btcjson.DecodeRawTransactionCmd) (out *btcjson.TxRawDecodeResult, e error) {
430 RPCHandlers["decoderawtransaction"].Call <-API{a.Ch, cmd, nil}
431 select {
432 case <-time.After(time.Second*5):
433 break
434 case o := <-a.Ch.(chan DecodeRawTransactionRes):
435 out, e = o.Res, o.Err
436 }
437 return
438 }
439 440 // DecodeScript calls the method with the given parameters
441 func (a API) DecodeScript(cmd *btcjson.DecodeScriptCmd) (e error) {
442 RPCHandlers["decodescript"].Call <-API{a.Ch, cmd, nil}
443 return
444 }
445 446 // DecodeScriptChk checks if a new message arrived on the result channel and
447 // returns true if it does, as well as storing the value in the Result field
448 func (a API) DecodeScriptChk() (isNew bool) {
449 select {
450 case o := <-a.Ch.(chan DecodeScriptRes):
451 if o.Err != nil {
452 a.Result = o.Err
453 } else {
454 a.Result = o.Res
455 }
456 isNew = true
457 default:
458 }
459 return
460 }
461 462 // DecodeScriptGetRes returns a pointer to the value in the Result field
463 func (a API) DecodeScriptGetRes() (out *btcjson.DecodeScriptResult, e error) {
464 out, _ = a.Result.(*btcjson.DecodeScriptResult)
465 e, _ = a.Result.(error)
466 return
467 }
468 469 // DecodeScriptWait calls the method and blocks until it returns or 5 seconds passes
470 func (a API) DecodeScriptWait(cmd *btcjson.DecodeScriptCmd) (out *btcjson.DecodeScriptResult, e error) {
471 RPCHandlers["decodescript"].Call <-API{a.Ch, cmd, nil}
472 select {
473 case <-time.After(time.Second*5):
474 break
475 case o := <-a.Ch.(chan DecodeScriptRes):
476 out, e = o.Res, o.Err
477 }
478 return
479 }
480 481 // EstimateFee calls the method with the given parameters
482 func (a API) EstimateFee(cmd *btcjson.EstimateFeeCmd) (e error) {
483 RPCHandlers["estimatefee"].Call <-API{a.Ch, cmd, nil}
484 return
485 }
486 487 // EstimateFeeChk checks if a new message arrived on the result channel and
488 // returns true if it does, as well as storing the value in the Result field
489 func (a API) EstimateFeeChk() (isNew bool) {
490 select {
491 case o := <-a.Ch.(chan EstimateFeeRes):
492 if o.Err != nil {
493 a.Result = o.Err
494 } else {
495 a.Result = o.Res
496 }
497 isNew = true
498 default:
499 }
500 return
501 }
502 503 // EstimateFeeGetRes returns a pointer to the value in the Result field
504 func (a API) EstimateFeeGetRes() (out *float64, e error) {
505 out, _ = a.Result.(*float64)
506 e, _ = a.Result.(error)
507 return
508 }
509 510 // EstimateFeeWait calls the method and blocks until it returns or 5 seconds passes
511 func (a API) EstimateFeeWait(cmd *btcjson.EstimateFeeCmd) (out *float64, e error) {
512 RPCHandlers["estimatefee"].Call <-API{a.Ch, cmd, nil}
513 select {
514 case <-time.After(time.Second*5):
515 break
516 case o := <-a.Ch.(chan EstimateFeeRes):
517 out, e = o.Res, o.Err
518 }
519 return
520 }
521 522 // Generate calls the method with the given parameters
523 func (a API) Generate(cmd *None) (e error) {
524 RPCHandlers["generate"].Call <-API{a.Ch, cmd, nil}
525 return
526 }
527 528 // GenerateChk checks if a new message arrived on the result channel and
529 // returns true if it does, as well as storing the value in the Result field
530 func (a API) GenerateChk() (isNew bool) {
531 select {
532 case o := <-a.Ch.(chan GenerateRes):
533 if o.Err != nil {
534 a.Result = o.Err
535 } else {
536 a.Result = o.Res
537 }
538 isNew = true
539 default:
540 }
541 return
542 }
543 544 // GenerateGetRes returns a pointer to the value in the Result field
545 func (a API) GenerateGetRes() (out *[]string, e error) {
546 out, _ = a.Result.(*[]string)
547 e, _ = a.Result.(error)
548 return
549 }
550 551 // GenerateWait calls the method and blocks until it returns or 5 seconds passes
552 func (a API) GenerateWait(cmd *None) (out *[]string, e error) {
553 RPCHandlers["generate"].Call <-API{a.Ch, cmd, nil}
554 select {
555 case <-time.After(time.Second*5):
556 break
557 case o := <-a.Ch.(chan GenerateRes):
558 out, e = o.Res, o.Err
559 }
560 return
561 }
562 563 // GetAddedNodeInfo calls the method with the given parameters
564 func (a API) GetAddedNodeInfo(cmd *btcjson.GetAddedNodeInfoCmd) (e error) {
565 RPCHandlers["getaddednodeinfo"].Call <-API{a.Ch, cmd, nil}
566 return
567 }
568 569 // GetAddedNodeInfoChk checks if a new message arrived on the result channel and
570 // returns true if it does, as well as storing the value in the Result field
571 func (a API) GetAddedNodeInfoChk() (isNew bool) {
572 select {
573 case o := <-a.Ch.(chan GetAddedNodeInfoRes):
574 if o.Err != nil {
575 a.Result = o.Err
576 } else {
577 a.Result = o.Res
578 }
579 isNew = true
580 default:
581 }
582 return
583 }
584 585 // GetAddedNodeInfoGetRes returns a pointer to the value in the Result field
586 func (a API) GetAddedNodeInfoGetRes() (out *[]btcjson.GetAddedNodeInfoResultAddr, e error) {
587 out, _ = a.Result.(*[]btcjson.GetAddedNodeInfoResultAddr)
588 e, _ = a.Result.(error)
589 return
590 }
591 592 // GetAddedNodeInfoWait calls the method and blocks until it returns or 5 seconds passes
593 func (a API) GetAddedNodeInfoWait(cmd *btcjson.GetAddedNodeInfoCmd) (out *[]btcjson.GetAddedNodeInfoResultAddr, e error) {
594 RPCHandlers["getaddednodeinfo"].Call <-API{a.Ch, cmd, nil}
595 select {
596 case <-time.After(time.Second*5):
597 break
598 case o := <-a.Ch.(chan GetAddedNodeInfoRes):
599 out, e = o.Res, o.Err
600 }
601 return
602 }
603 604 // GetBestBlock calls the method with the given parameters
605 func (a API) GetBestBlock(cmd *None) (e error) {
606 RPCHandlers["getbestblock"].Call <-API{a.Ch, cmd, nil}
607 return
608 }
609 610 // GetBestBlockChk checks if a new message arrived on the result channel and
611 // returns true if it does, as well as storing the value in the Result field
612 func (a API) GetBestBlockChk() (isNew bool) {
613 select {
614 case o := <-a.Ch.(chan GetBestBlockRes):
615 if o.Err != nil {
616 a.Result = o.Err
617 } else {
618 a.Result = o.Res
619 }
620 isNew = true
621 default:
622 }
623 return
624 }
625 626 // GetBestBlockGetRes returns a pointer to the value in the Result field
627 func (a API) GetBestBlockGetRes() (out *btcjson.GetBestBlockResult, e error) {
628 out, _ = a.Result.(*btcjson.GetBestBlockResult)
629 e, _ = a.Result.(error)
630 return
631 }
632 633 // GetBestBlockWait calls the method and blocks until it returns or 5 seconds passes
634 func (a API) GetBestBlockWait(cmd *None) (out *btcjson.GetBestBlockResult, e error) {
635 RPCHandlers["getbestblock"].Call <-API{a.Ch, cmd, nil}
636 select {
637 case <-time.After(time.Second*5):
638 break
639 case o := <-a.Ch.(chan GetBestBlockRes):
640 out, e = o.Res, o.Err
641 }
642 return
643 }
644 645 // GetBestBlockHash calls the method with the given parameters
646 func (a API) GetBestBlockHash(cmd *None) (e error) {
647 RPCHandlers["getbestblockhash"].Call <-API{a.Ch, cmd, nil}
648 return
649 }
650 651 // GetBestBlockHashChk checks if a new message arrived on the result channel and
652 // returns true if it does, as well as storing the value in the Result field
653 func (a API) GetBestBlockHashChk() (isNew bool) {
654 select {
655 case o := <-a.Ch.(chan GetBestBlockHashRes):
656 if o.Err != nil {
657 a.Result = o.Err
658 } else {
659 a.Result = o.Res
660 }
661 isNew = true
662 default:
663 }
664 return
665 }
666 667 // GetBestBlockHashGetRes returns a pointer to the value in the Result field
668 func (a API) GetBestBlockHashGetRes() (out *string, e error) {
669 out, _ = a.Result.(*string)
670 e, _ = a.Result.(error)
671 return
672 }
673 674 // GetBestBlockHashWait calls the method and blocks until it returns or 5 seconds passes
675 func (a API) GetBestBlockHashWait(cmd *None) (out *string, e error) {
676 RPCHandlers["getbestblockhash"].Call <-API{a.Ch, cmd, nil}
677 select {
678 case <-time.After(time.Second*5):
679 break
680 case o := <-a.Ch.(chan GetBestBlockHashRes):
681 out, e = o.Res, o.Err
682 }
683 return
684 }
685 686 // GetBlock calls the method with the given parameters
687 func (a API) GetBlock(cmd *btcjson.GetBlockCmd) (e error) {
688 RPCHandlers["getblock"].Call <-API{a.Ch, cmd, nil}
689 return
690 }
691 692 // GetBlockChk checks if a new message arrived on the result channel and
693 // returns true if it does, as well as storing the value in the Result field
694 func (a API) GetBlockChk() (isNew bool) {
695 select {
696 case o := <-a.Ch.(chan GetBlockRes):
697 if o.Err != nil {
698 a.Result = o.Err
699 } else {
700 a.Result = o.Res
701 }
702 isNew = true
703 default:
704 }
705 return
706 }
707 708 // GetBlockGetRes returns a pointer to the value in the Result field
709 func (a API) GetBlockGetRes() (out *btcjson.GetBlockVerboseResult, e error) {
710 out, _ = a.Result.(*btcjson.GetBlockVerboseResult)
711 e, _ = a.Result.(error)
712 return
713 }
714 715 // GetBlockWait calls the method and blocks until it returns or 5 seconds passes
716 func (a API) GetBlockWait(cmd *btcjson.GetBlockCmd) (out *btcjson.GetBlockVerboseResult, e error) {
717 RPCHandlers["getblock"].Call <-API{a.Ch, cmd, nil}
718 select {
719 case <-time.After(time.Second*5):
720 break
721 case o := <-a.Ch.(chan GetBlockRes):
722 out, e = o.Res, o.Err
723 }
724 return
725 }
726 727 // GetBlockChainInfo calls the method with the given parameters
728 func (a API) GetBlockChainInfo(cmd *None) (e error) {
729 RPCHandlers["getblockchaininfo"].Call <-API{a.Ch, cmd, nil}
730 return
731 }
732 733 // GetBlockChainInfoChk checks if a new message arrived on the result channel and
734 // returns true if it does, as well as storing the value in the Result field
735 func (a API) GetBlockChainInfoChk() (isNew bool) {
736 select {
737 case o := <-a.Ch.(chan GetBlockChainInfoRes):
738 if o.Err != nil {
739 a.Result = o.Err
740 } else {
741 a.Result = o.Res
742 }
743 isNew = true
744 default:
745 }
746 return
747 }
748 749 // GetBlockChainInfoGetRes returns a pointer to the value in the Result field
750 func (a API) GetBlockChainInfoGetRes() (out *btcjson.GetBlockChainInfoResult, e error) {
751 out, _ = a.Result.(*btcjson.GetBlockChainInfoResult)
752 e, _ = a.Result.(error)
753 return
754 }
755 756 // GetBlockChainInfoWait calls the method and blocks until it returns or 5 seconds passes
757 func (a API) GetBlockChainInfoWait(cmd *None) (out *btcjson.GetBlockChainInfoResult, e error) {
758 RPCHandlers["getblockchaininfo"].Call <-API{a.Ch, cmd, nil}
759 select {
760 case <-time.After(time.Second*5):
761 break
762 case o := <-a.Ch.(chan GetBlockChainInfoRes):
763 out, e = o.Res, o.Err
764 }
765 return
766 }
767 768 // GetBlockCount calls the method with the given parameters
769 func (a API) GetBlockCount(cmd *None) (e error) {
770 RPCHandlers["getblockcount"].Call <-API{a.Ch, cmd, nil}
771 return
772 }
773 774 // GetBlockCountChk checks if a new message arrived on the result channel and
775 // returns true if it does, as well as storing the value in the Result field
776 func (a API) GetBlockCountChk() (isNew bool) {
777 select {
778 case o := <-a.Ch.(chan GetBlockCountRes):
779 if o.Err != nil {
780 a.Result = o.Err
781 } else {
782 a.Result = o.Res
783 }
784 isNew = true
785 default:
786 }
787 return
788 }
789 790 // GetBlockCountGetRes returns a pointer to the value in the Result field
791 func (a API) GetBlockCountGetRes() (out *int64, e error) {
792 out, _ = a.Result.(*int64)
793 e, _ = a.Result.(error)
794 return
795 }
796 797 // GetBlockCountWait calls the method and blocks until it returns or 5 seconds passes
798 func (a API) GetBlockCountWait(cmd *None) (out *int64, e error) {
799 RPCHandlers["getblockcount"].Call <-API{a.Ch, cmd, nil}
800 select {
801 case <-time.After(time.Second*5):
802 break
803 case o := <-a.Ch.(chan GetBlockCountRes):
804 out, e = o.Res, o.Err
805 }
806 return
807 }
808 809 // GetBlockHash calls the method with the given parameters
810 func (a API) GetBlockHash(cmd *btcjson.GetBlockHashCmd) (e error) {
811 RPCHandlers["getblockhash"].Call <-API{a.Ch, cmd, nil}
812 return
813 }
814 815 // GetBlockHashChk checks if a new message arrived on the result channel and
816 // returns true if it does, as well as storing the value in the Result field
817 func (a API) GetBlockHashChk() (isNew bool) {
818 select {
819 case o := <-a.Ch.(chan GetBlockHashRes):
820 if o.Err != nil {
821 a.Result = o.Err
822 } else {
823 a.Result = o.Res
824 }
825 isNew = true
826 default:
827 }
828 return
829 }
830 831 // GetBlockHashGetRes returns a pointer to the value in the Result field
832 func (a API) GetBlockHashGetRes() (out *string, e error) {
833 out, _ = a.Result.(*string)
834 e, _ = a.Result.(error)
835 return
836 }
837 838 // GetBlockHashWait calls the method and blocks until it returns or 5 seconds passes
839 func (a API) GetBlockHashWait(cmd *btcjson.GetBlockHashCmd) (out *string, e error) {
840 RPCHandlers["getblockhash"].Call <-API{a.Ch, cmd, nil}
841 select {
842 case <-time.After(time.Second*5):
843 break
844 case o := <-a.Ch.(chan GetBlockHashRes):
845 out, e = o.Res, o.Err
846 }
847 return
848 }
849 850 // GetBlockHeader calls the method with the given parameters
851 func (a API) GetBlockHeader(cmd *btcjson.GetBlockHeaderCmd) (e error) {
852 RPCHandlers["getblockheader"].Call <-API{a.Ch, cmd, nil}
853 return
854 }
855 856 // GetBlockHeaderChk checks if a new message arrived on the result channel and
857 // returns true if it does, as well as storing the value in the Result field
858 func (a API) GetBlockHeaderChk() (isNew bool) {
859 select {
860 case o := <-a.Ch.(chan GetBlockHeaderRes):
861 if o.Err != nil {
862 a.Result = o.Err
863 } else {
864 a.Result = o.Res
865 }
866 isNew = true
867 default:
868 }
869 return
870 }
871 872 // GetBlockHeaderGetRes returns a pointer to the value in the Result field
873 func (a API) GetBlockHeaderGetRes() (out *btcjson.GetBlockHeaderVerboseResult, e error) {
874 out, _ = a.Result.(*btcjson.GetBlockHeaderVerboseResult)
875 e, _ = a.Result.(error)
876 return
877 }
878 879 // GetBlockHeaderWait calls the method and blocks until it returns or 5 seconds passes
880 func (a API) GetBlockHeaderWait(cmd *btcjson.GetBlockHeaderCmd) (out *btcjson.GetBlockHeaderVerboseResult, e error) {
881 RPCHandlers["getblockheader"].Call <-API{a.Ch, cmd, nil}
882 select {
883 case <-time.After(time.Second*5):
884 break
885 case o := <-a.Ch.(chan GetBlockHeaderRes):
886 out, e = o.Res, o.Err
887 }
888 return
889 }
890 891 // GetBlockTemplate calls the method with the given parameters
892 func (a API) GetBlockTemplate(cmd *btcjson.GetBlockTemplateCmd) (e error) {
893 RPCHandlers["getblocktemplate"].Call <-API{a.Ch, cmd, nil}
894 return
895 }
896 897 // GetBlockTemplateChk checks if a new message arrived on the result channel and
898 // returns true if it does, as well as storing the value in the Result field
899 func (a API) GetBlockTemplateChk() (isNew bool) {
900 select {
901 case o := <-a.Ch.(chan GetBlockTemplateRes):
902 if o.Err != nil {
903 a.Result = o.Err
904 } else {
905 a.Result = o.Res
906 }
907 isNew = true
908 default:
909 }
910 return
911 }
912 913 // GetBlockTemplateGetRes returns a pointer to the value in the Result field
914 func (a API) GetBlockTemplateGetRes() (out *string, e error) {
915 out, _ = a.Result.(*string)
916 e, _ = a.Result.(error)
917 return
918 }
919 920 // GetBlockTemplateWait calls the method and blocks until it returns or 5 seconds passes
921 func (a API) GetBlockTemplateWait(cmd *btcjson.GetBlockTemplateCmd) (out *string, e error) {
922 RPCHandlers["getblocktemplate"].Call <-API{a.Ch, cmd, nil}
923 select {
924 case <-time.After(time.Second*5):
925 break
926 case o := <-a.Ch.(chan GetBlockTemplateRes):
927 out, e = o.Res, o.Err
928 }
929 return
930 }
931 932 // GetCFilter calls the method with the given parameters
933 func (a API) GetCFilter(cmd *btcjson.GetCFilterCmd) (e error) {
934 RPCHandlers["getcfilter"].Call <-API{a.Ch, cmd, nil}
935 return
936 }
937 938 // GetCFilterChk checks if a new message arrived on the result channel and
939 // returns true if it does, as well as storing the value in the Result field
940 func (a API) GetCFilterChk() (isNew bool) {
941 select {
942 case o := <-a.Ch.(chan GetCFilterRes):
943 if o.Err != nil {
944 a.Result = o.Err
945 } else {
946 a.Result = o.Res
947 }
948 isNew = true
949 default:
950 }
951 return
952 }
953 954 // GetCFilterGetRes returns a pointer to the value in the Result field
955 func (a API) GetCFilterGetRes() (out *string, e error) {
956 out, _ = a.Result.(*string)
957 e, _ = a.Result.(error)
958 return
959 }
960 961 // GetCFilterWait calls the method and blocks until it returns or 5 seconds passes
962 func (a API) GetCFilterWait(cmd *btcjson.GetCFilterCmd) (out *string, e error) {
963 RPCHandlers["getcfilter"].Call <-API{a.Ch, cmd, nil}
964 select {
965 case <-time.After(time.Second*5):
966 break
967 case o := <-a.Ch.(chan GetCFilterRes):
968 out, e = o.Res, o.Err
969 }
970 return
971 }
972 973 // GetCFilterHeader calls the method with the given parameters
974 func (a API) GetCFilterHeader(cmd *btcjson.GetCFilterHeaderCmd) (e error) {
975 RPCHandlers["getcfilterheader"].Call <-API{a.Ch, cmd, nil}
976 return
977 }
978 979 // GetCFilterHeaderChk checks if a new message arrived on the result channel and
980 // returns true if it does, as well as storing the value in the Result field
981 func (a API) GetCFilterHeaderChk() (isNew bool) {
982 select {
983 case o := <-a.Ch.(chan GetCFilterHeaderRes):
984 if o.Err != nil {
985 a.Result = o.Err
986 } else {
987 a.Result = o.Res
988 }
989 isNew = true
990 default:
991 }
992 return
993 }
994 995 // GetCFilterHeaderGetRes returns a pointer to the value in the Result field
996 func (a API) GetCFilterHeaderGetRes() (out *string, e error) {
997 out, _ = a.Result.(*string)
998 e, _ = a.Result.(error)
999 return
1000 }
1001 1002 // GetCFilterHeaderWait calls the method and blocks until it returns or 5 seconds passes
1003 func (a API) GetCFilterHeaderWait(cmd *btcjson.GetCFilterHeaderCmd) (out *string, e error) {
1004 RPCHandlers["getcfilterheader"].Call <-API{a.Ch, cmd, nil}
1005 select {
1006 case <-time.After(time.Second*5):
1007 break
1008 case o := <-a.Ch.(chan GetCFilterHeaderRes):
1009 out, e = o.Res, o.Err
1010 }
1011 return
1012 }
1013 1014 // GetConnectionCount calls the method with the given parameters
1015 func (a API) GetConnectionCount(cmd *None) (e error) {
1016 RPCHandlers["getconnectioncount"].Call <-API{a.Ch, cmd, nil}
1017 return
1018 }
1019 1020 // GetConnectionCountChk checks if a new message arrived on the result channel and
1021 // returns true if it does, as well as storing the value in the Result field
1022 func (a API) GetConnectionCountChk() (isNew bool) {
1023 select {
1024 case o := <-a.Ch.(chan GetConnectionCountRes):
1025 if o.Err != nil {
1026 a.Result = o.Err
1027 } else {
1028 a.Result = o.Res
1029 }
1030 isNew = true
1031 default:
1032 }
1033 return
1034 }
1035 1036 // GetConnectionCountGetRes returns a pointer to the value in the Result field
1037 func (a API) GetConnectionCountGetRes() (out *int32, e error) {
1038 out, _ = a.Result.(*int32)
1039 e, _ = a.Result.(error)
1040 return
1041 }
1042 1043 // GetConnectionCountWait calls the method and blocks until it returns or 5 seconds passes
1044 func (a API) GetConnectionCountWait(cmd *None) (out *int32, e error) {
1045 RPCHandlers["getconnectioncount"].Call <-API{a.Ch, cmd, nil}
1046 select {
1047 case <-time.After(time.Second*5):
1048 break
1049 case o := <-a.Ch.(chan GetConnectionCountRes):
1050 out, e = o.Res, o.Err
1051 }
1052 return
1053 }
1054 1055 // GetCurrentNet calls the method with the given parameters
1056 func (a API) GetCurrentNet(cmd *None) (e error) {
1057 RPCHandlers["getcurrentnet"].Call <-API{a.Ch, cmd, nil}
1058 return
1059 }
1060 1061 // GetCurrentNetChk checks if a new message arrived on the result channel and
1062 // returns true if it does, as well as storing the value in the Result field
1063 func (a API) GetCurrentNetChk() (isNew bool) {
1064 select {
1065 case o := <-a.Ch.(chan GetCurrentNetRes):
1066 if o.Err != nil {
1067 a.Result = o.Err
1068 } else {
1069 a.Result = o.Res
1070 }
1071 isNew = true
1072 default:
1073 }
1074 return
1075 }
1076 1077 // GetCurrentNetGetRes returns a pointer to the value in the Result field
1078 func (a API) GetCurrentNetGetRes() (out *string, e error) {
1079 out, _ = a.Result.(*string)
1080 e, _ = a.Result.(error)
1081 return
1082 }
1083 1084 // GetCurrentNetWait calls the method and blocks until it returns or 5 seconds passes
1085 func (a API) GetCurrentNetWait(cmd *None) (out *string, e error) {
1086 RPCHandlers["getcurrentnet"].Call <-API{a.Ch, cmd, nil}
1087 select {
1088 case <-time.After(time.Second*5):
1089 break
1090 case o := <-a.Ch.(chan GetCurrentNetRes):
1091 out, e = o.Res, o.Err
1092 }
1093 return
1094 }
1095 1096 // GetDifficulty calls the method with the given parameters
1097 func (a API) GetDifficulty(cmd *btcjson.GetDifficultyCmd) (e error) {
1098 RPCHandlers["getdifficulty"].Call <-API{a.Ch, cmd, nil}
1099 return
1100 }
1101 1102 // GetDifficultyChk checks if a new message arrived on the result channel and
1103 // returns true if it does, as well as storing the value in the Result field
1104 func (a API) GetDifficultyChk() (isNew bool) {
1105 select {
1106 case o := <-a.Ch.(chan GetDifficultyRes):
1107 if o.Err != nil {
1108 a.Result = o.Err
1109 } else {
1110 a.Result = o.Res
1111 }
1112 isNew = true
1113 default:
1114 }
1115 return
1116 }
1117 1118 // GetDifficultyGetRes returns a pointer to the value in the Result field
1119 func (a API) GetDifficultyGetRes() (out *float64, e error) {
1120 out, _ = a.Result.(*float64)
1121 e, _ = a.Result.(error)
1122 return
1123 }
1124 1125 // GetDifficultyWait calls the method and blocks until it returns or 5 seconds passes
1126 func (a API) GetDifficultyWait(cmd *btcjson.GetDifficultyCmd) (out *float64, e error) {
1127 RPCHandlers["getdifficulty"].Call <-API{a.Ch, cmd, nil}
1128 select {
1129 case <-time.After(time.Second*5):
1130 break
1131 case o := <-a.Ch.(chan GetDifficultyRes):
1132 out, e = o.Res, o.Err
1133 }
1134 return
1135 }
1136 1137 // GetGenerate calls the method with the given parameters
1138 func (a API) GetGenerate(cmd *btcjson.GetHeadersCmd) (e error) {
1139 RPCHandlers["getgenerate"].Call <-API{a.Ch, cmd, nil}
1140 return
1141 }
1142 1143 // GetGenerateChk checks if a new message arrived on the result channel and
1144 // returns true if it does, as well as storing the value in the Result field
1145 func (a API) GetGenerateChk() (isNew bool) {
1146 select {
1147 case o := <-a.Ch.(chan GetGenerateRes):
1148 if o.Err != nil {
1149 a.Result = o.Err
1150 } else {
1151 a.Result = o.Res
1152 }
1153 isNew = true
1154 default:
1155 }
1156 return
1157 }
1158 1159 // GetGenerateGetRes returns a pointer to the value in the Result field
1160 func (a API) GetGenerateGetRes() (out *bool, e error) {
1161 out, _ = a.Result.(*bool)
1162 e, _ = a.Result.(error)
1163 return
1164 }
1165 1166 // GetGenerateWait calls the method and blocks until it returns or 5 seconds passes
1167 func (a API) GetGenerateWait(cmd *btcjson.GetHeadersCmd) (out *bool, e error) {
1168 RPCHandlers["getgenerate"].Call <-API{a.Ch, cmd, nil}
1169 select {
1170 case <-time.After(time.Second*5):
1171 break
1172 case o := <-a.Ch.(chan GetGenerateRes):
1173 out, e = o.Res, o.Err
1174 }
1175 return
1176 }
1177 1178 // GetHashesPerSec calls the method with the given parameters
1179 func (a API) GetHashesPerSec(cmd *None) (e error) {
1180 RPCHandlers["gethashespersec"].Call <-API{a.Ch, cmd, nil}
1181 return
1182 }
1183 1184 // GetHashesPerSecChk checks if a new message arrived on the result channel and
1185 // returns true if it does, as well as storing the value in the Result field
1186 func (a API) GetHashesPerSecChk() (isNew bool) {
1187 select {
1188 case o := <-a.Ch.(chan GetHashesPerSecRes):
1189 if o.Err != nil {
1190 a.Result = o.Err
1191 } else {
1192 a.Result = o.Res
1193 }
1194 isNew = true
1195 default:
1196 }
1197 return
1198 }
1199 1200 // GetHashesPerSecGetRes returns a pointer to the value in the Result field
1201 func (a API) GetHashesPerSecGetRes() (out *float64, e error) {
1202 out, _ = a.Result.(*float64)
1203 e, _ = a.Result.(error)
1204 return
1205 }
1206 1207 // GetHashesPerSecWait calls the method and blocks until it returns or 5 seconds passes
1208 func (a API) GetHashesPerSecWait(cmd *None) (out *float64, e error) {
1209 RPCHandlers["gethashespersec"].Call <-API{a.Ch, cmd, nil}
1210 select {
1211 case <-time.After(time.Second*5):
1212 break
1213 case o := <-a.Ch.(chan GetHashesPerSecRes):
1214 out, e = o.Res, o.Err
1215 }
1216 return
1217 }
1218 1219 // GetHeaders calls the method with the given parameters
1220 func (a API) GetHeaders(cmd *btcjson.GetHeadersCmd) (e error) {
1221 RPCHandlers["getheaders"].Call <-API{a.Ch, cmd, nil}
1222 return
1223 }
1224 1225 // GetHeadersChk checks if a new message arrived on the result channel and
1226 // returns true if it does, as well as storing the value in the Result field
1227 func (a API) GetHeadersChk() (isNew bool) {
1228 select {
1229 case o := <-a.Ch.(chan GetHeadersRes):
1230 if o.Err != nil {
1231 a.Result = o.Err
1232 } else {
1233 a.Result = o.Res
1234 }
1235 isNew = true
1236 default:
1237 }
1238 return
1239 }
1240 1241 // GetHeadersGetRes returns a pointer to the value in the Result field
1242 func (a API) GetHeadersGetRes() (out *[]string, e error) {
1243 out, _ = a.Result.(*[]string)
1244 e, _ = a.Result.(error)
1245 return
1246 }
1247 1248 // GetHeadersWait calls the method and blocks until it returns or 5 seconds passes
1249 func (a API) GetHeadersWait(cmd *btcjson.GetHeadersCmd) (out *[]string, e error) {
1250 RPCHandlers["getheaders"].Call <-API{a.Ch, cmd, nil}
1251 select {
1252 case <-time.After(time.Second*5):
1253 break
1254 case o := <-a.Ch.(chan GetHeadersRes):
1255 out, e = o.Res, o.Err
1256 }
1257 return
1258 }
1259 1260 // GetInfo calls the method with the given parameters
1261 func (a API) GetInfo(cmd *None) (e error) {
1262 RPCHandlers["getinfo"].Call <-API{a.Ch, cmd, nil}
1263 return
1264 }
1265 1266 // GetInfoChk checks if a new message arrived on the result channel and
1267 // returns true if it does, as well as storing the value in the Result field
1268 func (a API) GetInfoChk() (isNew bool) {
1269 select {
1270 case o := <-a.Ch.(chan GetInfoRes):
1271 if o.Err != nil {
1272 a.Result = o.Err
1273 } else {
1274 a.Result = o.Res
1275 }
1276 isNew = true
1277 default:
1278 }
1279 return
1280 }
1281 1282 // GetInfoGetRes returns a pointer to the value in the Result field
1283 func (a API) GetInfoGetRes() (out *btcjson.InfoChainResult0, e error) {
1284 out, _ = a.Result.(*btcjson.InfoChainResult0)
1285 e, _ = a.Result.(error)
1286 return
1287 }
1288 1289 // GetInfoWait calls the method and blocks until it returns or 5 seconds passes
1290 func (a API) GetInfoWait(cmd *None) (out *btcjson.InfoChainResult0, e error) {
1291 RPCHandlers["getinfo"].Call <-API{a.Ch, cmd, nil}
1292 select {
1293 case <-time.After(time.Second*5):
1294 break
1295 case o := <-a.Ch.(chan GetInfoRes):
1296 out, e = o.Res, o.Err
1297 }
1298 return
1299 }
1300 1301 // GetMempoolInfo calls the method with the given parameters
1302 func (a API) GetMempoolInfo(cmd *None) (e error) {
1303 RPCHandlers["getmempoolinfo"].Call <-API{a.Ch, cmd, nil}
1304 return
1305 }
1306 1307 // GetMempoolInfoChk checks if a new message arrived on the result channel and
1308 // returns true if it does, as well as storing the value in the Result field
1309 func (a API) GetMempoolInfoChk() (isNew bool) {
1310 select {
1311 case o := <-a.Ch.(chan GetMempoolInfoRes):
1312 if o.Err != nil {
1313 a.Result = o.Err
1314 } else {
1315 a.Result = o.Res
1316 }
1317 isNew = true
1318 default:
1319 }
1320 return
1321 }
1322 1323 // GetMempoolInfoGetRes returns a pointer to the value in the Result field
1324 func (a API) GetMempoolInfoGetRes() (out *btcjson.GetMempoolInfoResult, e error) {
1325 out, _ = a.Result.(*btcjson.GetMempoolInfoResult)
1326 e, _ = a.Result.(error)
1327 return
1328 }
1329 1330 // GetMempoolInfoWait calls the method and blocks until it returns or 5 seconds passes
1331 func (a API) GetMempoolInfoWait(cmd *None) (out *btcjson.GetMempoolInfoResult, e error) {
1332 RPCHandlers["getmempoolinfo"].Call <-API{a.Ch, cmd, nil}
1333 select {
1334 case <-time.After(time.Second*5):
1335 break
1336 case o := <-a.Ch.(chan GetMempoolInfoRes):
1337 out, e = o.Res, o.Err
1338 }
1339 return
1340 }
1341 1342 // GetMiningInfo calls the method with the given parameters
1343 func (a API) GetMiningInfo(cmd *None) (e error) {
1344 RPCHandlers["getmininginfo"].Call <-API{a.Ch, cmd, nil}
1345 return
1346 }
1347 1348 // GetMiningInfoChk checks if a new message arrived on the result channel and
1349 // returns true if it does, as well as storing the value in the Result field
1350 func (a API) GetMiningInfoChk() (isNew bool) {
1351 select {
1352 case o := <-a.Ch.(chan GetMiningInfoRes):
1353 if o.Err != nil {
1354 a.Result = o.Err
1355 } else {
1356 a.Result = o.Res
1357 }
1358 isNew = true
1359 default:
1360 }
1361 return
1362 }
1363 1364 // GetMiningInfoGetRes returns a pointer to the value in the Result field
1365 func (a API) GetMiningInfoGetRes() (out *btcjson.GetMiningInfoResult, e error) {
1366 out, _ = a.Result.(*btcjson.GetMiningInfoResult)
1367 e, _ = a.Result.(error)
1368 return
1369 }
1370 1371 // GetMiningInfoWait calls the method and blocks until it returns or 5 seconds passes
1372 func (a API) GetMiningInfoWait(cmd *None) (out *btcjson.GetMiningInfoResult, e error) {
1373 RPCHandlers["getmininginfo"].Call <-API{a.Ch, cmd, nil}
1374 select {
1375 case <-time.After(time.Second*5):
1376 break
1377 case o := <-a.Ch.(chan GetMiningInfoRes):
1378 out, e = o.Res, o.Err
1379 }
1380 return
1381 }
1382 1383 // GetNetTotals calls the method with the given parameters
1384 func (a API) GetNetTotals(cmd *None) (e error) {
1385 RPCHandlers["getnettotals"].Call <-API{a.Ch, cmd, nil}
1386 return
1387 }
1388 1389 // GetNetTotalsChk checks if a new message arrived on the result channel and
1390 // returns true if it does, as well as storing the value in the Result field
1391 func (a API) GetNetTotalsChk() (isNew bool) {
1392 select {
1393 case o := <-a.Ch.(chan GetNetTotalsRes):
1394 if o.Err != nil {
1395 a.Result = o.Err
1396 } else {
1397 a.Result = o.Res
1398 }
1399 isNew = true
1400 default:
1401 }
1402 return
1403 }
1404 1405 // GetNetTotalsGetRes returns a pointer to the value in the Result field
1406 func (a API) GetNetTotalsGetRes() (out *btcjson.GetNetTotalsResult, e error) {
1407 out, _ = a.Result.(*btcjson.GetNetTotalsResult)
1408 e, _ = a.Result.(error)
1409 return
1410 }
1411 1412 // GetNetTotalsWait calls the method and blocks until it returns or 5 seconds passes
1413 func (a API) GetNetTotalsWait(cmd *None) (out *btcjson.GetNetTotalsResult, e error) {
1414 RPCHandlers["getnettotals"].Call <-API{a.Ch, cmd, nil}
1415 select {
1416 case <-time.After(time.Second*5):
1417 break
1418 case o := <-a.Ch.(chan GetNetTotalsRes):
1419 out, e = o.Res, o.Err
1420 }
1421 return
1422 }
1423 1424 // GetNetworkHashPS calls the method with the given parameters
1425 func (a API) GetNetworkHashPS(cmd *btcjson.GetNetworkHashPSCmd) (e error) {
1426 RPCHandlers["getnetworkhashps"].Call <-API{a.Ch, cmd, nil}
1427 return
1428 }
1429 1430 // GetNetworkHashPSChk checks if a new message arrived on the result channel and
1431 // returns true if it does, as well as storing the value in the Result field
1432 func (a API) GetNetworkHashPSChk() (isNew bool) {
1433 select {
1434 case o := <-a.Ch.(chan GetNetworkHashPSRes):
1435 if o.Err != nil {
1436 a.Result = o.Err
1437 } else {
1438 a.Result = o.Res
1439 }
1440 isNew = true
1441 default:
1442 }
1443 return
1444 }
1445 1446 // GetNetworkHashPSGetRes returns a pointer to the value in the Result field
1447 func (a API) GetNetworkHashPSGetRes() (out *[]btcjson.GetPeerInfoResult, e error) {
1448 out, _ = a.Result.(*[]btcjson.GetPeerInfoResult)
1449 e, _ = a.Result.(error)
1450 return
1451 }
1452 1453 // GetNetworkHashPSWait calls the method and blocks until it returns or 5 seconds passes
1454 func (a API) GetNetworkHashPSWait(cmd *btcjson.GetNetworkHashPSCmd) (out *[]btcjson.GetPeerInfoResult, e error) {
1455 RPCHandlers["getnetworkhashps"].Call <-API{a.Ch, cmd, nil}
1456 select {
1457 case <-time.After(time.Second*5):
1458 break
1459 case o := <-a.Ch.(chan GetNetworkHashPSRes):
1460 out, e = o.Res, o.Err
1461 }
1462 return
1463 }
1464 1465 // GetPeerInfo calls the method with the given parameters
1466 func (a API) GetPeerInfo(cmd *None) (e error) {
1467 RPCHandlers["getpeerinfo"].Call <-API{a.Ch, cmd, nil}
1468 return
1469 }
1470 1471 // GetPeerInfoChk checks if a new message arrived on the result channel and
1472 // returns true if it does, as well as storing the value in the Result field
1473 func (a API) GetPeerInfoChk() (isNew bool) {
1474 select {
1475 case o := <-a.Ch.(chan GetPeerInfoRes):
1476 if o.Err != nil {
1477 a.Result = o.Err
1478 } else {
1479 a.Result = o.Res
1480 }
1481 isNew = true
1482 default:
1483 }
1484 return
1485 }
1486 1487 // GetPeerInfoGetRes returns a pointer to the value in the Result field
1488 func (a API) GetPeerInfoGetRes() (out *[]btcjson.GetPeerInfoResult, e error) {
1489 out, _ = a.Result.(*[]btcjson.GetPeerInfoResult)
1490 e, _ = a.Result.(error)
1491 return
1492 }
1493 1494 // GetPeerInfoWait calls the method and blocks until it returns or 5 seconds passes
1495 func (a API) GetPeerInfoWait(cmd *None) (out *[]btcjson.GetPeerInfoResult, e error) {
1496 RPCHandlers["getpeerinfo"].Call <-API{a.Ch, cmd, nil}
1497 select {
1498 case <-time.After(time.Second*5):
1499 break
1500 case o := <-a.Ch.(chan GetPeerInfoRes):
1501 out, e = o.Res, o.Err
1502 }
1503 return
1504 }
1505 1506 // GetRawMempool calls the method with the given parameters
1507 func (a API) GetRawMempool(cmd *btcjson.GetRawMempoolCmd) (e error) {
1508 RPCHandlers["getrawmempool"].Call <-API{a.Ch, cmd, nil}
1509 return
1510 }
1511 1512 // GetRawMempoolChk checks if a new message arrived on the result channel and
1513 // returns true if it does, as well as storing the value in the Result field
1514 func (a API) GetRawMempoolChk() (isNew bool) {
1515 select {
1516 case o := <-a.Ch.(chan GetRawMempoolRes):
1517 if o.Err != nil {
1518 a.Result = o.Err
1519 } else {
1520 a.Result = o.Res
1521 }
1522 isNew = true
1523 default:
1524 }
1525 return
1526 }
1527 1528 // GetRawMempoolGetRes returns a pointer to the value in the Result field
1529 func (a API) GetRawMempoolGetRes() (out *[]string, e error) {
1530 out, _ = a.Result.(*[]string)
1531 e, _ = a.Result.(error)
1532 return
1533 }
1534 1535 // GetRawMempoolWait calls the method and blocks until it returns or 5 seconds passes
1536 func (a API) GetRawMempoolWait(cmd *btcjson.GetRawMempoolCmd) (out *[]string, e error) {
1537 RPCHandlers["getrawmempool"].Call <-API{a.Ch, cmd, nil}
1538 select {
1539 case <-time.After(time.Second*5):
1540 break
1541 case o := <-a.Ch.(chan GetRawMempoolRes):
1542 out, e = o.Res, o.Err
1543 }
1544 return
1545 }
1546 1547 // GetRawTransaction calls the method with the given parameters
1548 func (a API) GetRawTransaction(cmd *btcjson.GetRawTransactionCmd) (e error) {
1549 RPCHandlers["getrawtransaction"].Call <-API{a.Ch, cmd, nil}
1550 return
1551 }
1552 1553 // GetRawTransactionChk checks if a new message arrived on the result channel and
1554 // returns true if it does, as well as storing the value in the Result field
1555 func (a API) GetRawTransactionChk() (isNew bool) {
1556 select {
1557 case o := <-a.Ch.(chan GetRawTransactionRes):
1558 if o.Err != nil {
1559 a.Result = o.Err
1560 } else {
1561 a.Result = o.Res
1562 }
1563 isNew = true
1564 default:
1565 }
1566 return
1567 }
1568 1569 // GetRawTransactionGetRes returns a pointer to the value in the Result field
1570 func (a API) GetRawTransactionGetRes() (out *string, e error) {
1571 out, _ = a.Result.(*string)
1572 e, _ = a.Result.(error)
1573 return
1574 }
1575 1576 // GetRawTransactionWait calls the method and blocks until it returns or 5 seconds passes
1577 func (a API) GetRawTransactionWait(cmd *btcjson.GetRawTransactionCmd) (out *string, e error) {
1578 RPCHandlers["getrawtransaction"].Call <-API{a.Ch, cmd, nil}
1579 select {
1580 case <-time.After(time.Second*5):
1581 break
1582 case o := <-a.Ch.(chan GetRawTransactionRes):
1583 out, e = o.Res, o.Err
1584 }
1585 return
1586 }
1587 1588 // GetTxOut calls the method with the given parameters
1589 func (a API) GetTxOut(cmd *btcjson.GetTxOutCmd) (e error) {
1590 RPCHandlers["gettxout"].Call <-API{a.Ch, cmd, nil}
1591 return
1592 }
1593 1594 // GetTxOutChk checks if a new message arrived on the result channel and
1595 // returns true if it does, as well as storing the value in the Result field
1596 func (a API) GetTxOutChk() (isNew bool) {
1597 select {
1598 case o := <-a.Ch.(chan GetTxOutRes):
1599 if o.Err != nil {
1600 a.Result = o.Err
1601 } else {
1602 a.Result = o.Res
1603 }
1604 isNew = true
1605 default:
1606 }
1607 return
1608 }
1609 1610 // GetTxOutGetRes returns a pointer to the value in the Result field
1611 func (a API) GetTxOutGetRes() (out *string, e error) {
1612 out, _ = a.Result.(*string)
1613 e, _ = a.Result.(error)
1614 return
1615 }
1616 1617 // GetTxOutWait calls the method and blocks until it returns or 5 seconds passes
1618 func (a API) GetTxOutWait(cmd *btcjson.GetTxOutCmd) (out *string, e error) {
1619 RPCHandlers["gettxout"].Call <-API{a.Ch, cmd, nil}
1620 select {
1621 case <-time.After(time.Second*5):
1622 break
1623 case o := <-a.Ch.(chan GetTxOutRes):
1624 out, e = o.Res, o.Err
1625 }
1626 return
1627 }
1628 1629 // Help calls the method with the given parameters
1630 func (a API) Help(cmd *btcjson.HelpCmd) (e error) {
1631 RPCHandlers["help"].Call <-API{a.Ch, cmd, nil}
1632 return
1633 }
1634 1635 // HelpChk checks if a new message arrived on the result channel and
1636 // returns true if it does, as well as storing the value in the Result field
1637 func (a API) HelpChk() (isNew bool) {
1638 select {
1639 case o := <-a.Ch.(chan HelpRes):
1640 if o.Err != nil {
1641 a.Result = o.Err
1642 } else {
1643 a.Result = o.Res
1644 }
1645 isNew = true
1646 default:
1647 }
1648 return
1649 }
1650 1651 // HelpGetRes returns a pointer to the value in the Result field
1652 func (a API) HelpGetRes() (out *string, e error) {
1653 out, _ = a.Result.(*string)
1654 e, _ = a.Result.(error)
1655 return
1656 }
1657 1658 // HelpWait calls the method and blocks until it returns or 5 seconds passes
1659 func (a API) HelpWait(cmd *btcjson.HelpCmd) (out *string, e error) {
1660 RPCHandlers["help"].Call <-API{a.Ch, cmd, nil}
1661 select {
1662 case <-time.After(time.Second*5):
1663 break
1664 case o := <-a.Ch.(chan HelpRes):
1665 out, e = o.Res, o.Err
1666 }
1667 return
1668 }
1669 1670 // Node calls the method with the given parameters
1671 func (a API) Node(cmd *btcjson.NodeCmd) (e error) {
1672 RPCHandlers["node"].Call <-API{a.Ch, cmd, nil}
1673 return
1674 }
1675 1676 // NodeChk checks if a new message arrived on the result channel and
1677 // returns true if it does, as well as storing the value in the Result field
1678 func (a API) NodeChk() (isNew bool) {
1679 select {
1680 case o := <-a.Ch.(chan NodeRes):
1681 if o.Err != nil {
1682 a.Result = o.Err
1683 } else {
1684 a.Result = o.Res
1685 }
1686 isNew = true
1687 default:
1688 }
1689 return
1690 }
1691 1692 // NodeGetRes returns a pointer to the value in the Result field
1693 func (a API) NodeGetRes() (out *None, e error) {
1694 out, _ = a.Result.(*None)
1695 e, _ = a.Result.(error)
1696 return
1697 }
1698 1699 // NodeWait calls the method and blocks until it returns or 5 seconds passes
1700 func (a API) NodeWait(cmd *btcjson.NodeCmd) (out *None, e error) {
1701 RPCHandlers["node"].Call <-API{a.Ch, cmd, nil}
1702 select {
1703 case <-time.After(time.Second*5):
1704 break
1705 case o := <-a.Ch.(chan NodeRes):
1706 out, e = o.Res, o.Err
1707 }
1708 return
1709 }
1710 1711 // Ping calls the method with the given parameters
1712 func (a API) Ping(cmd *None) (e error) {
1713 RPCHandlers["ping"].Call <-API{a.Ch, cmd, nil}
1714 return
1715 }
1716 1717 // PingChk checks if a new message arrived on the result channel and
1718 // returns true if it does, as well as storing the value in the Result field
1719 func (a API) PingChk() (isNew bool) {
1720 select {
1721 case o := <-a.Ch.(chan PingRes):
1722 if o.Err != nil {
1723 a.Result = o.Err
1724 } else {
1725 a.Result = o.Res
1726 }
1727 isNew = true
1728 default:
1729 }
1730 return
1731 }
1732 1733 // PingGetRes returns a pointer to the value in the Result field
1734 func (a API) PingGetRes() (out *None, e error) {
1735 out, _ = a.Result.(*None)
1736 e, _ = a.Result.(error)
1737 return
1738 }
1739 1740 // PingWait calls the method and blocks until it returns or 5 seconds passes
1741 func (a API) PingWait(cmd *None) (out *None, e error) {
1742 RPCHandlers["ping"].Call <-API{a.Ch, cmd, nil}
1743 select {
1744 case <-time.After(time.Second*5):
1745 break
1746 case o := <-a.Ch.(chan PingRes):
1747 out, e = o.Res, o.Err
1748 }
1749 return
1750 }
1751 1752 // ResetChain calls the method with the given parameters
1753 func (a API) ResetChain(cmd *None) (e error) {
1754 RPCHandlers["resetchain"].Call <-API{a.Ch, cmd, nil}
1755 return
1756 }
1757 1758 // ResetChainChk checks if a new message arrived on the result channel and
1759 // returns true if it does, as well as storing the value in the Result field
1760 func (a API) ResetChainChk() (isNew bool) {
1761 select {
1762 case o := <-a.Ch.(chan ResetChainRes):
1763 if o.Err != nil {
1764 a.Result = o.Err
1765 } else {
1766 a.Result = o.Res
1767 }
1768 isNew = true
1769 default:
1770 }
1771 return
1772 }
1773 1774 // ResetChainGetRes returns a pointer to the value in the Result field
1775 func (a API) ResetChainGetRes() (out *None, e error) {
1776 out, _ = a.Result.(*None)
1777 e, _ = a.Result.(error)
1778 return
1779 }
1780 1781 // ResetChainWait calls the method and blocks until it returns or 5 seconds passes
1782 func (a API) ResetChainWait(cmd *None) (out *None, e error) {
1783 RPCHandlers["resetchain"].Call <-API{a.Ch, cmd, nil}
1784 select {
1785 case <-time.After(time.Second*5):
1786 break
1787 case o := <-a.Ch.(chan ResetChainRes):
1788 out, e = o.Res, o.Err
1789 }
1790 return
1791 }
1792 1793 // Restart calls the method with the given parameters
1794 func (a API) Restart(cmd *None) (e error) {
1795 RPCHandlers["restart"].Call <-API{a.Ch, cmd, nil}
1796 return
1797 }
1798 1799 // RestartChk checks if a new message arrived on the result channel and
1800 // returns true if it does, as well as storing the value in the Result field
1801 func (a API) RestartChk() (isNew bool) {
1802 select {
1803 case o := <-a.Ch.(chan RestartRes):
1804 if o.Err != nil {
1805 a.Result = o.Err
1806 } else {
1807 a.Result = o.Res
1808 }
1809 isNew = true
1810 default:
1811 }
1812 return
1813 }
1814 1815 // RestartGetRes returns a pointer to the value in the Result field
1816 func (a API) RestartGetRes() (out *None, e error) {
1817 out, _ = a.Result.(*None)
1818 e, _ = a.Result.(error)
1819 return
1820 }
1821 1822 // RestartWait calls the method and blocks until it returns or 5 seconds passes
1823 func (a API) RestartWait(cmd *None) (out *None, e error) {
1824 RPCHandlers["restart"].Call <-API{a.Ch, cmd, nil}
1825 select {
1826 case <-time.After(time.Second*5):
1827 break
1828 case o := <-a.Ch.(chan RestartRes):
1829 out, e = o.Res, o.Err
1830 }
1831 return
1832 }
1833 1834 // SearchRawTransactions calls the method with the given parameters
1835 func (a API) SearchRawTransactions(cmd *btcjson.SearchRawTransactionsCmd) (e error) {
1836 RPCHandlers["searchrawtransactions"].Call <-API{a.Ch, cmd, nil}
1837 return
1838 }
1839 1840 // SearchRawTransactionsChk checks if a new message arrived on the result channel and
1841 // returns true if it does, as well as storing the value in the Result field
1842 func (a API) SearchRawTransactionsChk() (isNew bool) {
1843 select {
1844 case o := <-a.Ch.(chan SearchRawTransactionsRes):
1845 if o.Err != nil {
1846 a.Result = o.Err
1847 } else {
1848 a.Result = o.Res
1849 }
1850 isNew = true
1851 default:
1852 }
1853 return
1854 }
1855 1856 // SearchRawTransactionsGetRes returns a pointer to the value in the Result field
1857 func (a API) SearchRawTransactionsGetRes() (out *[]btcjson.SearchRawTransactionsResult, e error) {
1858 out, _ = a.Result.(*[]btcjson.SearchRawTransactionsResult)
1859 e, _ = a.Result.(error)
1860 return
1861 }
1862 1863 // SearchRawTransactionsWait calls the method and blocks until it returns or 5 seconds passes
1864 func (a API) SearchRawTransactionsWait(cmd *btcjson.SearchRawTransactionsCmd) (out *[]btcjson.SearchRawTransactionsResult, e error) {
1865 RPCHandlers["searchrawtransactions"].Call <-API{a.Ch, cmd, nil}
1866 select {
1867 case <-time.After(time.Second*5):
1868 break
1869 case o := <-a.Ch.(chan SearchRawTransactionsRes):
1870 out, e = o.Res, o.Err
1871 }
1872 return
1873 }
1874 1875 // SendRawTransaction calls the method with the given parameters
1876 func (a API) SendRawTransaction(cmd *btcjson.SendRawTransactionCmd) (e error) {
1877 RPCHandlers["sendrawtransaction"].Call <-API{a.Ch, cmd, nil}
1878 return
1879 }
1880 1881 // SendRawTransactionChk checks if a new message arrived on the result channel and
1882 // returns true if it does, as well as storing the value in the Result field
1883 func (a API) SendRawTransactionChk() (isNew bool) {
1884 select {
1885 case o := <-a.Ch.(chan SendRawTransactionRes):
1886 if o.Err != nil {
1887 a.Result = o.Err
1888 } else {
1889 a.Result = o.Res
1890 }
1891 isNew = true
1892 default:
1893 }
1894 return
1895 }
1896 1897 // SendRawTransactionGetRes returns a pointer to the value in the Result field
1898 func (a API) SendRawTransactionGetRes() (out *None, e error) {
1899 out, _ = a.Result.(*None)
1900 e, _ = a.Result.(error)
1901 return
1902 }
1903 1904 // SendRawTransactionWait calls the method and blocks until it returns or 5 seconds passes
1905 func (a API) SendRawTransactionWait(cmd *btcjson.SendRawTransactionCmd) (out *None, e error) {
1906 RPCHandlers["sendrawtransaction"].Call <-API{a.Ch, cmd, nil}
1907 select {
1908 case <-time.After(time.Second*5):
1909 break
1910 case o := <-a.Ch.(chan SendRawTransactionRes):
1911 out, e = o.Res, o.Err
1912 }
1913 return
1914 }
1915 1916 // SetGenerate calls the method with the given parameters
1917 func (a API) SetGenerate(cmd *btcjson.SetGenerateCmd) (e error) {
1918 RPCHandlers["setgenerate"].Call <-API{a.Ch, cmd, nil}
1919 return
1920 }
1921 1922 // SetGenerateChk checks if a new message arrived on the result channel and
1923 // returns true if it does, as well as storing the value in the Result field
1924 func (a API) SetGenerateChk() (isNew bool) {
1925 select {
1926 case o := <-a.Ch.(chan SetGenerateRes):
1927 if o.Err != nil {
1928 a.Result = o.Err
1929 } else {
1930 a.Result = o.Res
1931 }
1932 isNew = true
1933 default:
1934 }
1935 return
1936 }
1937 1938 // SetGenerateGetRes returns a pointer to the value in the Result field
1939 func (a API) SetGenerateGetRes() (out *None, e error) {
1940 out, _ = a.Result.(*None)
1941 e, _ = a.Result.(error)
1942 return
1943 }
1944 1945 // SetGenerateWait calls the method and blocks until it returns or 5 seconds passes
1946 func (a API) SetGenerateWait(cmd *btcjson.SetGenerateCmd) (out *None, e error) {
1947 RPCHandlers["setgenerate"].Call <-API{a.Ch, cmd, nil}
1948 select {
1949 case <-time.After(time.Second*5):
1950 break
1951 case o := <-a.Ch.(chan SetGenerateRes):
1952 out, e = o.Res, o.Err
1953 }
1954 return
1955 }
1956 1957 // Stop calls the method with the given parameters
1958 func (a API) Stop(cmd *None) (e error) {
1959 RPCHandlers["stop"].Call <-API{a.Ch, cmd, nil}
1960 return
1961 }
1962 1963 // StopChk checks if a new message arrived on the result channel and
1964 // returns true if it does, as well as storing the value in the Result field
1965 func (a API) StopChk() (isNew bool) {
1966 select {
1967 case o := <-a.Ch.(chan StopRes):
1968 if o.Err != nil {
1969 a.Result = o.Err
1970 } else {
1971 a.Result = o.Res
1972 }
1973 isNew = true
1974 default:
1975 }
1976 return
1977 }
1978 1979 // StopGetRes returns a pointer to the value in the Result field
1980 func (a API) StopGetRes() (out *None, e error) {
1981 out, _ = a.Result.(*None)
1982 e, _ = a.Result.(error)
1983 return
1984 }
1985 1986 // StopWait calls the method and blocks until it returns or 5 seconds passes
1987 func (a API) StopWait(cmd *None) (out *None, e error) {
1988 RPCHandlers["stop"].Call <-API{a.Ch, cmd, nil}
1989 select {
1990 case <-time.After(time.Second*5):
1991 break
1992 case o := <-a.Ch.(chan StopRes):
1993 out, e = o.Res, o.Err
1994 }
1995 return
1996 }
1997 1998 // SubmitBlock calls the method with the given parameters
1999 func (a API) SubmitBlock(cmd *btcjson.SubmitBlockCmd) (e error) {
2000 RPCHandlers["submitblock"].Call <-API{a.Ch, cmd, nil}
2001 return
2002 }
2003 2004 // SubmitBlockChk checks if a new message arrived on the result channel and
2005 // returns true if it does, as well as storing the value in the Result field
2006 func (a API) SubmitBlockChk() (isNew bool) {
2007 select {
2008 case o := <-a.Ch.(chan SubmitBlockRes):
2009 if o.Err != nil {
2010 a.Result = o.Err
2011 } else {
2012 a.Result = o.Res
2013 }
2014 isNew = true
2015 default:
2016 }
2017 return
2018 }
2019 2020 // SubmitBlockGetRes returns a pointer to the value in the Result field
2021 func (a API) SubmitBlockGetRes() (out *string, e error) {
2022 out, _ = a.Result.(*string)
2023 e, _ = a.Result.(error)
2024 return
2025 }
2026 2027 // SubmitBlockWait calls the method and blocks until it returns or 5 seconds passes
2028 func (a API) SubmitBlockWait(cmd *btcjson.SubmitBlockCmd) (out *string, e error) {
2029 RPCHandlers["submitblock"].Call <-API{a.Ch, cmd, nil}
2030 select {
2031 case <-time.After(time.Second*5):
2032 break
2033 case o := <-a.Ch.(chan SubmitBlockRes):
2034 out, e = o.Res, o.Err
2035 }
2036 return
2037 }
2038 2039 // Uptime calls the method with the given parameters
2040 func (a API) Uptime(cmd *None) (e error) {
2041 RPCHandlers["uptime"].Call <-API{a.Ch, cmd, nil}
2042 return
2043 }
2044 2045 // UptimeChk checks if a new message arrived on the result channel and
2046 // returns true if it does, as well as storing the value in the Result field
2047 func (a API) UptimeChk() (isNew bool) {
2048 select {
2049 case o := <-a.Ch.(chan UptimeRes):
2050 if o.Err != nil {
2051 a.Result = o.Err
2052 } else {
2053 a.Result = o.Res
2054 }
2055 isNew = true
2056 default:
2057 }
2058 return
2059 }
2060 2061 // UptimeGetRes returns a pointer to the value in the Result field
2062 func (a API) UptimeGetRes() (out *btcjson.GetMempoolInfoResult, e error) {
2063 out, _ = a.Result.(*btcjson.GetMempoolInfoResult)
2064 e, _ = a.Result.(error)
2065 return
2066 }
2067 2068 // UptimeWait calls the method and blocks until it returns or 5 seconds passes
2069 func (a API) UptimeWait(cmd *None) (out *btcjson.GetMempoolInfoResult, e error) {
2070 RPCHandlers["uptime"].Call <-API{a.Ch, cmd, nil}
2071 select {
2072 case <-time.After(time.Second*5):
2073 break
2074 case o := <-a.Ch.(chan UptimeRes):
2075 out, e = o.Res, o.Err
2076 }
2077 return
2078 }
2079 2080 // ValidateAddress calls the method with the given parameters
2081 func (a API) ValidateAddress(cmd *btcjson.ValidateAddressCmd) (e error) {
2082 RPCHandlers["validateaddress"].Call <-API{a.Ch, cmd, nil}
2083 return
2084 }
2085 2086 // ValidateAddressChk checks if a new message arrived on the result channel and
2087 // returns true if it does, as well as storing the value in the Result field
2088 func (a API) ValidateAddressChk() (isNew bool) {
2089 select {
2090 case o := <-a.Ch.(chan ValidateAddressRes):
2091 if o.Err != nil {
2092 a.Result = o.Err
2093 } else {
2094 a.Result = o.Res
2095 }
2096 isNew = true
2097 default:
2098 }
2099 return
2100 }
2101 2102 // ValidateAddressGetRes returns a pointer to the value in the Result field
2103 func (a API) ValidateAddressGetRes() (out *btcjson.ValidateAddressChainResult, e error) {
2104 out, _ = a.Result.(*btcjson.ValidateAddressChainResult)
2105 e, _ = a.Result.(error)
2106 return
2107 }
2108 2109 // ValidateAddressWait calls the method and blocks until it returns or 5 seconds passes
2110 func (a API) ValidateAddressWait(cmd *btcjson.ValidateAddressCmd) (out *btcjson.ValidateAddressChainResult, e error) {
2111 RPCHandlers["validateaddress"].Call <-API{a.Ch, cmd, nil}
2112 select {
2113 case <-time.After(time.Second*5):
2114 break
2115 case o := <-a.Ch.(chan ValidateAddressRes):
2116 out, e = o.Res, o.Err
2117 }
2118 return
2119 }
2120 2121 // VerifyChain calls the method with the given parameters
2122 func (a API) VerifyChain(cmd *btcjson.VerifyChainCmd) (e error) {
2123 RPCHandlers["verifychain"].Call <-API{a.Ch, cmd, nil}
2124 return
2125 }
2126 2127 // VerifyChainChk checks if a new message arrived on the result channel and
2128 // returns true if it does, as well as storing the value in the Result field
2129 func (a API) VerifyChainChk() (isNew bool) {
2130 select {
2131 case o := <-a.Ch.(chan VerifyChainRes):
2132 if o.Err != nil {
2133 a.Result = o.Err
2134 } else {
2135 a.Result = o.Res
2136 }
2137 isNew = true
2138 default:
2139 }
2140 return
2141 }
2142 2143 // VerifyChainGetRes returns a pointer to the value in the Result field
2144 func (a API) VerifyChainGetRes() (out *bool, e error) {
2145 out, _ = a.Result.(*bool)
2146 e, _ = a.Result.(error)
2147 return
2148 }
2149 2150 // VerifyChainWait calls the method and blocks until it returns or 5 seconds passes
2151 func (a API) VerifyChainWait(cmd *btcjson.VerifyChainCmd) (out *bool, e error) {
2152 RPCHandlers["verifychain"].Call <-API{a.Ch, cmd, nil}
2153 select {
2154 case <-time.After(time.Second*5):
2155 break
2156 case o := <-a.Ch.(chan VerifyChainRes):
2157 out, e = o.Res, o.Err
2158 }
2159 return
2160 }
2161 2162 // VerifyMessage calls the method with the given parameters
2163 func (a API) VerifyMessage(cmd *btcjson.VerifyMessageCmd) (e error) {
2164 RPCHandlers["verifymessage"].Call <-API{a.Ch, cmd, nil}
2165 return
2166 }
2167 2168 // VerifyMessageChk checks if a new message arrived on the result channel and
2169 // returns true if it does, as well as storing the value in the Result field
2170 func (a API) VerifyMessageChk() (isNew bool) {
2171 select {
2172 case o := <-a.Ch.(chan VerifyMessageRes):
2173 if o.Err != nil {
2174 a.Result = o.Err
2175 } else {
2176 a.Result = o.Res
2177 }
2178 isNew = true
2179 default:
2180 }
2181 return
2182 }
2183 2184 // VerifyMessageGetRes returns a pointer to the value in the Result field
2185 func (a API) VerifyMessageGetRes() (out *bool, e error) {
2186 out, _ = a.Result.(*bool)
2187 e, _ = a.Result.(error)
2188 return
2189 }
2190 2191 // VerifyMessageWait calls the method and blocks until it returns or 5 seconds passes
2192 func (a API) VerifyMessageWait(cmd *btcjson.VerifyMessageCmd) (out *bool, e error) {
2193 RPCHandlers["verifymessage"].Call <-API{a.Ch, cmd, nil}
2194 select {
2195 case <-time.After(time.Second*5):
2196 break
2197 case o := <-a.Ch.(chan VerifyMessageRes):
2198 out, e = o.Res, o.Err
2199 }
2200 return
2201 }
2202 2203 // Version calls the method with the given parameters
2204 func (a API) Version(cmd *btcjson.VersionCmd) (e error) {
2205 RPCHandlers["version"].Call <-API{a.Ch, cmd, nil}
2206 return
2207 }
2208 2209 // VersionChk checks if a new message arrived on the result channel and
2210 // returns true if it does, as well as storing the value in the Result field
2211 func (a API) VersionChk() (isNew bool) {
2212 select {
2213 case o := <-a.Ch.(chan VersionRes):
2214 if o.Err != nil {
2215 a.Result = o.Err
2216 } else {
2217 a.Result = o.Res
2218 }
2219 isNew = true
2220 default:
2221 }
2222 return
2223 }
2224 2225 // VersionGetRes returns a pointer to the value in the Result field
2226 func (a API) VersionGetRes() (out *map[string]btcjson.VersionResult, e error) {
2227 out, _ = a.Result.(*map[string]btcjson.VersionResult)
2228 e, _ = a.Result.(error)
2229 return
2230 }
2231 2232 // VersionWait calls the method and blocks until it returns or 5 seconds passes
2233 func (a API) VersionWait(cmd *btcjson.VersionCmd) (out *map[string]btcjson.VersionResult, e error) {
2234 RPCHandlers["version"].Call <-API{a.Ch, cmd, nil}
2235 select {
2236 case <-time.After(time.Second*5):
2237 break
2238 case o := <-a.Ch.(chan VersionRes):
2239 out, e = o.Res, o.Err
2240 }
2241 return
2242 }
2243 2244 2245 // RunAPI starts up the api handler server that receives rpc.API messages and runs the handler and returns the result
2246 // Note that the parameters are type asserted to prevent the consumer of the API from sending wrong message types not
2247 // because it's necessary since they are interfaces end to end
2248 func RunAPI(server *Server, quit qu.C) {
2249 nrh := RPCHandlers
2250 go func() {
2251 D.Ln("starting up node cAPI")
2252 var e error
2253 var res interface{}
2254 for {
2255 select {
2256 case msg := <-nrh["addnode"].Call:
2257 if res, e = nrh["addnode"].
2258 Fn(server, msg.Params.(*btcjson.AddNodeCmd), nil); E.Chk(e) {
2259 }
2260 if r, ok := res.(None); ok {
2261 msg.Ch.(chan AddNodeRes) <-AddNodeRes{&r, e} }
2262 case msg := <-nrh["createrawtransaction"].Call:
2263 if res, e = nrh["createrawtransaction"].
2264 Fn(server, msg.Params.(*btcjson.CreateRawTransactionCmd), nil); E.Chk(e) {
2265 }
2266 if r, ok := res.(string); ok {
2267 msg.Ch.(chan CreateRawTransactionRes) <-CreateRawTransactionRes{&r, e} }
2268 case msg := <-nrh["decoderawtransaction"].Call:
2269 if res, e = nrh["decoderawtransaction"].
2270 Fn(server, msg.Params.(*btcjson.DecodeRawTransactionCmd), nil); E.Chk(e) {
2271 }
2272 if r, ok := res.(btcjson.TxRawDecodeResult); ok {
2273 msg.Ch.(chan DecodeRawTransactionRes) <-DecodeRawTransactionRes{&r, e} }
2274 case msg := <-nrh["decodescript"].Call:
2275 if res, e = nrh["decodescript"].
2276 Fn(server, msg.Params.(*btcjson.DecodeScriptCmd), nil); E.Chk(e) {
2277 }
2278 if r, ok := res.(btcjson.DecodeScriptResult); ok {
2279 msg.Ch.(chan DecodeScriptRes) <-DecodeScriptRes{&r, e} }
2280 case msg := <-nrh["estimatefee"].Call:
2281 if res, e = nrh["estimatefee"].
2282 Fn(server, msg.Params.(*btcjson.EstimateFeeCmd), nil); E.Chk(e) {
2283 }
2284 if r, ok := res.(float64); ok {
2285 msg.Ch.(chan EstimateFeeRes) <-EstimateFeeRes{&r, e} }
2286 case msg := <-nrh["generate"].Call:
2287 if res, e = nrh["generate"].
2288 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2289 }
2290 if r, ok := res.([]string); ok {
2291 msg.Ch.(chan GenerateRes) <-GenerateRes{&r, e} }
2292 case msg := <-nrh["getaddednodeinfo"].Call:
2293 if res, e = nrh["getaddednodeinfo"].
2294 Fn(server, msg.Params.(*btcjson.GetAddedNodeInfoCmd), nil); E.Chk(e) {
2295 }
2296 if r, ok := res.([]btcjson.GetAddedNodeInfoResultAddr); ok {
2297 msg.Ch.(chan GetAddedNodeInfoRes) <-GetAddedNodeInfoRes{&r, e} }
2298 case msg := <-nrh["getbestblock"].Call:
2299 if res, e = nrh["getbestblock"].
2300 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2301 }
2302 if r, ok := res.(btcjson.GetBestBlockResult); ok {
2303 msg.Ch.(chan GetBestBlockRes) <-GetBestBlockRes{&r, e} }
2304 case msg := <-nrh["getbestblockhash"].Call:
2305 if res, e = nrh["getbestblockhash"].
2306 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2307 }
2308 if r, ok := res.(string); ok {
2309 msg.Ch.(chan GetBestBlockHashRes) <-GetBestBlockHashRes{&r, e} }
2310 case msg := <-nrh["getblock"].Call:
2311 if res, e = nrh["getblock"].
2312 Fn(server, msg.Params.(*btcjson.GetBlockCmd), nil); E.Chk(e) {
2313 }
2314 if r, ok := res.(btcjson.GetBlockVerboseResult); ok {
2315 msg.Ch.(chan GetBlockRes) <-GetBlockRes{&r, e} }
2316 case msg := <-nrh["getblockchaininfo"].Call:
2317 if res, e = nrh["getblockchaininfo"].
2318 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2319 }
2320 if r, ok := res.(btcjson.GetBlockChainInfoResult); ok {
2321 msg.Ch.(chan GetBlockChainInfoRes) <-GetBlockChainInfoRes{&r, e} }
2322 case msg := <-nrh["getblockcount"].Call:
2323 if res, e = nrh["getblockcount"].
2324 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2325 }
2326 if r, ok := res.(int64); ok {
2327 msg.Ch.(chan GetBlockCountRes) <-GetBlockCountRes{&r, e} }
2328 case msg := <-nrh["getblockhash"].Call:
2329 if res, e = nrh["getblockhash"].
2330 Fn(server, msg.Params.(*btcjson.GetBlockHashCmd), nil); E.Chk(e) {
2331 }
2332 if r, ok := res.(string); ok {
2333 msg.Ch.(chan GetBlockHashRes) <-GetBlockHashRes{&r, e} }
2334 case msg := <-nrh["getblockheader"].Call:
2335 if res, e = nrh["getblockheader"].
2336 Fn(server, msg.Params.(*btcjson.GetBlockHeaderCmd), nil); E.Chk(e) {
2337 }
2338 if r, ok := res.(btcjson.GetBlockHeaderVerboseResult); ok {
2339 msg.Ch.(chan GetBlockHeaderRes) <-GetBlockHeaderRes{&r, e} }
2340 case msg := <-nrh["getblocktemplate"].Call:
2341 if res, e = nrh["getblocktemplate"].
2342 Fn(server, msg.Params.(*btcjson.GetBlockTemplateCmd), nil); E.Chk(e) {
2343 }
2344 if r, ok := res.(string); ok {
2345 msg.Ch.(chan GetBlockTemplateRes) <-GetBlockTemplateRes{&r, e} }
2346 case msg := <-nrh["getcfilter"].Call:
2347 if res, e = nrh["getcfilter"].
2348 Fn(server, msg.Params.(*btcjson.GetCFilterCmd), nil); E.Chk(e) {
2349 }
2350 if r, ok := res.(string); ok {
2351 msg.Ch.(chan GetCFilterRes) <-GetCFilterRes{&r, e} }
2352 case msg := <-nrh["getcfilterheader"].Call:
2353 if res, e = nrh["getcfilterheader"].
2354 Fn(server, msg.Params.(*btcjson.GetCFilterHeaderCmd), nil); E.Chk(e) {
2355 }
2356 if r, ok := res.(string); ok {
2357 msg.Ch.(chan GetCFilterHeaderRes) <-GetCFilterHeaderRes{&r, e} }
2358 case msg := <-nrh["getconnectioncount"].Call:
2359 if res, e = nrh["getconnectioncount"].
2360 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2361 }
2362 if r, ok := res.(int32); ok {
2363 msg.Ch.(chan GetConnectionCountRes) <-GetConnectionCountRes{&r, e} }
2364 case msg := <-nrh["getcurrentnet"].Call:
2365 if res, e = nrh["getcurrentnet"].
2366 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2367 }
2368 if r, ok := res.(string); ok {
2369 msg.Ch.(chan GetCurrentNetRes) <-GetCurrentNetRes{&r, e} }
2370 case msg := <-nrh["getdifficulty"].Call:
2371 if res, e = nrh["getdifficulty"].
2372 Fn(server, msg.Params.(*btcjson.GetDifficultyCmd), nil); E.Chk(e) {
2373 }
2374 if r, ok := res.(float64); ok {
2375 msg.Ch.(chan GetDifficultyRes) <-GetDifficultyRes{&r, e} }
2376 case msg := <-nrh["getgenerate"].Call:
2377 if res, e = nrh["getgenerate"].
2378 Fn(server, msg.Params.(*btcjson.GetHeadersCmd), nil); E.Chk(e) {
2379 }
2380 if r, ok := res.(bool); ok {
2381 msg.Ch.(chan GetGenerateRes) <-GetGenerateRes{&r, e} }
2382 case msg := <-nrh["gethashespersec"].Call:
2383 if res, e = nrh["gethashespersec"].
2384 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2385 }
2386 if r, ok := res.(float64); ok {
2387 msg.Ch.(chan GetHashesPerSecRes) <-GetHashesPerSecRes{&r, e} }
2388 case msg := <-nrh["getheaders"].Call:
2389 if res, e = nrh["getheaders"].
2390 Fn(server, msg.Params.(*btcjson.GetHeadersCmd), nil); E.Chk(e) {
2391 }
2392 if r, ok := res.([]string); ok {
2393 msg.Ch.(chan GetHeadersRes) <-GetHeadersRes{&r, e} }
2394 case msg := <-nrh["getinfo"].Call:
2395 if res, e = nrh["getinfo"].
2396 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2397 }
2398 if r, ok := res.(btcjson.InfoChainResult0); ok {
2399 msg.Ch.(chan GetInfoRes) <-GetInfoRes{&r, e} }
2400 case msg := <-nrh["getmempoolinfo"].Call:
2401 if res, e = nrh["getmempoolinfo"].
2402 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2403 }
2404 if r, ok := res.(btcjson.GetMempoolInfoResult); ok {
2405 msg.Ch.(chan GetMempoolInfoRes) <-GetMempoolInfoRes{&r, e} }
2406 case msg := <-nrh["getmininginfo"].Call:
2407 if res, e = nrh["getmininginfo"].
2408 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2409 }
2410 if r, ok := res.(btcjson.GetMiningInfoResult); ok {
2411 msg.Ch.(chan GetMiningInfoRes) <-GetMiningInfoRes{&r, e} }
2412 case msg := <-nrh["getnettotals"].Call:
2413 if res, e = nrh["getnettotals"].
2414 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2415 }
2416 if r, ok := res.(btcjson.GetNetTotalsResult); ok {
2417 msg.Ch.(chan GetNetTotalsRes) <-GetNetTotalsRes{&r, e} }
2418 case msg := <-nrh["getnetworkhashps"].Call:
2419 if res, e = nrh["getnetworkhashps"].
2420 Fn(server, msg.Params.(*btcjson.GetNetworkHashPSCmd), nil); E.Chk(e) {
2421 }
2422 if r, ok := res.([]btcjson.GetPeerInfoResult); ok {
2423 msg.Ch.(chan GetNetworkHashPSRes) <-GetNetworkHashPSRes{&r, e} }
2424 case msg := <-nrh["getpeerinfo"].Call:
2425 if res, e = nrh["getpeerinfo"].
2426 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2427 }
2428 if r, ok := res.([]btcjson.GetPeerInfoResult); ok {
2429 msg.Ch.(chan GetPeerInfoRes) <-GetPeerInfoRes{&r, e} }
2430 case msg := <-nrh["getrawmempool"].Call:
2431 if res, e = nrh["getrawmempool"].
2432 Fn(server, msg.Params.(*btcjson.GetRawMempoolCmd), nil); E.Chk(e) {
2433 }
2434 if r, ok := res.([]string); ok {
2435 msg.Ch.(chan GetRawMempoolRes) <-GetRawMempoolRes{&r, e} }
2436 case msg := <-nrh["getrawtransaction"].Call:
2437 if res, e = nrh["getrawtransaction"].
2438 Fn(server, msg.Params.(*btcjson.GetRawTransactionCmd), nil); E.Chk(e) {
2439 }
2440 if r, ok := res.(string); ok {
2441 msg.Ch.(chan GetRawTransactionRes) <-GetRawTransactionRes{&r, e} }
2442 case msg := <-nrh["gettxout"].Call:
2443 if res, e = nrh["gettxout"].
2444 Fn(server, msg.Params.(*btcjson.GetTxOutCmd), nil); E.Chk(e) {
2445 }
2446 if r, ok := res.(string); ok {
2447 msg.Ch.(chan GetTxOutRes) <-GetTxOutRes{&r, e} }
2448 case msg := <-nrh["help"].Call:
2449 if res, e = nrh["help"].
2450 Fn(server, msg.Params.(*btcjson.HelpCmd), nil); E.Chk(e) {
2451 }
2452 if r, ok := res.(string); ok {
2453 msg.Ch.(chan HelpRes) <-HelpRes{&r, e} }
2454 case msg := <-nrh["node"].Call:
2455 if res, e = nrh["node"].
2456 Fn(server, msg.Params.(*btcjson.NodeCmd), nil); E.Chk(e) {
2457 }
2458 if r, ok := res.(None); ok {
2459 msg.Ch.(chan NodeRes) <-NodeRes{&r, e} }
2460 case msg := <-nrh["ping"].Call:
2461 if res, e = nrh["ping"].
2462 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2463 }
2464 if r, ok := res.(None); ok {
2465 msg.Ch.(chan PingRes) <-PingRes{&r, e} }
2466 case msg := <-nrh["resetchain"].Call:
2467 if res, e = nrh["resetchain"].
2468 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2469 }
2470 if r, ok := res.(None); ok {
2471 msg.Ch.(chan ResetChainRes) <-ResetChainRes{&r, e} }
2472 case msg := <-nrh["restart"].Call:
2473 if res, e = nrh["restart"].
2474 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2475 }
2476 if r, ok := res.(None); ok {
2477 msg.Ch.(chan RestartRes) <-RestartRes{&r, e} }
2478 case msg := <-nrh["searchrawtransactions"].Call:
2479 if res, e = nrh["searchrawtransactions"].
2480 Fn(server, msg.Params.(*btcjson.SearchRawTransactionsCmd), nil); E.Chk(e) {
2481 }
2482 if r, ok := res.([]btcjson.SearchRawTransactionsResult); ok {
2483 msg.Ch.(chan SearchRawTransactionsRes) <-SearchRawTransactionsRes{&r, e} }
2484 case msg := <-nrh["sendrawtransaction"].Call:
2485 if res, e = nrh["sendrawtransaction"].
2486 Fn(server, msg.Params.(*btcjson.SendRawTransactionCmd), nil); E.Chk(e) {
2487 }
2488 if r, ok := res.(None); ok {
2489 msg.Ch.(chan SendRawTransactionRes) <-SendRawTransactionRes{&r, e} }
2490 case msg := <-nrh["setgenerate"].Call:
2491 if res, e = nrh["setgenerate"].
2492 Fn(server, msg.Params.(*btcjson.SetGenerateCmd), nil); E.Chk(e) {
2493 }
2494 if r, ok := res.(None); ok {
2495 msg.Ch.(chan SetGenerateRes) <-SetGenerateRes{&r, e} }
2496 case msg := <-nrh["stop"].Call:
2497 if res, e = nrh["stop"].
2498 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2499 }
2500 if r, ok := res.(None); ok {
2501 msg.Ch.(chan StopRes) <-StopRes{&r, e} }
2502 case msg := <-nrh["submitblock"].Call:
2503 if res, e = nrh["submitblock"].
2504 Fn(server, msg.Params.(*btcjson.SubmitBlockCmd), nil); E.Chk(e) {
2505 }
2506 if r, ok := res.(string); ok {
2507 msg.Ch.(chan SubmitBlockRes) <-SubmitBlockRes{&r, e} }
2508 case msg := <-nrh["uptime"].Call:
2509 if res, e = nrh["uptime"].
2510 Fn(server, msg.Params.(*None), nil); E.Chk(e) {
2511 }
2512 if r, ok := res.(btcjson.GetMempoolInfoResult); ok {
2513 msg.Ch.(chan UptimeRes) <-UptimeRes{&r, e} }
2514 case msg := <-nrh["validateaddress"].Call:
2515 if res, e = nrh["validateaddress"].
2516 Fn(server, msg.Params.(*btcjson.ValidateAddressCmd), nil); E.Chk(e) {
2517 }
2518 if r, ok := res.(btcjson.ValidateAddressChainResult); ok {
2519 msg.Ch.(chan ValidateAddressRes) <-ValidateAddressRes{&r, e} }
2520 case msg := <-nrh["verifychain"].Call:
2521 if res, e = nrh["verifychain"].
2522 Fn(server, msg.Params.(*btcjson.VerifyChainCmd), nil); E.Chk(e) {
2523 }
2524 if r, ok := res.(bool); ok {
2525 msg.Ch.(chan VerifyChainRes) <-VerifyChainRes{&r, e} }
2526 case msg := <-nrh["verifymessage"].Call:
2527 if res, e = nrh["verifymessage"].
2528 Fn(server, msg.Params.(*btcjson.VerifyMessageCmd), nil); E.Chk(e) {
2529 }
2530 if r, ok := res.(bool); ok {
2531 msg.Ch.(chan VerifyMessageRes) <-VerifyMessageRes{&r, e} }
2532 case msg := <-nrh["version"].Call:
2533 if res, e = nrh["version"].
2534 Fn(server, msg.Params.(*btcjson.VersionCmd), nil); E.Chk(e) {
2535 }
2536 if r, ok := res.(map[string]btcjson.VersionResult); ok {
2537 msg.Ch.(chan VersionRes) <-VersionRes{&r, e} }
2538 case <-quit.Wait():
2539 D.Ln("stopping wallet cAPI")
2540 return
2541 }
2542 }
2543 }()
2544 }
2545 2546 // RPC API functions to use with net/rpc
2547 2548 func (c *CAPI) AddNode(req *btcjson.AddNodeCmd, resp None) (e error) {
2549 nrh := RPCHandlers
2550 res := nrh["addnode"].Result()
2551 res.Params = req
2552 nrh["addnode"].Call <- res
2553 select {
2554 case resp = <-res.Ch.(chan None):
2555 case <-time.After(c.Timeout):
2556 case <-c.quit.Wait():
2557 }
2558 return
2559 }
2560 2561 func (c *CAPI) CreateRawTransaction(req *btcjson.CreateRawTransactionCmd, resp string) (e error) {
2562 nrh := RPCHandlers
2563 res := nrh["createrawtransaction"].Result()
2564 res.Params = req
2565 nrh["createrawtransaction"].Call <- res
2566 select {
2567 case resp = <-res.Ch.(chan string):
2568 case <-time.After(c.Timeout):
2569 case <-c.quit.Wait():
2570 }
2571 return
2572 }
2573 2574 func (c *CAPI) DecodeRawTransaction(req *btcjson.DecodeRawTransactionCmd, resp btcjson.TxRawDecodeResult) (e error) {
2575 nrh := RPCHandlers
2576 res := nrh["decoderawtransaction"].Result()
2577 res.Params = req
2578 nrh["decoderawtransaction"].Call <- res
2579 select {
2580 case resp = <-res.Ch.(chan btcjson.TxRawDecodeResult):
2581 case <-time.After(c.Timeout):
2582 case <-c.quit.Wait():
2583 }
2584 return
2585 }
2586 2587 func (c *CAPI) DecodeScript(req *btcjson.DecodeScriptCmd, resp btcjson.DecodeScriptResult) (e error) {
2588 nrh := RPCHandlers
2589 res := nrh["decodescript"].Result()
2590 res.Params = req
2591 nrh["decodescript"].Call <- res
2592 select {
2593 case resp = <-res.Ch.(chan btcjson.DecodeScriptResult):
2594 case <-time.After(c.Timeout):
2595 case <-c.quit.Wait():
2596 }
2597 return
2598 }
2599 2600 func (c *CAPI) EstimateFee(req *btcjson.EstimateFeeCmd, resp float64) (e error) {
2601 nrh := RPCHandlers
2602 res := nrh["estimatefee"].Result()
2603 res.Params = req
2604 nrh["estimatefee"].Call <- res
2605 select {
2606 case resp = <-res.Ch.(chan float64):
2607 case <-time.After(c.Timeout):
2608 case <-c.quit.Wait():
2609 }
2610 return
2611 }
2612 2613 func (c *CAPI) Generate(req *None, resp []string) (e error) {
2614 nrh := RPCHandlers
2615 res := nrh["generate"].Result()
2616 res.Params = req
2617 nrh["generate"].Call <- res
2618 select {
2619 case resp = <-res.Ch.(chan []string):
2620 case <-time.After(c.Timeout):
2621 case <-c.quit.Wait():
2622 }
2623 return
2624 }
2625 2626 func (c *CAPI) GetAddedNodeInfo(req *btcjson.GetAddedNodeInfoCmd, resp []btcjson.GetAddedNodeInfoResultAddr) (e error) {
2627 nrh := RPCHandlers
2628 res := nrh["getaddednodeinfo"].Result()
2629 res.Params = req
2630 nrh["getaddednodeinfo"].Call <- res
2631 select {
2632 case resp = <-res.Ch.(chan []btcjson.GetAddedNodeInfoResultAddr):
2633 case <-time.After(c.Timeout):
2634 case <-c.quit.Wait():
2635 }
2636 return
2637 }
2638 2639 func (c *CAPI) GetBestBlock(req *None, resp btcjson.GetBestBlockResult) (e error) {
2640 nrh := RPCHandlers
2641 res := nrh["getbestblock"].Result()
2642 res.Params = req
2643 nrh["getbestblock"].Call <- res
2644 select {
2645 case resp = <-res.Ch.(chan btcjson.GetBestBlockResult):
2646 case <-time.After(c.Timeout):
2647 case <-c.quit.Wait():
2648 }
2649 return
2650 }
2651 2652 func (c *CAPI) GetBestBlockHash(req *None, resp string) (e error) {
2653 nrh := RPCHandlers
2654 res := nrh["getbestblockhash"].Result()
2655 res.Params = req
2656 nrh["getbestblockhash"].Call <- res
2657 select {
2658 case resp = <-res.Ch.(chan string):
2659 case <-time.After(c.Timeout):
2660 case <-c.quit.Wait():
2661 }
2662 return
2663 }
2664 2665 func (c *CAPI) GetBlock(req *btcjson.GetBlockCmd, resp btcjson.GetBlockVerboseResult) (e error) {
2666 nrh := RPCHandlers
2667 res := nrh["getblock"].Result()
2668 res.Params = req
2669 nrh["getblock"].Call <- res
2670 select {
2671 case resp = <-res.Ch.(chan btcjson.GetBlockVerboseResult):
2672 case <-time.After(c.Timeout):
2673 case <-c.quit.Wait():
2674 }
2675 return
2676 }
2677 2678 func (c *CAPI) GetBlockChainInfo(req *None, resp btcjson.GetBlockChainInfoResult) (e error) {
2679 nrh := RPCHandlers
2680 res := nrh["getblockchaininfo"].Result()
2681 res.Params = req
2682 nrh["getblockchaininfo"].Call <- res
2683 select {
2684 case resp = <-res.Ch.(chan btcjson.GetBlockChainInfoResult):
2685 case <-time.After(c.Timeout):
2686 case <-c.quit.Wait():
2687 }
2688 return
2689 }
2690 2691 func (c *CAPI) GetBlockCount(req *None, resp int64) (e error) {
2692 nrh := RPCHandlers
2693 res := nrh["getblockcount"].Result()
2694 res.Params = req
2695 nrh["getblockcount"].Call <- res
2696 select {
2697 case resp = <-res.Ch.(chan int64):
2698 case <-time.After(c.Timeout):
2699 case <-c.quit.Wait():
2700 }
2701 return
2702 }
2703 2704 func (c *CAPI) GetBlockHash(req *btcjson.GetBlockHashCmd, resp string) (e error) {
2705 nrh := RPCHandlers
2706 res := nrh["getblockhash"].Result()
2707 res.Params = req
2708 nrh["getblockhash"].Call <- res
2709 select {
2710 case resp = <-res.Ch.(chan string):
2711 case <-time.After(c.Timeout):
2712 case <-c.quit.Wait():
2713 }
2714 return
2715 }
2716 2717 func (c *CAPI) GetBlockHeader(req *btcjson.GetBlockHeaderCmd, resp btcjson.GetBlockHeaderVerboseResult) (e error) {
2718 nrh := RPCHandlers
2719 res := nrh["getblockheader"].Result()
2720 res.Params = req
2721 nrh["getblockheader"].Call <- res
2722 select {
2723 case resp = <-res.Ch.(chan btcjson.GetBlockHeaderVerboseResult):
2724 case <-time.After(c.Timeout):
2725 case <-c.quit.Wait():
2726 }
2727 return
2728 }
2729 2730 func (c *CAPI) GetBlockTemplate(req *btcjson.GetBlockTemplateCmd, resp string) (e error) {
2731 nrh := RPCHandlers
2732 res := nrh["getblocktemplate"].Result()
2733 res.Params = req
2734 nrh["getblocktemplate"].Call <- res
2735 select {
2736 case resp = <-res.Ch.(chan string):
2737 case <-time.After(c.Timeout):
2738 case <-c.quit.Wait():
2739 }
2740 return
2741 }
2742 2743 func (c *CAPI) GetCFilter(req *btcjson.GetCFilterCmd, resp string) (e error) {
2744 nrh := RPCHandlers
2745 res := nrh["getcfilter"].Result()
2746 res.Params = req
2747 nrh["getcfilter"].Call <- res
2748 select {
2749 case resp = <-res.Ch.(chan string):
2750 case <-time.After(c.Timeout):
2751 case <-c.quit.Wait():
2752 }
2753 return
2754 }
2755 2756 func (c *CAPI) GetCFilterHeader(req *btcjson.GetCFilterHeaderCmd, resp string) (e error) {
2757 nrh := RPCHandlers
2758 res := nrh["getcfilterheader"].Result()
2759 res.Params = req
2760 nrh["getcfilterheader"].Call <- res
2761 select {
2762 case resp = <-res.Ch.(chan string):
2763 case <-time.After(c.Timeout):
2764 case <-c.quit.Wait():
2765 }
2766 return
2767 }
2768 2769 func (c *CAPI) GetConnectionCount(req *None, resp int32) (e error) {
2770 nrh := RPCHandlers
2771 res := nrh["getconnectioncount"].Result()
2772 res.Params = req
2773 nrh["getconnectioncount"].Call <- res
2774 select {
2775 case resp = <-res.Ch.(chan int32):
2776 case <-time.After(c.Timeout):
2777 case <-c.quit.Wait():
2778 }
2779 return
2780 }
2781 2782 func (c *CAPI) GetCurrentNet(req *None, resp string) (e error) {
2783 nrh := RPCHandlers
2784 res := nrh["getcurrentnet"].Result()
2785 res.Params = req
2786 nrh["getcurrentnet"].Call <- res
2787 select {
2788 case resp = <-res.Ch.(chan string):
2789 case <-time.After(c.Timeout):
2790 case <-c.quit.Wait():
2791 }
2792 return
2793 }
2794 2795 func (c *CAPI) GetDifficulty(req *btcjson.GetDifficultyCmd, resp float64) (e error) {
2796 nrh := RPCHandlers
2797 res := nrh["getdifficulty"].Result()
2798 res.Params = req
2799 nrh["getdifficulty"].Call <- res
2800 select {
2801 case resp = <-res.Ch.(chan float64):
2802 case <-time.After(c.Timeout):
2803 case <-c.quit.Wait():
2804 }
2805 return
2806 }
2807 2808 func (c *CAPI) GetGenerate(req *btcjson.GetHeadersCmd, resp bool) (e error) {
2809 nrh := RPCHandlers
2810 res := nrh["getgenerate"].Result()
2811 res.Params = req
2812 nrh["getgenerate"].Call <- res
2813 select {
2814 case resp = <-res.Ch.(chan bool):
2815 case <-time.After(c.Timeout):
2816 case <-c.quit.Wait():
2817 }
2818 return
2819 }
2820 2821 func (c *CAPI) GetHashesPerSec(req *None, resp float64) (e error) {
2822 nrh := RPCHandlers
2823 res := nrh["gethashespersec"].Result()
2824 res.Params = req
2825 nrh["gethashespersec"].Call <- res
2826 select {
2827 case resp = <-res.Ch.(chan float64):
2828 case <-time.After(c.Timeout):
2829 case <-c.quit.Wait():
2830 }
2831 return
2832 }
2833 2834 func (c *CAPI) GetHeaders(req *btcjson.GetHeadersCmd, resp []string) (e error) {
2835 nrh := RPCHandlers
2836 res := nrh["getheaders"].Result()
2837 res.Params = req
2838 nrh["getheaders"].Call <- res
2839 select {
2840 case resp = <-res.Ch.(chan []string):
2841 case <-time.After(c.Timeout):
2842 case <-c.quit.Wait():
2843 }
2844 return
2845 }
2846 2847 func (c *CAPI) GetInfo(req *None, resp btcjson.InfoChainResult0) (e error) {
2848 nrh := RPCHandlers
2849 res := nrh["getinfo"].Result()
2850 res.Params = req
2851 nrh["getinfo"].Call <- res
2852 select {
2853 case resp = <-res.Ch.(chan btcjson.InfoChainResult0):
2854 case <-time.After(c.Timeout):
2855 case <-c.quit.Wait():
2856 }
2857 return
2858 }
2859 2860 func (c *CAPI) GetMempoolInfo(req *None, resp btcjson.GetMempoolInfoResult) (e error) {
2861 nrh := RPCHandlers
2862 res := nrh["getmempoolinfo"].Result()
2863 res.Params = req
2864 nrh["getmempoolinfo"].Call <- res
2865 select {
2866 case resp = <-res.Ch.(chan btcjson.GetMempoolInfoResult):
2867 case <-time.After(c.Timeout):
2868 case <-c.quit.Wait():
2869 }
2870 return
2871 }
2872 2873 func (c *CAPI) GetMiningInfo(req *None, resp btcjson.GetMiningInfoResult) (e error) {
2874 nrh := RPCHandlers
2875 res := nrh["getmininginfo"].Result()
2876 res.Params = req
2877 nrh["getmininginfo"].Call <- res
2878 select {
2879 case resp = <-res.Ch.(chan btcjson.GetMiningInfoResult):
2880 case <-time.After(c.Timeout):
2881 case <-c.quit.Wait():
2882 }
2883 return
2884 }
2885 2886 func (c *CAPI) GetNetTotals(req *None, resp btcjson.GetNetTotalsResult) (e error) {
2887 nrh := RPCHandlers
2888 res := nrh["getnettotals"].Result()
2889 res.Params = req
2890 nrh["getnettotals"].Call <- res
2891 select {
2892 case resp = <-res.Ch.(chan btcjson.GetNetTotalsResult):
2893 case <-time.After(c.Timeout):
2894 case <-c.quit.Wait():
2895 }
2896 return
2897 }
2898 2899 func (c *CAPI) GetNetworkHashPS(req *btcjson.GetNetworkHashPSCmd, resp []btcjson.GetPeerInfoResult) (e error) {
2900 nrh := RPCHandlers
2901 res := nrh["getnetworkhashps"].Result()
2902 res.Params = req
2903 nrh["getnetworkhashps"].Call <- res
2904 select {
2905 case resp = <-res.Ch.(chan []btcjson.GetPeerInfoResult):
2906 case <-time.After(c.Timeout):
2907 case <-c.quit.Wait():
2908 }
2909 return
2910 }
2911 2912 func (c *CAPI) GetPeerInfo(req *None, resp []btcjson.GetPeerInfoResult) (e error) {
2913 nrh := RPCHandlers
2914 res := nrh["getpeerinfo"].Result()
2915 res.Params = req
2916 nrh["getpeerinfo"].Call <- res
2917 select {
2918 case resp = <-res.Ch.(chan []btcjson.GetPeerInfoResult):
2919 case <-time.After(c.Timeout):
2920 case <-c.quit.Wait():
2921 }
2922 return
2923 }
2924 2925 func (c *CAPI) GetRawMempool(req *btcjson.GetRawMempoolCmd, resp []string) (e error) {
2926 nrh := RPCHandlers
2927 res := nrh["getrawmempool"].Result()
2928 res.Params = req
2929 nrh["getrawmempool"].Call <- res
2930 select {
2931 case resp = <-res.Ch.(chan []string):
2932 case <-time.After(c.Timeout):
2933 case <-c.quit.Wait():
2934 }
2935 return
2936 }
2937 2938 func (c *CAPI) GetRawTransaction(req *btcjson.GetRawTransactionCmd, resp string) (e error) {
2939 nrh := RPCHandlers
2940 res := nrh["getrawtransaction"].Result()
2941 res.Params = req
2942 nrh["getrawtransaction"].Call <- res
2943 select {
2944 case resp = <-res.Ch.(chan string):
2945 case <-time.After(c.Timeout):
2946 case <-c.quit.Wait():
2947 }
2948 return
2949 }
2950 2951 func (c *CAPI) GetTxOut(req *btcjson.GetTxOutCmd, resp string) (e error) {
2952 nrh := RPCHandlers
2953 res := nrh["gettxout"].Result()
2954 res.Params = req
2955 nrh["gettxout"].Call <- res
2956 select {
2957 case resp = <-res.Ch.(chan string):
2958 case <-time.After(c.Timeout):
2959 case <-c.quit.Wait():
2960 }
2961 return
2962 }
2963 2964 func (c *CAPI) Help(req *btcjson.HelpCmd, resp string) (e error) {
2965 nrh := RPCHandlers
2966 res := nrh["help"].Result()
2967 res.Params = req
2968 nrh["help"].Call <- res
2969 select {
2970 case resp = <-res.Ch.(chan string):
2971 case <-time.After(c.Timeout):
2972 case <-c.quit.Wait():
2973 }
2974 return
2975 }
2976 2977 func (c *CAPI) Node(req *btcjson.NodeCmd, resp None) (e error) {
2978 nrh := RPCHandlers
2979 res := nrh["node"].Result()
2980 res.Params = req
2981 nrh["node"].Call <- res
2982 select {
2983 case resp = <-res.Ch.(chan None):
2984 case <-time.After(c.Timeout):
2985 case <-c.quit.Wait():
2986 }
2987 return
2988 }
2989 2990 func (c *CAPI) Ping(req *None, resp None) (e error) {
2991 nrh := RPCHandlers
2992 res := nrh["ping"].Result()
2993 res.Params = req
2994 nrh["ping"].Call <- res
2995 select {
2996 case resp = <-res.Ch.(chan None):
2997 case <-time.After(c.Timeout):
2998 case <-c.quit.Wait():
2999 }
3000 return
3001 }
3002 3003 func (c *CAPI) ResetChain(req *None, resp None) (e error) {
3004 nrh := RPCHandlers
3005 res := nrh["resetchain"].Result()
3006 res.Params = req
3007 nrh["resetchain"].Call <- res
3008 select {
3009 case resp = <-res.Ch.(chan None):
3010 case <-time.After(c.Timeout):
3011 case <-c.quit.Wait():
3012 }
3013 return
3014 }
3015 3016 func (c *CAPI) Restart(req *None, resp None) (e error) {
3017 nrh := RPCHandlers
3018 res := nrh["restart"].Result()
3019 res.Params = req
3020 nrh["restart"].Call <- res
3021 select {
3022 case resp = <-res.Ch.(chan None):
3023 case <-time.After(c.Timeout):
3024 case <-c.quit.Wait():
3025 }
3026 return
3027 }
3028 3029 func (c *CAPI) SearchRawTransactions(req *btcjson.SearchRawTransactionsCmd, resp []btcjson.SearchRawTransactionsResult) (e error) {
3030 nrh := RPCHandlers
3031 res := nrh["searchrawtransactions"].Result()
3032 res.Params = req
3033 nrh["searchrawtransactions"].Call <- res
3034 select {
3035 case resp = <-res.Ch.(chan []btcjson.SearchRawTransactionsResult):
3036 case <-time.After(c.Timeout):
3037 case <-c.quit.Wait():
3038 }
3039 return
3040 }
3041 3042 func (c *CAPI) SendRawTransaction(req *btcjson.SendRawTransactionCmd, resp None) (e error) {
3043 nrh := RPCHandlers
3044 res := nrh["sendrawtransaction"].Result()
3045 res.Params = req
3046 nrh["sendrawtransaction"].Call <- res
3047 select {
3048 case resp = <-res.Ch.(chan None):
3049 case <-time.After(c.Timeout):
3050 case <-c.quit.Wait():
3051 }
3052 return
3053 }
3054 3055 func (c *CAPI) SetGenerate(req *btcjson.SetGenerateCmd, resp None) (e error) {
3056 nrh := RPCHandlers
3057 res := nrh["setgenerate"].Result()
3058 res.Params = req
3059 nrh["setgenerate"].Call <- res
3060 select {
3061 case resp = <-res.Ch.(chan None):
3062 case <-time.After(c.Timeout):
3063 case <-c.quit.Wait():
3064 }
3065 return
3066 }
3067 3068 func (c *CAPI) Stop(req *None, resp None) (e error) {
3069 nrh := RPCHandlers
3070 res := nrh["stop"].Result()
3071 res.Params = req
3072 nrh["stop"].Call <- res
3073 select {
3074 case resp = <-res.Ch.(chan None):
3075 case <-time.After(c.Timeout):
3076 case <-c.quit.Wait():
3077 }
3078 return
3079 }
3080 3081 func (c *CAPI) SubmitBlock(req *btcjson.SubmitBlockCmd, resp string) (e error) {
3082 nrh := RPCHandlers
3083 res := nrh["submitblock"].Result()
3084 res.Params = req
3085 nrh["submitblock"].Call <- res
3086 select {
3087 case resp = <-res.Ch.(chan string):
3088 case <-time.After(c.Timeout):
3089 case <-c.quit.Wait():
3090 }
3091 return
3092 }
3093 3094 func (c *CAPI) Uptime(req *None, resp btcjson.GetMempoolInfoResult) (e error) {
3095 nrh := RPCHandlers
3096 res := nrh["uptime"].Result()
3097 res.Params = req
3098 nrh["uptime"].Call <- res
3099 select {
3100 case resp = <-res.Ch.(chan btcjson.GetMempoolInfoResult):
3101 case <-time.After(c.Timeout):
3102 case <-c.quit.Wait():
3103 }
3104 return
3105 }
3106 3107 func (c *CAPI) ValidateAddress(req *btcjson.ValidateAddressCmd, resp btcjson.ValidateAddressChainResult) (e error) {
3108 nrh := RPCHandlers
3109 res := nrh["validateaddress"].Result()
3110 res.Params = req
3111 nrh["validateaddress"].Call <- res
3112 select {
3113 case resp = <-res.Ch.(chan btcjson.ValidateAddressChainResult):
3114 case <-time.After(c.Timeout):
3115 case <-c.quit.Wait():
3116 }
3117 return
3118 }
3119 3120 func (c *CAPI) VerifyChain(req *btcjson.VerifyChainCmd, resp bool) (e error) {
3121 nrh := RPCHandlers
3122 res := nrh["verifychain"].Result()
3123 res.Params = req
3124 nrh["verifychain"].Call <- res
3125 select {
3126 case resp = <-res.Ch.(chan bool):
3127 case <-time.After(c.Timeout):
3128 case <-c.quit.Wait():
3129 }
3130 return
3131 }
3132 3133 func (c *CAPI) VerifyMessage(req *btcjson.VerifyMessageCmd, resp bool) (e error) {
3134 nrh := RPCHandlers
3135 res := nrh["verifymessage"].Result()
3136 res.Params = req
3137 nrh["verifymessage"].Call <- res
3138 select {
3139 case resp = <-res.Ch.(chan bool):
3140 case <-time.After(c.Timeout):
3141 case <-c.quit.Wait():
3142 }
3143 return
3144 }
3145 3146 func (c *CAPI) Version(req *btcjson.VersionCmd, resp map[string]btcjson.VersionResult) (e error) {
3147 nrh := RPCHandlers
3148 res := nrh["version"].Result()
3149 res.Params = req
3150 nrh["version"].Call <- res
3151 select {
3152 case resp = <-res.Ch.(chan map[string]btcjson.VersionResult):
3153 case <-time.After(c.Timeout):
3154 case <-c.quit.Wait():
3155 }
3156 return
3157 }
3158 3159 // Client call wrappers for a CAPI client with a given Conn
3160 3161 func (r *CAPIClient) AddNode(cmd ...*btcjson.AddNodeCmd) (res None, e error) {
3162 var c *btcjson.AddNodeCmd
3163 if len(cmd) > 0 {
3164 c = cmd[0]
3165 }
3166 if e = r.Call("CAPI.AddNode", c, &res); E.Chk(e) {
3167 }
3168 return
3169 }
3170 3171 func (r *CAPIClient) CreateRawTransaction(cmd ...*btcjson.CreateRawTransactionCmd) (res string, e error) {
3172 var c *btcjson.CreateRawTransactionCmd
3173 if len(cmd) > 0 {
3174 c = cmd[0]
3175 }
3176 if e = r.Call("CAPI.CreateRawTransaction", c, &res); E.Chk(e) {
3177 }
3178 return
3179 }
3180 3181 func (r *CAPIClient) DecodeRawTransaction(cmd ...*btcjson.DecodeRawTransactionCmd) (res btcjson.TxRawDecodeResult, e error) {
3182 var c *btcjson.DecodeRawTransactionCmd
3183 if len(cmd) > 0 {
3184 c = cmd[0]
3185 }
3186 if e = r.Call("CAPI.DecodeRawTransaction", c, &res); E.Chk(e) {
3187 }
3188 return
3189 }
3190 3191 func (r *CAPIClient) DecodeScript(cmd ...*btcjson.DecodeScriptCmd) (res btcjson.DecodeScriptResult, e error) {
3192 var c *btcjson.DecodeScriptCmd
3193 if len(cmd) > 0 {
3194 c = cmd[0]
3195 }
3196 if e = r.Call("CAPI.DecodeScript", c, &res); E.Chk(e) {
3197 }
3198 return
3199 }
3200 3201 func (r *CAPIClient) EstimateFee(cmd ...*btcjson.EstimateFeeCmd) (res float64, e error) {
3202 var c *btcjson.EstimateFeeCmd
3203 if len(cmd) > 0 {
3204 c = cmd[0]
3205 }
3206 if e = r.Call("CAPI.EstimateFee", c, &res); E.Chk(e) {
3207 }
3208 return
3209 }
3210 3211 func (r *CAPIClient) Generate(cmd ...*None) (res []string, e error) {
3212 var c *None
3213 if len(cmd) > 0 {
3214 c = cmd[0]
3215 }
3216 if e = r.Call("CAPI.Generate", c, &res); E.Chk(e) {
3217 }
3218 return
3219 }
3220 3221 func (r *CAPIClient) GetAddedNodeInfo(cmd ...*btcjson.GetAddedNodeInfoCmd) (res []btcjson.GetAddedNodeInfoResultAddr, e error) {
3222 var c *btcjson.GetAddedNodeInfoCmd
3223 if len(cmd) > 0 {
3224 c = cmd[0]
3225 }
3226 if e = r.Call("CAPI.GetAddedNodeInfo", c, &res); E.Chk(e) {
3227 }
3228 return
3229 }
3230 3231 func (r *CAPIClient) GetBestBlock(cmd ...*None) (res btcjson.GetBestBlockResult, e error) {
3232 var c *None
3233 if len(cmd) > 0 {
3234 c = cmd[0]
3235 }
3236 if e = r.Call("CAPI.GetBestBlock", c, &res); E.Chk(e) {
3237 }
3238 return
3239 }
3240 3241 func (r *CAPIClient) GetBestBlockHash(cmd ...*None) (res string, e error) {
3242 var c *None
3243 if len(cmd) > 0 {
3244 c = cmd[0]
3245 }
3246 if e = r.Call("CAPI.GetBestBlockHash", c, &res); E.Chk(e) {
3247 }
3248 return
3249 }
3250 3251 func (r *CAPIClient) GetBlock(cmd ...*btcjson.GetBlockCmd) (res btcjson.GetBlockVerboseResult, e error) {
3252 var c *btcjson.GetBlockCmd
3253 if len(cmd) > 0 {
3254 c = cmd[0]
3255 }
3256 if e = r.Call("CAPI.GetBlock", c, &res); E.Chk(e) {
3257 }
3258 return
3259 }
3260 3261 func (r *CAPIClient) GetBlockChainInfo(cmd ...*None) (res btcjson.GetBlockChainInfoResult, e error) {
3262 var c *None
3263 if len(cmd) > 0 {
3264 c = cmd[0]
3265 }
3266 if e = r.Call("CAPI.GetBlockChainInfo", c, &res); E.Chk(e) {
3267 }
3268 return
3269 }
3270 3271 func (r *CAPIClient) GetBlockCount(cmd ...*None) (res int64, e error) {
3272 var c *None
3273 if len(cmd) > 0 {
3274 c = cmd[0]
3275 }
3276 if e = r.Call("CAPI.GetBlockCount", c, &res); E.Chk(e) {
3277 }
3278 return
3279 }
3280 3281 func (r *CAPIClient) GetBlockHash(cmd ...*btcjson.GetBlockHashCmd) (res string, e error) {
3282 var c *btcjson.GetBlockHashCmd
3283 if len(cmd) > 0 {
3284 c = cmd[0]
3285 }
3286 if e = r.Call("CAPI.GetBlockHash", c, &res); E.Chk(e) {
3287 }
3288 return
3289 }
3290 3291 func (r *CAPIClient) GetBlockHeader(cmd ...*btcjson.GetBlockHeaderCmd) (res btcjson.GetBlockHeaderVerboseResult, e error) {
3292 var c *btcjson.GetBlockHeaderCmd
3293 if len(cmd) > 0 {
3294 c = cmd[0]
3295 }
3296 if e = r.Call("CAPI.GetBlockHeader", c, &res); E.Chk(e) {
3297 }
3298 return
3299 }
3300 3301 func (r *CAPIClient) GetBlockTemplate(cmd ...*btcjson.GetBlockTemplateCmd) (res string, e error) {
3302 var c *btcjson.GetBlockTemplateCmd
3303 if len(cmd) > 0 {
3304 c = cmd[0]
3305 }
3306 if e = r.Call("CAPI.GetBlockTemplate", c, &res); E.Chk(e) {
3307 }
3308 return
3309 }
3310 3311 func (r *CAPIClient) GetCFilter(cmd ...*btcjson.GetCFilterCmd) (res string, e error) {
3312 var c *btcjson.GetCFilterCmd
3313 if len(cmd) > 0 {
3314 c = cmd[0]
3315 }
3316 if e = r.Call("CAPI.GetCFilter", c, &res); E.Chk(e) {
3317 }
3318 return
3319 }
3320 3321 func (r *CAPIClient) GetCFilterHeader(cmd ...*btcjson.GetCFilterHeaderCmd) (res string, e error) {
3322 var c *btcjson.GetCFilterHeaderCmd
3323 if len(cmd) > 0 {
3324 c = cmd[0]
3325 }
3326 if e = r.Call("CAPI.GetCFilterHeader", c, &res); E.Chk(e) {
3327 }
3328 return
3329 }
3330 3331 func (r *CAPIClient) GetConnectionCount(cmd ...*None) (res int32, e error) {
3332 var c *None
3333 if len(cmd) > 0 {
3334 c = cmd[0]
3335 }
3336 if e = r.Call("CAPI.GetConnectionCount", c, &res); E.Chk(e) {
3337 }
3338 return
3339 }
3340 3341 func (r *CAPIClient) GetCurrentNet(cmd ...*None) (res string, e error) {
3342 var c *None
3343 if len(cmd) > 0 {
3344 c = cmd[0]
3345 }
3346 if e = r.Call("CAPI.GetCurrentNet", c, &res); E.Chk(e) {
3347 }
3348 return
3349 }
3350 3351 func (r *CAPIClient) GetDifficulty(cmd ...*btcjson.GetDifficultyCmd) (res float64, e error) {
3352 var c *btcjson.GetDifficultyCmd
3353 if len(cmd) > 0 {
3354 c = cmd[0]
3355 }
3356 if e = r.Call("CAPI.GetDifficulty", c, &res); E.Chk(e) {
3357 }
3358 return
3359 }
3360 3361 func (r *CAPIClient) GetGenerate(cmd ...*btcjson.GetHeadersCmd) (res bool, e error) {
3362 var c *btcjson.GetHeadersCmd
3363 if len(cmd) > 0 {
3364 c = cmd[0]
3365 }
3366 if e = r.Call("CAPI.GetGenerate", c, &res); E.Chk(e) {
3367 }
3368 return
3369 }
3370 3371 func (r *CAPIClient) GetHashesPerSec(cmd ...*None) (res float64, e error) {
3372 var c *None
3373 if len(cmd) > 0 {
3374 c = cmd[0]
3375 }
3376 if e = r.Call("CAPI.GetHashesPerSec", c, &res); E.Chk(e) {
3377 }
3378 return
3379 }
3380 3381 func (r *CAPIClient) GetHeaders(cmd ...*btcjson.GetHeadersCmd) (res []string, e error) {
3382 var c *btcjson.GetHeadersCmd
3383 if len(cmd) > 0 {
3384 c = cmd[0]
3385 }
3386 if e = r.Call("CAPI.GetHeaders", c, &res); E.Chk(e) {
3387 }
3388 return
3389 }
3390 3391 func (r *CAPIClient) GetInfo(cmd ...*None) (res btcjson.InfoChainResult0, e error) {
3392 var c *None
3393 if len(cmd) > 0 {
3394 c = cmd[0]
3395 }
3396 if e = r.Call("CAPI.GetInfo", c, &res); E.Chk(e) {
3397 }
3398 return
3399 }
3400 3401 func (r *CAPIClient) GetMempoolInfo(cmd ...*None) (res btcjson.GetMempoolInfoResult, e error) {
3402 var c *None
3403 if len(cmd) > 0 {
3404 c = cmd[0]
3405 }
3406 if e = r.Call("CAPI.GetMempoolInfo", c, &res); E.Chk(e) {
3407 }
3408 return
3409 }
3410 3411 func (r *CAPIClient) GetMiningInfo(cmd ...*None) (res btcjson.GetMiningInfoResult, e error) {
3412 var c *None
3413 if len(cmd) > 0 {
3414 c = cmd[0]
3415 }
3416 if e = r.Call("CAPI.GetMiningInfo", c, &res); E.Chk(e) {
3417 }
3418 return
3419 }
3420 3421 func (r *CAPIClient) GetNetTotals(cmd ...*None) (res btcjson.GetNetTotalsResult, e error) {
3422 var c *None
3423 if len(cmd) > 0 {
3424 c = cmd[0]
3425 }
3426 if e = r.Call("CAPI.GetNetTotals", c, &res); E.Chk(e) {
3427 }
3428 return
3429 }
3430 3431 func (r *CAPIClient) GetNetworkHashPS(cmd ...*btcjson.GetNetworkHashPSCmd) (res []btcjson.GetPeerInfoResult, e error) {
3432 var c *btcjson.GetNetworkHashPSCmd
3433 if len(cmd) > 0 {
3434 c = cmd[0]
3435 }
3436 if e = r.Call("CAPI.GetNetworkHashPS", c, &res); E.Chk(e) {
3437 }
3438 return
3439 }
3440 3441 func (r *CAPIClient) GetPeerInfo(cmd ...*None) (res []btcjson.GetPeerInfoResult, e error) {
3442 var c *None
3443 if len(cmd) > 0 {
3444 c = cmd[0]
3445 }
3446 if e = r.Call("CAPI.GetPeerInfo", c, &res); E.Chk(e) {
3447 }
3448 return
3449 }
3450 3451 func (r *CAPIClient) GetRawMempool(cmd ...*btcjson.GetRawMempoolCmd) (res []string, e error) {
3452 var c *btcjson.GetRawMempoolCmd
3453 if len(cmd) > 0 {
3454 c = cmd[0]
3455 }
3456 if e = r.Call("CAPI.GetRawMempool", c, &res); E.Chk(e) {
3457 }
3458 return
3459 }
3460 3461 func (r *CAPIClient) GetRawTransaction(cmd ...*btcjson.GetRawTransactionCmd) (res string, e error) {
3462 var c *btcjson.GetRawTransactionCmd
3463 if len(cmd) > 0 {
3464 c = cmd[0]
3465 }
3466 if e = r.Call("CAPI.GetRawTransaction", c, &res); E.Chk(e) {
3467 }
3468 return
3469 }
3470 3471 func (r *CAPIClient) GetTxOut(cmd ...*btcjson.GetTxOutCmd) (res string, e error) {
3472 var c *btcjson.GetTxOutCmd
3473 if len(cmd) > 0 {
3474 c = cmd[0]
3475 }
3476 if e = r.Call("CAPI.GetTxOut", c, &res); E.Chk(e) {
3477 }
3478 return
3479 }
3480 3481 func (r *CAPIClient) Help(cmd ...*btcjson.HelpCmd) (res string, e error) {
3482 var c *btcjson.HelpCmd
3483 if len(cmd) > 0 {
3484 c = cmd[0]
3485 }
3486 if e = r.Call("CAPI.Help", c, &res); E.Chk(e) {
3487 }
3488 return
3489 }
3490 3491 func (r *CAPIClient) Node(cmd ...*btcjson.NodeCmd) (res None, e error) {
3492 var c *btcjson.NodeCmd
3493 if len(cmd) > 0 {
3494 c = cmd[0]
3495 }
3496 if e = r.Call("CAPI.Node", c, &res); E.Chk(e) {
3497 }
3498 return
3499 }
3500 3501 func (r *CAPIClient) Ping(cmd ...*None) (res None, e error) {
3502 var c *None
3503 if len(cmd) > 0 {
3504 c = cmd[0]
3505 }
3506 if e = r.Call("CAPI.Ping", c, &res); E.Chk(e) {
3507 }
3508 return
3509 }
3510 3511 func (r *CAPIClient) ResetChain(cmd ...*None) (res None, e error) {
3512 var c *None
3513 if len(cmd) > 0 {
3514 c = cmd[0]
3515 }
3516 if e = r.Call("CAPI.ResetChain", c, &res); E.Chk(e) {
3517 }
3518 return
3519 }
3520 3521 func (r *CAPIClient) Restart(cmd ...*None) (res None, e error) {
3522 var c *None
3523 if len(cmd) > 0 {
3524 c = cmd[0]
3525 }
3526 if e = r.Call("CAPI.Restart", c, &res); E.Chk(e) {
3527 }
3528 return
3529 }
3530 3531 func (r *CAPIClient) SearchRawTransactions(cmd ...*btcjson.SearchRawTransactionsCmd) (res []btcjson.SearchRawTransactionsResult, e error) {
3532 var c *btcjson.SearchRawTransactionsCmd
3533 if len(cmd) > 0 {
3534 c = cmd[0]
3535 }
3536 if e = r.Call("CAPI.SearchRawTransactions", c, &res); E.Chk(e) {
3537 }
3538 return
3539 }
3540 3541 func (r *CAPIClient) SendRawTransaction(cmd ...*btcjson.SendRawTransactionCmd) (res None, e error) {
3542 var c *btcjson.SendRawTransactionCmd
3543 if len(cmd) > 0 {
3544 c = cmd[0]
3545 }
3546 if e = r.Call("CAPI.SendRawTransaction", c, &res); E.Chk(e) {
3547 }
3548 return
3549 }
3550 3551 func (r *CAPIClient) SetGenerate(cmd ...*btcjson.SetGenerateCmd) (res None, e error) {
3552 var c *btcjson.SetGenerateCmd
3553 if len(cmd) > 0 {
3554 c = cmd[0]
3555 }
3556 if e = r.Call("CAPI.SetGenerate", c, &res); E.Chk(e) {
3557 }
3558 return
3559 }
3560 3561 func (r *CAPIClient) Stop(cmd ...*None) (res None, e error) {
3562 var c *None
3563 if len(cmd) > 0 {
3564 c = cmd[0]
3565 }
3566 if e = r.Call("CAPI.Stop", c, &res); E.Chk(e) {
3567 }
3568 return
3569 }
3570 3571 func (r *CAPIClient) SubmitBlock(cmd ...*btcjson.SubmitBlockCmd) (res string, e error) {
3572 var c *btcjson.SubmitBlockCmd
3573 if len(cmd) > 0 {
3574 c = cmd[0]
3575 }
3576 if e = r.Call("CAPI.SubmitBlock", c, &res); E.Chk(e) {
3577 }
3578 return
3579 }
3580 3581 func (r *CAPIClient) Uptime(cmd ...*None) (res btcjson.GetMempoolInfoResult, e error) {
3582 var c *None
3583 if len(cmd) > 0 {
3584 c = cmd[0]
3585 }
3586 if e = r.Call("CAPI.Uptime", c, &res); E.Chk(e) {
3587 }
3588 return
3589 }
3590 3591 func (r *CAPIClient) ValidateAddress(cmd ...*btcjson.ValidateAddressCmd) (res btcjson.ValidateAddressChainResult, e error) {
3592 var c *btcjson.ValidateAddressCmd
3593 if len(cmd) > 0 {
3594 c = cmd[0]
3595 }
3596 if e = r.Call("CAPI.ValidateAddress", c, &res); E.Chk(e) {
3597 }
3598 return
3599 }
3600 3601 func (r *CAPIClient) VerifyChain(cmd ...*btcjson.VerifyChainCmd) (res bool, e error) {
3602 var c *btcjson.VerifyChainCmd
3603 if len(cmd) > 0 {
3604 c = cmd[0]
3605 }
3606 if e = r.Call("CAPI.VerifyChain", c, &res); E.Chk(e) {
3607 }
3608 return
3609 }
3610 3611 func (r *CAPIClient) VerifyMessage(cmd ...*btcjson.VerifyMessageCmd) (res bool, e error) {
3612 var c *btcjson.VerifyMessageCmd
3613 if len(cmd) > 0 {
3614 c = cmd[0]
3615 }
3616 if e = r.Call("CAPI.VerifyMessage", c, &res); E.Chk(e) {
3617 }
3618 return
3619 }
3620 3621 func (r *CAPIClient) Version(cmd ...*btcjson.VersionCmd) (res map[string]btcjson.VersionResult, e error) {
3622 var c *btcjson.VersionCmd
3623 if len(cmd) > 0 {
3624 c = cmd[0]
3625 }
3626 if e = r.Call("CAPI.Version", c, &res); E.Chk(e) {
3627 }
3628 return
3629 }
3630 3631