Properly set reply.Result to output of unmarshalled GetTxOutResult JSON.

Fix panic caused by nil pointer dereference.

Create new error type for invalid tx vout (gettxout).
This commit is contained in:
Olaoluwa Osuntokun 2014-07-06 11:51:13 -07:00 committed by John C. Vernaleo
parent 8005d2e455
commit 033b00dd1c
2 changed files with 6 additions and 2 deletions

View file

@ -148,6 +148,10 @@ var (
Code: -5,
Message: "No information about newest block",
}
ErrInvalidTxVout = Error{
Code: -5,
Message: "Ouput index number (vout) does not exist for transaction.",
}
ErrRawTxString = Error{
Code: -32602,
Message: "Raw tx is not a string",

View file

@ -607,11 +607,11 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
case "gettxout":
var res *GetTxOutResult
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
if res != nil && err == nil {
if res.ScriptPubKey.Addresses == nil {
res.ScriptPubKey.Addresses = []string{}
}
result.Result = true
result.Result = res
}
case "getwork":
// getwork can either return a JSON object or a boolean