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