Use ReplySuccess() to send successful JSON replies
This commit is contained in:
parent
8f38a43964
commit
b0f6a70d40
1 changed files with 7 additions and 24 deletions
29
cmdmgr.go
29
cmdmgr.go
|
@ -211,21 +211,14 @@ func GetAddressesByAccount(reply chan []byte, msg []byte) {
|
||||||
var v map[string]interface{}
|
var v map[string]interface{}
|
||||||
json.Unmarshal(msg, &v)
|
json.Unmarshal(msg, &v)
|
||||||
params := v["params"].([]interface{})
|
params := v["params"].([]interface{})
|
||||||
id := v["id"]
|
|
||||||
r := btcjson.Reply{
|
var result interface{}
|
||||||
Id: &id,
|
|
||||||
}
|
|
||||||
if w := wallets[params[0].(string)]; w != nil {
|
if w := wallets[params[0].(string)]; w != nil {
|
||||||
r.Result = w.GetActiveAddresses()
|
result = w.GetActiveAddresses()
|
||||||
} else {
|
} else {
|
||||||
r.Result = []interface{}{}
|
result = []interface{}{}
|
||||||
}
|
}
|
||||||
mr, err := json.Marshal(r)
|
ReplySuccess(reply, v["id"], result)
|
||||||
if err != nil {
|
|
||||||
log.Info("Error marshalling reply: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reply <- mr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNewAddress gets or generates a new address for an account.
|
// GetNewAddress gets or generates a new address for an account.
|
||||||
|
@ -238,17 +231,7 @@ func GetNewAddress(reply chan []byte, msg []byte) {
|
||||||
if len(params) == 0 || params[0].(string) == "" {
|
if len(params) == 0 || params[0].(string) == "" {
|
||||||
if w := wallets[""]; w != nil {
|
if w := wallets[""]; w != nil {
|
||||||
addr := w.NextUnusedAddress()
|
addr := w.NextUnusedAddress()
|
||||||
id := v["id"]
|
ReplySuccess(reply, v["id"], addr)
|
||||||
r := btcjson.Reply{
|
|
||||||
Result: addr,
|
|
||||||
Id: &id,
|
|
||||||
}
|
|
||||||
mr, err := json.Marshal(r)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("Error marshalling reply: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reply <- mr
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue