/ vendor / github.com / btcsuite / btcd / btcjson / btcwalletextcmds.go
btcwalletextcmds.go
  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  	Rescan  *bool `jsonrpcdefault:"true"`
 40  }
 41  
 42  // NewImportAddressCmd returns a new instance which can be used to issue an
 43  // importaddress JSON-RPC command.
 44  func NewImportAddressCmd(address string, rescan *bool) *ImportAddressCmd {
 45  	return &ImportAddressCmd{
 46  		Address: address,
 47  		Rescan:  rescan,
 48  	}
 49  }
 50  
 51  // ImportPubKeyCmd defines the importpubkey JSON-RPC command.
 52  type ImportPubKeyCmd struct {
 53  	PubKey string
 54  	Rescan *bool `jsonrpcdefault:"true"`
 55  }
 56  
 57  // NewImportPubKeyCmd returns a new instance which can be used to issue an
 58  // importpubkey JSON-RPC command.
 59  func NewImportPubKeyCmd(pubKey string, rescan *bool) *ImportPubKeyCmd {
 60  	return &ImportPubKeyCmd{
 61  		PubKey: pubKey,
 62  		Rescan: rescan,
 63  	}
 64  }
 65  
 66  // ImportWalletCmd defines the importwallet JSON-RPC command.
 67  type ImportWalletCmd struct {
 68  	Filename string
 69  }
 70  
 71  // NewImportWalletCmd returns a new instance which can be used to issue a
 72  // importwallet JSON-RPC command.
 73  func NewImportWalletCmd(filename string) *ImportWalletCmd {
 74  	return &ImportWalletCmd{
 75  		Filename: filename,
 76  	}
 77  }
 78  
 79  // RenameAccountCmd defines the renameaccount JSON-RPC command.
 80  type RenameAccountCmd struct {
 81  	OldAccount string
 82  	NewAccount string
 83  }
 84  
 85  // NewRenameAccountCmd returns a new instance which can be used to issue a
 86  // renameaccount JSON-RPC command.
 87  func NewRenameAccountCmd(oldAccount, newAccount string) *RenameAccountCmd {
 88  	return &RenameAccountCmd{
 89  		OldAccount: oldAccount,
 90  		NewAccount: newAccount,
 91  	}
 92  }
 93  
 94  func init() {
 95  	// The commands in this file are only usable with a wallet server.
 96  	flags := UFWalletOnly
 97  
 98  	MustRegisterCmd("createnewaccount", (*CreateNewAccountCmd)(nil), flags)
 99  	MustRegisterCmd("dumpwallet", (*DumpWalletCmd)(nil), flags)
100  	MustRegisterCmd("importaddress", (*ImportAddressCmd)(nil), flags)
101  	MustRegisterCmd("importpubkey", (*ImportPubKeyCmd)(nil), flags)
102  	MustRegisterCmd("importwallet", (*ImportWalletCmd)(nil), flags)
103  	MustRegisterCmd("renameaccount", (*RenameAccountCmd)(nil), flags)
104  }