github.com/btcsuite/btcd@v0.24.0/btcjson/btcwalletextcmds.go (about)

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