chainsvrcmds.go raw

   1  package btcjson
   2  
   3  import (
   4  	"encoding/json"
   5  	"fmt"
   6  	
   7  	"github.com/p9c/p9/pkg/wire"
   8  )
   9  
  10  // AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.
  11  type AddNodeSubCmd string
  12  
  13  const (
  14  	// ANAdd indicates the specified host should be added as a persistent peer.
  15  	ANAdd AddNodeSubCmd = "add"
  16  	// ANRemove indicates the specified peer should be removed.
  17  	ANRemove AddNodeSubCmd = "remove"
  18  	// ANOneTry indicates the specified host should try to connect once, but it should not be made persistent.
  19  	ANOneTry AddNodeSubCmd = "onetry"
  20  )
  21  
  22  // AddNodeCmd defines the addnode JSON-RPC command.
  23  type AddNodeCmd struct {
  24  	Addr   string
  25  	SubCmd AddNodeSubCmd `jsonrpcusage:"\"add|remove|onetry\""`
  26  }
  27  
  28  // NewAddNodeCmd returns a new instance which can be used to issue an addnode JSON-RPC command.
  29  func NewAddNodeCmd(addr string, subCmd AddNodeSubCmd) *AddNodeCmd {
  30  	return &AddNodeCmd{
  31  		Addr:   addr,
  32  		SubCmd: subCmd,
  33  	}
  34  }
  35  
  36  // TransactionInput represents the inputs to a transaction.  Specifically a transaction hash and output number pair.
  37  type TransactionInput struct {
  38  	Txid string `json:"txid"`
  39  	Vout uint32 `json:"vout"`
  40  }
  41  
  42  // CreateRawTransactionCmd defines the createrawtransaction JSON-RPC command.
  43  type CreateRawTransactionCmd struct {
  44  	Inputs   []TransactionInput
  45  	Amounts  map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In DUO
  46  	LockTime *int64
  47  }
  48  
  49  // NewCreateRawTransactionCmd returns a new instance which can be used to issue a createrawtransaction JSON-RPC command.
  50  // Amounts are in DUO.
  51  func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]float64,
  52  	lockTime *int64,
  53  ) *CreateRawTransactionCmd {
  54  	return &CreateRawTransactionCmd{
  55  		Inputs:   inputs,
  56  		Amounts:  amounts,
  57  		LockTime: lockTime,
  58  	}
  59  }
  60  
  61  // DecodeRawTransactionCmd defines the decoderawtransaction JSON-RPC command.
  62  type DecodeRawTransactionCmd struct {
  63  	HexTx string
  64  }
  65  
  66  // NewDecodeRawTransactionCmd returns a new instance which can be used to issue a decoderawtransaction JSON-RPC command.
  67  func NewDecodeRawTransactionCmd(hexTx string) *DecodeRawTransactionCmd {
  68  	return &DecodeRawTransactionCmd{
  69  		HexTx: hexTx,
  70  	}
  71  }
  72  
  73  // DecodeScriptCmd defines the decodescript JSON-RPC command.
  74  type DecodeScriptCmd struct {
  75  	HexScript string
  76  }
  77  
  78  // NewDecodeScriptCmd returns a new instance which can be used to issue a decodescript JSON-RPC command.
  79  func NewDecodeScriptCmd(hexScript string) *DecodeScriptCmd {
  80  	return &DecodeScriptCmd{
  81  		HexScript: hexScript,
  82  	}
  83  }
  84  
  85  // GetAddedNodeInfoCmd defines the getaddednodeinfo JSON-RPC command.
  86  type GetAddedNodeInfoCmd struct {
  87  	DNS  bool
  88  	Node *string
  89  }
  90  
  91  // NewGetAddedNodeInfoCmd returns a new instance which can be used to issue a getaddednodeinfo JSON-RPC command. The
  92  // parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default
  93  // value.
  94  func NewGetAddedNodeInfoCmd(dns bool, node *string) *GetAddedNodeInfoCmd {
  95  	return &GetAddedNodeInfoCmd{
  96  		DNS:  dns,
  97  		Node: node,
  98  	}
  99  }
 100  
 101  // GetBestBlockHashCmd defines the getbestblockhash JSON-RPC command.
 102  type GetBestBlockHashCmd struct{}
 103  
 104  // NewGetBestBlockHashCmd returns a new instance which can be used to issue a getbestblockhash JSON-RPC command.
 105  func NewGetBestBlockHashCmd() *GetBestBlockHashCmd {
 106  	return &GetBestBlockHashCmd{}
 107  }
 108  
 109  // GetBlockCmd defines the getblock JSON-RPC command.
 110  type GetBlockCmd struct {
 111  	Hash      string
 112  	Verbose   *bool `jsonrpcdefault:"true"`
 113  	VerboseTx *bool `jsonrpcdefault:"false"`
 114  }
 115  
 116  // NewGetBlockCmd returns a new instance which can be used to issue a getblock JSON-RPC command. The parameters which
 117  // are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
 118  func NewGetBlockCmd(hash string, verbose, verboseTx *bool) *GetBlockCmd {
 119  	return &GetBlockCmd{
 120  		Hash:      hash,
 121  		Verbose:   verbose,
 122  		VerboseTx: verboseTx,
 123  	}
 124  }
 125  
 126  // GetBlockChainInfoCmd defines the getblockchaininfo JSON-RPC command.
 127  type GetBlockChainInfoCmd struct{}
 128  
 129  // NewGetBlockChainInfoCmd returns a new instance which can be used to issue a getblockchaininfo JSON-RPC command.
 130  func NewGetBlockChainInfoCmd() *GetBlockChainInfoCmd {
 131  	return &GetBlockChainInfoCmd{}
 132  }
 133  
 134  // GetBlockCountCmd defines the getblockcount JSON-RPC command.
 135  type GetBlockCountCmd struct{}
 136  
 137  // NewGetBlockCountCmd returns a new instance which can be used to issue a getblockcount JSON-RPC command.
 138  func NewGetBlockCountCmd() *GetBlockCountCmd {
 139  	return &GetBlockCountCmd{}
 140  }
 141  
 142  // GetBlockHashCmd defines the getblockhash JSON-RPC command.
 143  type GetBlockHashCmd struct {
 144  	Index int64
 145  }
 146  
 147  // NewGetBlockHashCmd returns a new instance which can be used to issue a getblockhash JSON-RPC command.
 148  func NewGetBlockHashCmd(index int64) *GetBlockHashCmd {
 149  	return &GetBlockHashCmd{
 150  		Index: index,
 151  	}
 152  }
 153  
 154  // GetBlockHeaderCmd defines the getblockheader JSON-RPC command.
 155  type GetBlockHeaderCmd struct {
 156  	Hash    string
 157  	Verbose *bool `jsonrpcdefault:"true"`
 158  }
 159  
 160  // NewGetBlockHeaderCmd returns a new instance which can be used to issue a getblockheader JSON-RPC command.
 161  func NewGetBlockHeaderCmd(hash string, verbose *bool) *GetBlockHeaderCmd {
 162  	return &GetBlockHeaderCmd{
 163  		Hash:    hash,
 164  		Verbose: verbose,
 165  	}
 166  }
 167  
 168  // TemplateRequest is a request object as defined in BIP22 (https://en.bitcoin.it/wiki/BIP_0022), it is optionally
 169  // provided as an pointer argument to GetBlockTemplateCmd.
 170  type TemplateRequest struct {
 171  	Mode         string   `json:"mode,omitempty"`
 172  	Capabilities []string `json:"capabilities,omitempty"`
 173  	// Optional long polling.
 174  	LongPollID string `json:"longpollid,omitempty"`
 175  	// Optional template tweaking.  SigOpLimit and SizeLimit can be int64 or bool.
 176  	SigOpLimit interface{} `json:"sigoplimit,omitempty"`
 177  	SizeLimit  interface{} `json:"sizelimit,omitempty"`
 178  	MaxVersion uint32      `json:"maxversion,omitempty"`
 179  	// Basic pool extension from BIP 0023.
 180  	Target string `json:"target,omitempty"`
 181  	// Block proposal from BIP 0023.  Data is only provided when Mode is "proposal".
 182  	Data   string `json:"data,omitempty"`
 183  	WorkID string `json:"workid,omitempty"`
 184  }
 185  
 186  // convertTemplateRequestField potentially converts the provided value as needed.
 187  func convertTemplateRequestField(fieldName string, iface interface{}) (interface{}, error) {
 188  	switch val := iface.(type) {
 189  	case nil:
 190  		return nil, nil
 191  	case bool:
 192  		return val, nil
 193  	case float64:
 194  		if val == float64(int64(val)) {
 195  			return int64(val), nil
 196  		}
 197  	}
 198  	str := fmt.Sprintf("the %s field must be unspecified, a boolean, or "+
 199  		"a 64-bit integer", fieldName,
 200  	)
 201  	return nil, makeError(ErrInvalidType, str)
 202  }
 203  
 204  // UnmarshalJSON provides a custom Unmarshal method for TemplateRequest. This is necessary because the SigOpLimit and
 205  // SizeLimit fields can only be specific types.
 206  func (t *TemplateRequest) UnmarshalJSON(data []byte) (e error) {
 207  	type templateRequest TemplateRequest
 208  	request := (*templateRequest)(t)
 209  	if e = json.Unmarshal(data, &request); E.Chk(e) {
 210  		return e
 211  	}
 212  	// The SigOpLimit field can only be nil, bool, or int64.
 213  	var val interface{}
 214  	val, e = convertTemplateRequestField("sigoplimit", request.SigOpLimit)
 215  	if e != nil {
 216  		E.Ln(e)
 217  		return e
 218  	}
 219  	request.SigOpLimit = val
 220  	// The SizeLimit field can only be nil, bool, or int64.
 221  	val, e = convertTemplateRequestField("sizelimit", request.SizeLimit)
 222  	if e != nil {
 223  		E.Ln(e)
 224  		return e
 225  	}
 226  	request.SizeLimit = val
 227  	return nil
 228  }
 229  
 230  // GetBlockTemplateCmd defines the getblocktemplate JSON-RPC command.
 231  type GetBlockTemplateCmd struct {
 232  	Request *TemplateRequest
 233  }
 234  
 235  // NewGetBlockTemplateCmd returns a new instance which can be used to issue a getblocktemplate JSON-RPC command. The
 236  // parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default
 237  // value.
 238  func NewGetBlockTemplateCmd(request *TemplateRequest) *GetBlockTemplateCmd {
 239  	return &GetBlockTemplateCmd{
 240  		Request: request,
 241  	}
 242  }
 243  
 244  // GetCFilterCmd defines the getcfilter JSON-RPC command.
 245  type GetCFilterCmd struct {
 246  	Hash       string
 247  	FilterType wire.FilterType
 248  }
 249  
 250  // NewGetCFilterCmd returns a new instance which can be used to issue a getcfilter JSON-RPC command.
 251  func NewGetCFilterCmd(hash string, filterType wire.FilterType) *GetCFilterCmd {
 252  	return &GetCFilterCmd{
 253  		Hash:       hash,
 254  		FilterType: filterType,
 255  	}
 256  }
 257  
 258  // GetCFilterHeaderCmd defines the getcfilterheader JSON-RPC command.
 259  type GetCFilterHeaderCmd struct {
 260  	Hash       string
 261  	FilterType wire.FilterType
 262  }
 263  
 264  // NewGetCFilterHeaderCmd returns a new instance which can be used to issue a getcfilterheader JSON-RPC command.
 265  func NewGetCFilterHeaderCmd(hash string,
 266  	filterType wire.FilterType,
 267  ) *GetCFilterHeaderCmd {
 268  	return &GetCFilterHeaderCmd{
 269  		Hash:       hash,
 270  		FilterType: filterType,
 271  	}
 272  }
 273  
 274  // GetChainTipsCmd defines the getchaintips JSON-RPC command.
 275  type GetChainTipsCmd struct{}
 276  
 277  // NewGetChainTipsCmd returns a new instance which can be used to issue a getchaintips JSON-RPC command.
 278  func NewGetChainTipsCmd() *GetChainTipsCmd {
 279  	return &GetChainTipsCmd{}
 280  }
 281  
 282  // GetConnectionCountCmd defines the getconnectioncount JSON-RPC command.
 283  type GetConnectionCountCmd struct{}
 284  
 285  // NewGetConnectionCountCmd returns a new instance which can be used to issue a getconnectioncount JSON-RPC command.
 286  func NewGetConnectionCountCmd() *GetConnectionCountCmd {
 287  	return &GetConnectionCountCmd{}
 288  }
 289  
 290  // GetDifficultyCmd defines the getdifficulty JSON-RPC command.
 291  type GetDifficultyCmd struct {
 292  	Algo string
 293  }
 294  
 295  // NewGetDifficultyCmd returns a new instance which can be used to issue a getdifficulty JSON-RPC command.
 296  func NewGetDifficultyCmd(algo string) *GetDifficultyCmd {
 297  	return &GetDifficultyCmd{
 298  		Algo: algo,
 299  	}
 300  }
 301  
 302  // GetGenerateCmd defines the getgenerate JSON-RPC command.
 303  type GetGenerateCmd struct{}
 304  
 305  // NewGetGenerateCmd returns a new instance which can be used to issue a getgenerate JSON-RPC command.
 306  func NewGetGenerateCmd() *GetGenerateCmd {
 307  	return &GetGenerateCmd{}
 308  }
 309  
 310  // GetHashesPerSecCmd defines the gethashespersec JSON-RPC command.
 311  type GetHashesPerSecCmd struct{}
 312  
 313  // NewGetHashesPerSecCmd returns a new instance which can be used to issue a gethashespersec JSON-RPC command.
 314  func NewGetHashesPerSecCmd() *GetHashesPerSecCmd {
 315  	return &GetHashesPerSecCmd{}
 316  }
 317  
 318  // GetInfoCmd defines the getinfo JSON-RPC command.
 319  type GetInfoCmd struct{}
 320  
 321  // NewGetInfoCmd returns a new instance which can be used to issue a getinfo JSON-RPC command.
 322  func NewGetInfoCmd() *GetInfoCmd {
 323  	return &GetInfoCmd{}
 324  }
 325  
 326  // GetMempoolEntryCmd defines the getmempoolentry JSON-RPC command.
 327  type GetMempoolEntryCmd struct {
 328  	TxID string
 329  }
 330  
 331  // NewGetMempoolEntryCmd returns a new instance which can be used to issue a getmempoolentry JSON-RPC command.
 332  func NewGetMempoolEntryCmd(txHash string) *GetMempoolEntryCmd {
 333  	return &GetMempoolEntryCmd{
 334  		TxID: txHash,
 335  	}
 336  }
 337  
 338  // GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command.
 339  type GetMempoolInfoCmd struct{}
 340  
 341  // NewGetMempoolInfoCmd returns a new instance which can be used to issue a getmempool JSON-RPC command.
 342  func NewGetMempoolInfoCmd() *GetMempoolInfoCmd {
 343  	return &GetMempoolInfoCmd{}
 344  }
 345  
 346  // GetMiningInfoCmd defines the getmininginfo JSON-RPC command.
 347  type GetMiningInfoCmd struct{}
 348  
 349  // NewGetMiningInfoCmd returns a new instance which can be used to issue a getmininginfo JSON-RPC command.
 350  func NewGetMiningInfoCmd() *GetMiningInfoCmd {
 351  	return &GetMiningInfoCmd{}
 352  }
 353  
 354  // GetNetworkInfoCmd defines the getnetworkinfo JSON-RPC command.
 355  type GetNetworkInfoCmd struct{}
 356  
 357  // NewGetNetworkInfoCmd returns a new instance which can be used to issue a getnetworkinfo JSON-RPC command.
 358  func NewGetNetworkInfoCmd() *GetNetworkInfoCmd {
 359  	return &GetNetworkInfoCmd{}
 360  }
 361  
 362  // GetNetTotalsCmd defines the getnettotals JSON-RPC command.
 363  type GetNetTotalsCmd struct{}
 364  
 365  // NewGetNetTotalsCmd returns a new instance which can be used to issue a getnettotals JSON-RPC command.
 366  func NewGetNetTotalsCmd() *GetNetTotalsCmd {
 367  	return &GetNetTotalsCmd{}
 368  }
 369  
 370  // GetNetworkHashPSCmd defines the getnetworkhashps JSON-RPC command.
 371  type GetNetworkHashPSCmd struct {
 372  	Blocks *int `jsonrpcdefault:"120"`
 373  	Height *int `jsonrpcdefault:"-1"`
 374  }
 375  
 376  // NewGetNetworkHashPSCmd returns a new instance which can be used to issue a getnetworkhashps JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 377  func NewGetNetworkHashPSCmd(numBlocks, height *int) *GetNetworkHashPSCmd {
 378  	return &GetNetworkHashPSCmd{
 379  		Blocks: numBlocks,
 380  		Height: height,
 381  	}
 382  }
 383  
 384  // GetPeerInfoCmd defines the getpeerinfo JSON-RPC command.
 385  type GetPeerInfoCmd struct{}
 386  
 387  // NewGetPeerInfoCmd returns a new instance which can be used to issue a getpeer JSON-RPC command.
 388  func NewGetPeerInfoCmd() *GetPeerInfoCmd {
 389  	return &GetPeerInfoCmd{}
 390  }
 391  
 392  // GetRawMempoolCmd defines the getmempool JSON-RPC command.
 393  type GetRawMempoolCmd struct {
 394  	Verbose *bool `jsonrpcdefault:"false"`
 395  }
 396  
 397  // NewGetRawMempoolCmd returns a new instance which can be used to issue a getrawmempool JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 398  func NewGetRawMempoolCmd(verbose *bool) *GetRawMempoolCmd {
 399  	return &GetRawMempoolCmd{
 400  		Verbose: verbose,
 401  	}
 402  }
 403  
 404  // GetRawTransactionCmd defines the getrawtransaction JSON-RPC command. NOTE: This field is an int versus a bool to remain compatible with Bitcoin Core even though it really should be a bool.
 405  type GetRawTransactionCmd struct {
 406  	Txid    string
 407  	Verbose *int `jsonrpcdefault:"0"`
 408  }
 409  
 410  // NewGetRawTransactionCmd returns a new instance which can be used to issue a getrawtransaction JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 411  func NewGetRawTransactionCmd(txHash string, verbose *int) *GetRawTransactionCmd {
 412  	return &GetRawTransactionCmd{
 413  		Txid:    txHash,
 414  		Verbose: verbose,
 415  	}
 416  }
 417  
 418  // GetTxOutCmd defines the gettxout JSON-RPC command.
 419  type GetTxOutCmd struct {
 420  	Txid           string
 421  	Vout           uint32
 422  	IncludeMempool *bool `jsonrpcdefault:"true"`
 423  }
 424  
 425  // NewGetTxOutCmd returns a new instance which can be used to issue a gettxout JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 426  func NewGetTxOutCmd(txHash string, vout uint32, includeMempool *bool) *GetTxOutCmd {
 427  	return &GetTxOutCmd{
 428  		Txid:           txHash,
 429  		Vout:           vout,
 430  		IncludeMempool: includeMempool,
 431  	}
 432  }
 433  
 434  // GetTxOutProofCmd defines the gettxoutproof JSON-RPC command.
 435  type GetTxOutProofCmd struct {
 436  	TxIDs     []string
 437  	BlockHash *string
 438  }
 439  
 440  // NewGetTxOutProofCmd returns a new instance which can be used to issue a gettxoutproof JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 441  func NewGetTxOutProofCmd(txIDs []string, blockHash *string) *GetTxOutProofCmd {
 442  	return &GetTxOutProofCmd{
 443  		TxIDs:     txIDs,
 444  		BlockHash: blockHash,
 445  	}
 446  }
 447  
 448  // GetTxOutSetInfoCmd defines the gettxoutsetinfo JSON-RPC command.
 449  type GetTxOutSetInfoCmd struct{}
 450  
 451  // NewGetTxOutSetInfoCmd returns a new instance which can be used to issue a gettxoutsetinfo JSON-RPC command.
 452  func NewGetTxOutSetInfoCmd() *GetTxOutSetInfoCmd {
 453  	return &GetTxOutSetInfoCmd{}
 454  }
 455  
 456  // GetWorkCmd defines the getwork JSON-RPC command.
 457  type GetWorkCmd struct {
 458  	Data *string
 459  }
 460  
 461  // NewGetWorkCmd returns a new instance which can be used to issue a getwork JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 462  func NewGetWorkCmd(data *string) *GetWorkCmd {
 463  	return &GetWorkCmd{
 464  		Data: data,
 465  	}
 466  }
 467  
 468  // HelpCmd defines the help JSON-RPC command.
 469  type HelpCmd struct {
 470  	Command *string
 471  }
 472  
 473  // NewHelpCmd returns a new instance which can be used to issue a help JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 474  func NewHelpCmd(command *string) *HelpCmd {
 475  	return &HelpCmd{
 476  		Command: command,
 477  	}
 478  }
 479  
 480  // InvalidateBlockCmd defines the invalidateblock JSON-RPC command.
 481  type InvalidateBlockCmd struct {
 482  	BlockHash string
 483  }
 484  
 485  // NewInvalidateBlockCmd returns a new instance which can be used to issue a invalidateblock JSON-RPC command.
 486  func NewInvalidateBlockCmd(blockHash string) *InvalidateBlockCmd {
 487  	return &InvalidateBlockCmd{
 488  		BlockHash: blockHash,
 489  	}
 490  }
 491  
 492  // PingCmd defines the ping JSON-RPC command.
 493  type PingCmd struct{}
 494  
 495  // NewPingCmd returns a new instance which can be used to issue a ping JSON-RPC command.
 496  func NewPingCmd() *PingCmd {
 497  	return &PingCmd{}
 498  }
 499  
 500  // PreciousBlockCmd defines the preciousblock JSON-RPC command.
 501  type PreciousBlockCmd struct {
 502  	BlockHash string
 503  }
 504  
 505  // NewPreciousBlockCmd returns a new instance which can be used to issue a preciousblock JSON-RPC command.
 506  func NewPreciousBlockCmd(blockHash string) *PreciousBlockCmd {
 507  	return &PreciousBlockCmd{
 508  		BlockHash: blockHash,
 509  	}
 510  }
 511  
 512  // ReconsiderBlockCmd defines the reconsiderblock JSON-RPC command.
 513  type ReconsiderBlockCmd struct {
 514  	BlockHash string
 515  }
 516  
 517  // NewReconsiderBlockCmd returns a new instance which can be used to issue a reconsiderblock JSON-RPC command.
 518  func NewReconsiderBlockCmd(blockHash string) *ReconsiderBlockCmd {
 519  	return &ReconsiderBlockCmd{
 520  		BlockHash: blockHash,
 521  	}
 522  }
 523  
 524  // SearchRawTransactionsCmd defines the searchrawtransactions JSON-RPC command.
 525  type SearchRawTransactionsCmd struct {
 526  	Address     string
 527  	Verbose     *int  `jsonrpcdefault:"1"`
 528  	Skip        *int  `jsonrpcdefault:"0"`
 529  	Count       *int  `jsonrpcdefault:"100"`
 530  	VinExtra    *int  `jsonrpcdefault:"0"`
 531  	Reverse     *bool `jsonrpcdefault:"false"`
 532  	FilterAddrs *[]string
 533  }
 534  
 535  // NewSearchRawTransactionsCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 536  func NewSearchRawTransactionsCmd(address string, verbose, skip, count *int, vinExtra *int, reverse *bool,
 537  	filterAddrs *[]string,
 538  ) *SearchRawTransactionsCmd {
 539  	return &SearchRawTransactionsCmd{
 540  		Address:     address,
 541  		Verbose:     verbose,
 542  		Skip:        skip,
 543  		Count:       count,
 544  		VinExtra:    vinExtra,
 545  		Reverse:     reverse,
 546  		FilterAddrs: filterAddrs,
 547  	}
 548  }
 549  
 550  // SendRawTransactionCmd defines the sendrawtransaction JSON-RPC command.
 551  type SendRawTransactionCmd struct {
 552  	HexTx         string
 553  	AllowHighFees *bool `jsonrpcdefault:"false"`
 554  }
 555  
 556  // NewSendRawTransactionCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command. The
 557  // parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default
 558  // value.
 559  func NewSendRawTransactionCmd(hexTx string, allowHighFees *bool) *SendRawTransactionCmd {
 560  	return &SendRawTransactionCmd{
 561  		HexTx:         hexTx,
 562  		AllowHighFees: allowHighFees,
 563  	}
 564  }
 565  
 566  // SetGenerateCmd defines the setgenerate JSON-RPC command.
 567  type SetGenerateCmd struct {
 568  	Generate     bool
 569  	GenProcLimit *int `jsonrpcdefault:"-1"`
 570  }
 571  
 572  // NewSetGenerateCmd returns a new instance which can be used to issue a setgenerate JSON-RPC command. The parameters
 573  // which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
 574  func NewSetGenerateCmd(generate bool, genProcLimit *int) *SetGenerateCmd {
 575  	return &SetGenerateCmd{
 576  		Generate:     generate,
 577  		GenProcLimit: genProcLimit,
 578  	}
 579  }
 580  
 581  // StopCmd defines the stop JSON-RPC command.
 582  type StopCmd struct{}
 583  
 584  // NewStopCmd returns a new instance which can be used to issue a stop JSON-RPC command.
 585  func NewStopCmd() *StopCmd {
 586  	return &StopCmd{}
 587  }
 588  
 589  // RestartCmd defines the restart JSON-RPC command.
 590  type RestartCmd struct{}
 591  
 592  // NewRestartCmd returns a new instance which can be used to issue a stop JSON-RPC command.
 593  func NewRestartCmd() *RestartCmd {
 594  	return &RestartCmd{}
 595  }
 596  
 597  // ResetChainCmd defines the resetchain JSON-RPC command
 598  type ResetChainCmd struct{}
 599  
 600  // NewResetChainCmd returns a new instance which can be used to issue a resetchain JSON-RPC command
 601  func NewResetChainCmd() *ResetChainCmd {
 602  	return &ResetChainCmd{}
 603  }
 604  
 605  // SubmitBlockOptions represents the optional options struct provided with a SubmitBlockCmd command.
 606  type SubmitBlockOptions struct {
 607  	// must be provided if server provided a workid with template.
 608  	WorkID string `json:"workid,omitempty"`
 609  }
 610  
 611  // SubmitBlockCmd defines the submitblock JSON-RPC command.
 612  type SubmitBlockCmd struct {
 613  	HexBlock string
 614  	Options  *SubmitBlockOptions
 615  }
 616  
 617  // NewSubmitBlockCmd returns a new instance which can be used to issue a submitblock JSON-RPC command. The parameters
 618  // which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
 619  func NewSubmitBlockCmd(hexBlock string, options *SubmitBlockOptions) *SubmitBlockCmd {
 620  	return &SubmitBlockCmd{
 621  		HexBlock: hexBlock,
 622  		Options:  options,
 623  	}
 624  }
 625  
 626  // UptimeCmd defines the uptime JSON-RPC command.
 627  type UptimeCmd struct{}
 628  
 629  // NewUptimeCmd returns a new instance which can be used to issue an uptime JSON-RPC command.
 630  func NewUptimeCmd() *UptimeCmd {
 631  	return &UptimeCmd{}
 632  }
 633  
 634  // ValidateAddressCmd defines the validateaddress JSON-RPC command.
 635  type ValidateAddressCmd struct {
 636  	Address string
 637  }
 638  
 639  // NewValidateAddressCmd returns a new instance which can be used to issue a validateaddress JSON-RPC command.
 640  func NewValidateAddressCmd(address string) *ValidateAddressCmd {
 641  	return &ValidateAddressCmd{
 642  		Address: address,
 643  	}
 644  }
 645  
 646  // VerifyChainCmd defines the verifychain JSON-RPC command.
 647  type VerifyChainCmd struct {
 648  	CheckLevel *int32 `jsonrpcdefault:"3"`
 649  	CheckDepth *int32 `jsonrpcdefault:"288"` // 0 = all
 650  }
 651  
 652  // NewVerifyChainCmd returns a new instance which can be used to issue a verifychain JSON-RPC command. The parameters which are pointers indicate they are optional.  Passing nil for optional parameters will use the default value.
 653  func NewVerifyChainCmd(checkLevel, checkDepth *int32) *VerifyChainCmd {
 654  	return &VerifyChainCmd{
 655  		CheckLevel: checkLevel,
 656  		CheckDepth: checkDepth,
 657  	}
 658  }
 659  
 660  // VerifyMessageCmd defines the verifymessage JSON-RPC command.
 661  type VerifyMessageCmd struct {
 662  	Address   string
 663  	Signature string
 664  	Message   string
 665  }
 666  
 667  // NewVerifyMessageCmd returns a new instance which can be used to issue a verifymessage JSON-RPC command.
 668  func NewVerifyMessageCmd(address, signature, message string) *VerifyMessageCmd {
 669  	return &VerifyMessageCmd{
 670  		Address:   address,
 671  		Signature: signature,
 672  		Message:   message,
 673  	}
 674  }
 675  
 676  // VerifyTxOutProofCmd defines the verifytxoutproof JSON-RPC command.
 677  type VerifyTxOutProofCmd struct {
 678  	Proof string
 679  }
 680  
 681  // NewVerifyTxOutProofCmd returns a new instance which can be used to issue a verifytxoutproof JSON-RPC command.
 682  func NewVerifyTxOutProofCmd(proof string) *VerifyTxOutProofCmd {
 683  	return &VerifyTxOutProofCmd{
 684  		Proof: proof,
 685  	}
 686  }
 687  func init() {
 688  	
 689  	// No special flags for commands in this file.
 690  	flags := UsageFlag(0)
 691  	MustRegisterCmd("addnode", (*AddNodeCmd)(nil), flags)
 692  	MustRegisterCmd("createrawtransaction", (*CreateRawTransactionCmd)(nil), flags)
 693  	MustRegisterCmd("decoderawtransaction", (*DecodeRawTransactionCmd)(nil), flags)
 694  	MustRegisterCmd("decodescript", (*DecodeScriptCmd)(nil), flags)
 695  	MustRegisterCmd("getaddednodeinfo", (*GetAddedNodeInfoCmd)(nil), flags)
 696  	MustRegisterCmd("getbestblockhash", (*GetBestBlockHashCmd)(nil), flags)
 697  	MustRegisterCmd("getblock", (*GetBlockCmd)(nil), flags)
 698  	MustRegisterCmd("getblockchaininfo", (*GetBlockChainInfoCmd)(nil), flags)
 699  	MustRegisterCmd("getblockcount", (*GetBlockCountCmd)(nil), flags)
 700  	MustRegisterCmd("getblockhash", (*GetBlockHashCmd)(nil), flags)
 701  	MustRegisterCmd("getblockheader", (*GetBlockHeaderCmd)(nil), flags)
 702  	MustRegisterCmd("getblocktemplate", (*GetBlockTemplateCmd)(nil), flags)
 703  	MustRegisterCmd("getcfilter", (*GetCFilterCmd)(nil), flags)
 704  	MustRegisterCmd("getcfilterheader", (*GetCFilterHeaderCmd)(nil), flags)
 705  	MustRegisterCmd("getchaintips", (*GetChainTipsCmd)(nil), flags)
 706  	MustRegisterCmd("getconnectioncount", (*GetConnectionCountCmd)(nil), flags)
 707  	MustRegisterCmd("getdifficulty", (*GetDifficultyCmd)(nil), flags)
 708  	MustRegisterCmd("getgenerate", (*GetGenerateCmd)(nil), flags)
 709  	MustRegisterCmd("gethashespersec", (*GetHashesPerSecCmd)(nil), flags)
 710  	MustRegisterCmd("getinfo", (*GetInfoCmd)(nil), flags)
 711  	MustRegisterCmd("getmempoolentry", (*GetMempoolEntryCmd)(nil), flags)
 712  	MustRegisterCmd("getmempoolinfo", (*GetMempoolInfoCmd)(nil), flags)
 713  	MustRegisterCmd("getmininginfo", (*GetMiningInfoCmd)(nil), flags)
 714  	MustRegisterCmd("getnetworkinfo", (*GetNetworkInfoCmd)(nil), flags)
 715  	MustRegisterCmd("getnettotals", (*GetNetTotalsCmd)(nil), flags)
 716  	MustRegisterCmd("getnetworkhashps", (*GetNetworkHashPSCmd)(nil), flags)
 717  	MustRegisterCmd("getpeerinfo", (*GetPeerInfoCmd)(nil), flags)
 718  	MustRegisterCmd("getrawmempool", (*GetRawMempoolCmd)(nil), flags)
 719  	MustRegisterCmd("getrawtransaction", (*GetRawTransactionCmd)(nil), flags)
 720  	MustRegisterCmd("gettxout", (*GetTxOutCmd)(nil), flags)
 721  	MustRegisterCmd("gettxoutproof", (*GetTxOutProofCmd)(nil), flags)
 722  	MustRegisterCmd("gettxoutsetinfo", (*GetTxOutSetInfoCmd)(nil), flags)
 723  	MustRegisterCmd("getwork", (*GetWorkCmd)(nil), flags)
 724  	MustRegisterCmd("help", (*HelpCmd)(nil), flags)
 725  	MustRegisterCmd("invalidateblock", (*InvalidateBlockCmd)(nil), flags)
 726  	MustRegisterCmd("ping", (*PingCmd)(nil), flags)
 727  	MustRegisterCmd("preciousblock", (*PreciousBlockCmd)(nil), flags)
 728  	MustRegisterCmd("reconsiderblock", (*ReconsiderBlockCmd)(nil), flags)
 729  	MustRegisterCmd("resetchain", (*ResetChainCmd)(nil), flags)
 730  	MustRegisterCmd("searchrawtransactions", (*SearchRawTransactionsCmd)(nil), flags)
 731  	MustRegisterCmd("sendrawtransaction", (*SendRawTransactionCmd)(nil), flags)
 732  	MustRegisterCmd("setgenerate", (*SetGenerateCmd)(nil), flags)
 733  	MustRegisterCmd("stop", (*StopCmd)(nil), flags)
 734  	MustRegisterCmd("restart", (*RestartCmd)(nil), flags)
 735  	MustRegisterCmd("submitblock", (*SubmitBlockCmd)(nil), flags)
 736  	MustRegisterCmd("uptime", (*UptimeCmd)(nil), flags)
 737  	MustRegisterCmd("validateaddress", (*ValidateAddressCmd)(nil), flags)
 738  	MustRegisterCmd("verifychain", (*VerifyChainCmd)(nil), flags)
 739  	MustRegisterCmd("verifymessage", (*VerifyMessageCmd)(nil), flags)
 740  	MustRegisterCmd("verifytxoutproof", (*VerifyTxOutProofCmd)(nil), flags)
 741  }
 742