From ea7947f74e462c51b4095392e62644c055c4e1f3 Mon Sep 17 00:00:00 2001 From: David Hill Date: Sat, 12 Apr 2014 10:41:32 -0400 Subject: [PATCH] Add support for decodescript concrete result. --- jsonresults.go | 6 ++++++ jsonresults_test.go | 2 ++ test_coverage.txt | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jsonresults.go b/jsonresults.go index 25eefc79..26f41b88 100644 --- a/jsonresults.go +++ b/jsonresults.go @@ -350,6 +350,12 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) { if err == nil { result.Result = res } + case "decodescript": + var res DecodeScriptResult + err = json.Unmarshal(objmap["result"], &res) + if err == nil { + result.Result = res + } case "getaddednodeinfo": // getaddednodeinfo can either return a JSON object or a // slice of strings depending on the verbose flag. Choose the diff --git a/jsonresults_test.go b/jsonresults_test.go index 6d30fad0..de434589 100644 --- a/jsonresults_test.go +++ b/jsonresults_test.go @@ -28,6 +28,8 @@ var resulttests = []struct { {"anycommand", []byte(`{"error":null,"result":null,"id":"test"}`), false, true}, {"createmultisig", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"createmultisig", []byte(`{"error":null,"id":1,"result":{"address":"something","redeemScript":"else"}}`), false, true}, + {"decodescript", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"decodescript", []byte(`{"error":null,"id":1,"result":{"Asm":"something"}}`), false, true}, {"getinfo", []byte(`{"error":null,"result":null,"id":"test"}`), false, true}, {"getinfo", []byte(`{"error":null,"result":null}`), false, false}, {"getinfo", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, diff --git a/test_coverage.txt b/test_coverage.txt index 7e6c1d5d..8395c2a3 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -439,8 +439,8 @@ github.com/conformal/btcjson/jsoncmd.go NewAddNodeCmd 66.67% (2/3) github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.MarshalJSON 63.64% (7/11) github.com/conformal/btcjson/jsonfxns.go jsonRpcSend 62.50% (10/16) github.com/conformal/btcjson/jsonapi.go rpcCommand 61.54% (8/13) -github.com/conformal/btcjson/jsonresults.go ReadResultCmd 59.12% (81/137) github.com/conformal/btcjson/jsoncmd.go GetTxOutCmd.UnmarshalJSON 59.09% (13/22) +github.com/conformal/btcjson/jsonresults.go ReadResultCmd 58.62% (85/145) github.com/conformal/btcjson/jsoncmd.go LockUnspentCmd.UnmarshalJSON 57.89% (11/19) github.com/conformal/btcjson/jsonapi.go rpcRawCommand 53.33% (8/15) github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.UnmarshalJSON 50.00% (12/24) @@ -462,5 +462,5 @@ github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1) github.com/conformal/btcjson/jsonapi.go TlsRpcRawCommand 0.00% (0/1) github.com/conformal/btcjson/jsonapi.go RpcRawCommand 0.00% (0/1) github.com/conformal/btcjson/jsonresults.go Vin.IsCoinBase 0.00% (0/1) -github.com/conformal/btcjson --------------------------------------- 78.56% (2345/2985) +github.com/conformal/btcjson --------------------------------------- 78.48% (2349/2993)