github.com/dashpay/godash@v0.0.0-20160726055534-e038a21e0e3d/btcjson/chainsvrcmds.go (about)

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