Return pointer to TxRawResult and use bytes.IndexByte instead of Strings.Contains

This commit is contained in:
GeertJohan 2014-05-04 17:12:32 +02:00
parent 4202bf2e93
commit 4fb5272063

View file

@ -5,6 +5,7 @@
package btcjson package btcjson
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strings" "strings"
@ -426,12 +427,12 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
case "getrawtransaction": case "getrawtransaction":
// getrawtransaction can either return a JSON object or a // getrawtransaction can either return a JSON object or a
// hex-encoded string depending on the verbose flag. Choose the // hex-encoded string depending on the verbose flag. Choose the
// right form accordingly. // right form accordingly.=
if strings.Contains(string(objmap["result"]), "{") { if bytes.IndexByte(objmap["result"], '{') > -1 {
var res TxRawResult var res TxRawResult
err = json.Unmarshal(objmap["result"], &res) err = json.Unmarshal(objmap["result"], &res)
if err == nil { if err == nil {
result.Result = res result.Result = &res
} }
} else { } else {
var res string var res string