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

     1  // Copyright (c) 2015 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 wallet server with btcwallet extensions.
     8  
     9  package btcjson
    10  
    11  // CreateNewAccountCmd defines the createnewaccount JSON-RPC command.
    12  type CreateNewAccountCmd struct {
    13  	Account string
    14  }
    15  
    16  // NewCreateNewAccountCmd returns a new instance which can be used to issue a
    17  // createnewaccount JSON-RPC command.
    18  func NewCreateNewAccountCmd(account string) *CreateNewAccountCmd {
    19  	return &CreateNewAccountCmd{
    20  		Account: account,
    21  	}
    22  }
    23  
    24  // DumpWalletCmd defines the dumpwallet JSON-RPC command.
    25  type DumpWalletCmd struct {
    26  	Filename string
    27  }
    28  
    29  // NewDumpWalletCmd returns a new instance which can be used to issue a
    30  // dumpwallet JSON-RPC command.
    31  func NewDumpWalletCmd(filename string) *DumpWalletCmd {
    32  	return &DumpWalletCmd{
    33  		Filename: filename,
    34  	}
    35  }
    36  
    37  // ImportAddressCmd defines the importaddress JSON-RPC command.
    38  type ImportAddressCmd struct {
    39  	Address string
    40  	Rescan  *bool `jsonrpcdefault:"true"`
    41  }
    42  
    43  // NewImportAddressCmd returns a new instance which can be used to issue an
    44  // importaddress JSON-RPC command.
    45  func NewImportAddressCmd(address string, rescan *bool) *ImportAddressCmd {
    46  	return &ImportAddressCmd{
    47  		Address: address,
    48  		Rescan:  rescan,
    49  	}
    50  }
    51  
    52  // ImportPubKeyCmd defines the importpubkey JSON-RPC command.
    53  type ImportPubKeyCmd struct {
    54  	PubKey string
    55  	Rescan *bool `jsonrpcdefault:"true"`
    56  }
    57  
    58  // NewImportPubKeyCmd returns a new instance which can be used to issue an
    59  // importpubkey JSON-RPC command.
    60  func NewImportPubKeyCmd(pubKey string, rescan *bool) *ImportPubKeyCmd {
    61  	return &ImportPubKeyCmd{
    62  		PubKey: pubKey,
    63  		Rescan: rescan,
    64  	}
    65  }
    66  
    67  // ImportWalletCmd defines the importwallet JSON-RPC command.
    68  type ImportWalletCmd struct {
    69  	Filename string
    70  }
    71  
    72  // NewImportWalletCmd returns a new instance which can be used to issue a
    73  // importwallet JSON-RPC command.
    74  func NewImportWalletCmd(filename string) *ImportWalletCmd {
    75  	return &ImportWalletCmd{
    76  		Filename: filename,
    77  	}
    78  }
    79  
    80  // RenameAccountCmd defines the renameaccount JSON-RPC command.
    81  type RenameAccountCmd struct {
    82  	OldAccount string
    83  	NewAccount string
    84  }
    85  
    86  // NewRenameAccountCmd returns a new instance which can be used to issue a
    87  // renameaccount JSON-RPC command.
    88  func NewRenameAccountCmd(oldAccount, newAccount string) *RenameAccountCmd {
    89  	return &RenameAccountCmd{
    90  		OldAccount: oldAccount,
    91  		NewAccount: newAccount,
    92  	}
    93  }
    94  
    95  func init() {
    96  	// The commands in this file are only usable with a wallet server.
    97  	flags := UFWalletOnly
    98  
    99  	MustRegisterCmd("createnewaccount", (*CreateNewAccountCmd)(nil), flags)
   100  	MustRegisterCmd("dumpwallet", (*DumpWalletCmd)(nil), flags)
   101  	MustRegisterCmd("importaddress", (*ImportAddressCmd)(nil), flags)
   102  	MustRegisterCmd("importpubkey", (*ImportPubKeyCmd)(nil), flags)
   103  	MustRegisterCmd("importwallet", (*ImportWalletCmd)(nil), flags)
   104  	MustRegisterCmd("renameaccount", (*RenameAccountCmd)(nil), flags)
   105  }