Allow getaddednodeinfo result to be string slice.
The getaddednode command dns flag alters the output. It is a JSON object when true and a slice of strings containing the addresses when false. Note there is a bug in bitcoind as of version 0.8.6 which returns the addresses as a JSON object with duplicate keys. This has been reported as issue 3581 on the bitcoind issue tracker. This commit allows the result for getaddednodeinfo to be either the JSON object or the string slice.
This commit is contained in:
parent
421f4c54a0
commit
6e2fa5aad7
1 changed files with 9 additions and 1 deletions
10
jsonapi.go
10
jsonapi.go
|
@ -837,7 +837,15 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
|
|||
// We handle the error condition after the switch statement.
|
||||
switch cmd {
|
||||
case "getaddednodeinfo":
|
||||
var res []GetAddedNodeInfoResult
|
||||
// getaddednodeinfo can either return a JSON object or a
|
||||
// slice of strings depending on the verbose flag. Choose the
|
||||
// right form accordingly.
|
||||
var res interface{}
|
||||
if strings.Contains(string(objmap["result"]), "{") {
|
||||
res = []GetAddedNodeInfoResult{}
|
||||
} else {
|
||||
res = []string{}
|
||||
}
|
||||
err = json.Unmarshal(objmap["result"], &res)
|
||||
if err == nil {
|
||||
result.Result = res
|
||||
|
|
Loading…
Reference in a new issue