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

View file

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