Remove parameters for createencryptedwallet.

The createencryptedwallet extension RPC request should not be used to
create wallets for additional accounts.  Instead, all btcwallet
accounts should use the same passphrase as the default account's
wallet.  This change removes the account name and description
parameters from createencryptedwallet, as it will only be used to
create the default account.
This commit is contained in:
Josh Rickmar 2014-01-24 11:14:44 -05:00
parent 0f7f080f19
commit 50a1c37317
2 changed files with 12 additions and 36 deletions

32
cmds.go
View file

@ -1008,8 +1008,6 @@ func (cmd *NotifySpentCmd) UnmarshalJSON(b []byte) error {
// JSON websocket extension commands.
type CreateEncryptedWalletCmd struct {
id interface{}
Account string
Description string
Passphrase string
}
@ -1018,13 +1016,9 @@ type CreateEncryptedWalletCmd struct {
var _ btcjson.Cmd = &CreateEncryptedWalletCmd{}
// NewCreateEncryptedWalletCmd creates a new CreateEncryptedWalletCmd.
func NewCreateEncryptedWalletCmd(id interface{},
account, description, passphrase string) *CreateEncryptedWalletCmd {
func NewCreateEncryptedWalletCmd(id interface{}, passphrase string) *CreateEncryptedWalletCmd {
return &CreateEncryptedWalletCmd{
id: id,
Account: account,
Description: description,
Passphrase: passphrase,
}
}
@ -1034,26 +1028,16 @@ func NewCreateEncryptedWalletCmd(id interface{},
// This is used when registering the custom command with the btcjson
// parser.
func parseCreateEncryptedWalletCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
if len(r.Params) != 3 {
if len(r.Params) != 1 {
return nil, btcjson.ErrWrongNumberOfParams
}
account, ok := r.Params[0].(string)
passphrase, ok := r.Params[0].(string)
if !ok {
return nil, errors.New("first parameter must be a string")
}
description, ok := r.Params[1].(string)
if !ok {
return nil, errors.New("second parameter is not a string")
}
passphrase, ok := r.Params[2].(string)
if !ok {
return nil, errors.New("third parameter is not a string")
return nil, errors.New("first parameter is not a string")
}
cmd := NewCreateEncryptedWalletCmd(r.Id, account, description,
passphrase)
return cmd, nil
return NewCreateEncryptedWalletCmd(r.Id, passphrase), nil
}
// Id satisifies the Cmd interface by returning the ID of the command.
@ -1078,11 +1062,7 @@ func (cmd *CreateEncryptedWalletCmd) MarshalJSON() ([]byte, error) {
Jsonrpc: "1.0",
Method: "createencryptedwallet",
Id: cmd.id,
Params: []interface{}{
cmd.Account,
cmd.Description,
cmd.Passphrase,
},
Params: []interface{}{cmd.Passphrase},
}
return json.Marshal(raw)

View file

@ -24,14 +24,10 @@ var cmdtests = []struct {
f: func() (btcjson.Cmd, error) {
return NewCreateEncryptedWalletCmd(
float64(1),
"abcde",
"description",
"banana"), nil
},
result: &CreateEncryptedWalletCmd{
id: float64(1),
Account: "abcde",
Description: "description",
Passphrase: "banana",
},
},