Return pointer to TxRawResult and use bytes.IndexByte instead of Strings.Contains
This commit is contained in:
parent
4202bf2e93
commit
4fb5272063
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue