github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/btcjson/walletsvrwscmds.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  package btcjson
     7  
     8  // NOTE: This file is intended to house the RPC commands that are supported by
     9  // a wallet server, but are only available via websockets.
    10  
    11  // CreateEncryptedWalletCmd defines the createencryptedwallet JSON-RPC command.
    12  type CreateEncryptedWalletCmd struct {
    13  	Passphrase string
    14  }
    15  
    16  // NewCreateEncryptedWalletCmd returns a new instance which can be used to issue
    17  // a createencryptedwallet JSON-RPC command.
    18  func NewCreateEncryptedWalletCmd(passphrase string) *CreateEncryptedWalletCmd {
    19  	return &CreateEncryptedWalletCmd{
    20  		Passphrase: passphrase,
    21  	}
    22  }
    23  
    24  // ExportWatchingWalletCmd defines the exportwatchingwallet JSON-RPC command.
    25  type ExportWatchingWalletCmd struct {
    26  	Account  *string
    27  	Download *bool `jsonrpcdefault:"false"`
    28  }
    29  
    30  // NewExportWatchingWalletCmd returns a new instance which can be used to issue
    31  // a exportwatchingwallet JSON-RPC command.
    32  //
    33  // The parameters which are pointers indicate they are optional.  Passing nil
    34  // for optional parameters will use the default value.
    35  func NewExportWatchingWalletCmd(account *string, download *bool) *ExportWatchingWalletCmd {
    36  	return &ExportWatchingWalletCmd{
    37  		Account:  account,
    38  		Download: download,
    39  	}
    40  }
    41  
    42  // GetUnconfirmedBalanceCmd defines the getunconfirmedbalance JSON-RPC command.
    43  type GetUnconfirmedBalanceCmd struct {
    44  	Account *string
    45  }
    46  
    47  // NewGetUnconfirmedBalanceCmd returns a new instance which can be used to issue
    48  // a getunconfirmedbalance JSON-RPC command.
    49  //
    50  // The parameters which are pointers indicate they are optional.  Passing nil
    51  // for optional parameters will use the default value.
    52  func NewGetUnconfirmedBalanceCmd(account *string) *GetUnconfirmedBalanceCmd {
    53  	return &GetUnconfirmedBalanceCmd{
    54  		Account: account,
    55  	}
    56  }
    57  
    58  // ListAddressTransactionsCmd defines the listaddresstransactions JSON-RPC
    59  // command.
    60  type ListAddressTransactionsCmd struct {
    61  	Addresses []string
    62  	Account   *string
    63  }
    64  
    65  // NewListAddressTransactionsCmd returns a new instance which can be used to
    66  // issue a listaddresstransactions JSON-RPC command.
    67  //
    68  // The parameters which are pointers indicate they are optional.  Passing nil
    69  // for optional parameters will use the default value.
    70  func NewListAddressTransactionsCmd(addresses []string, account *string) *ListAddressTransactionsCmd {
    71  	return &ListAddressTransactionsCmd{
    72  		Addresses: addresses,
    73  		Account:   account,
    74  	}
    75  }
    76  
    77  // ListAllTransactionsCmd defines the listalltransactions JSON-RPC command.
    78  type ListAllTransactionsCmd struct {
    79  	Account *string
    80  }
    81  
    82  // NewListAllTransactionsCmd returns a new instance which can be used to issue a
    83  // listalltransactions JSON-RPC command.
    84  //
    85  // The parameters which are pointers indicate they are optional.  Passing nil
    86  // for optional parameters will use the default value.
    87  func NewListAllTransactionsCmd(account *string) *ListAllTransactionsCmd {
    88  	return &ListAllTransactionsCmd{
    89  		Account: account,
    90  	}
    91  }
    92  
    93  // RecoverAddressesCmd defines the recoveraddresses JSON-RPC command.
    94  type RecoverAddressesCmd struct {
    95  	Account string
    96  	N       int
    97  }
    98  
    99  // NewRecoverAddressesCmd returns a new instance which can be used to issue a
   100  // recoveraddresses JSON-RPC command.
   101  func NewRecoverAddressesCmd(account string, n int) *RecoverAddressesCmd {
   102  	return &RecoverAddressesCmd{
   103  		Account: account,
   104  		N:       n,
   105  	}
   106  }
   107  
   108  // WalletIsLockedCmd defines the walletislocked JSON-RPC command.
   109  type WalletIsLockedCmd struct{}
   110  
   111  // NewWalletIsLockedCmd returns a new instance which can be used to issue a
   112  // walletislocked JSON-RPC command.
   113  func NewWalletIsLockedCmd() *WalletIsLockedCmd {
   114  	return &WalletIsLockedCmd{}
   115  }
   116  
   117  func init() {
   118  	// The commands in this file are only usable with a wallet server via
   119  	// websockets.
   120  	flags := UFWalletOnly | UFWebsocketOnly
   121  
   122  	MustRegisterCmd("createencryptedwallet", (*CreateEncryptedWalletCmd)(nil), flags)
   123  	MustRegisterCmd("exportwatchingwallet", (*ExportWatchingWalletCmd)(nil), flags)
   124  	MustRegisterCmd("getunconfirmedbalance", (*GetUnconfirmedBalanceCmd)(nil), flags)
   125  	MustRegisterCmd("listaddresstransactions", (*ListAddressTransactionsCmd)(nil), flags)
   126  	MustRegisterCmd("listalltransactions", (*ListAllTransactionsCmd)(nil), flags)
   127  	MustRegisterCmd("recoveraddresses", (*RecoverAddressesCmd)(nil), flags)
   128  	MustRegisterCmd("walletislocked", (*WalletIsLockedCmd)(nil), flags)
   129  }