Return errors for getaddressesbyaccount command
This commit is contained in:
parent
7e3edab24b
commit
f14d2edbff
1 changed files with 15 additions and 3 deletions
18
cmdmgr.go
18
cmdmgr.go
|
@ -235,22 +235,34 @@ func ReplySuccess(reply chan []byte, id interface{}, result interface{}) {
|
|||
|
||||
// GetAddressesByAccount replies with all addresses for an account.
|
||||
func GetAddressesByAccount(reply chan []byte, msg *btcjson.Message) {
|
||||
e := InvalidParams
|
||||
|
||||
// TODO(jrick): check if we can make btcjson.Message.Params
|
||||
// a []interface{} to avoid this.
|
||||
params, ok := msg.Params.([]interface{})
|
||||
if !ok {
|
||||
log.Error("GetAddressesByAccount: Cannot parse parameters.")
|
||||
ReplyError(reply, msg.Id, &e)
|
||||
return
|
||||
}
|
||||
account, ok := params[0].(string)
|
||||
if !ok {
|
||||
e.Message = "account is not a string"
|
||||
ReplyError(reply, msg.Id, &e)
|
||||
return
|
||||
}
|
||||
|
||||
var result interface{}
|
||||
wallets.RLock()
|
||||
w := wallets.m[params[0].(string)]
|
||||
w := wallets.m[account]
|
||||
wallets.RUnlock()
|
||||
|
||||
if w != nil {
|
||||
result = w.Wallet.GetActiveAddresses()
|
||||
} else {
|
||||
result = []interface{}{}
|
||||
ReplyError(reply, msg.Id, &WalletInvalidAccountName)
|
||||
return
|
||||
}
|
||||
|
||||
ReplySuccess(reply, msg.Id, result)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue