From 372e8c19262441519620cf341317fc195090e769 Mon Sep 17 00:00:00 2001 From: David Hill Date: Fri, 11 Apr 2014 20:17:21 -0400 Subject: [PATCH] Add support for ListSinceBlockResult ok @davecgh --- jsonresults.go | 15 +++++++++++++++ jsonresults_test.go | 2 ++ test_coverage.txt | 6 +++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/jsonresults.go b/jsonresults.go index df2e086f..5aaf31d0 100644 --- a/jsonresults.go +++ b/jsonresults.go @@ -279,6 +279,12 @@ type SignRawTransactionResult struct { Complete bool `json:"complete"` } +// ListSinceBlockResult models the data from the listsinceblock command. +type ListSinceBlockResult struct { + Transactions []ListTransactionsResult `json:"transactions"` + LastBlock string `json:"lastblock"` +} + // ListUnSpentResult models the data from the ListUnSpentResult command. type ListUnSpentResult struct { TxId string `json:"txid"` @@ -489,6 +495,15 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) { if err == nil { result.Result = res } + case "listsinceblock": + var res ListSinceBlockResult + err = json.Unmarshal(objmap["result"], &res) + if err == nil { + if res.Transactions == nil { + res.Transactions = []ListTransactionsResult{} + } + result.Result = res + } case "listtransactions": var res []ListTransactionsResult err = json.Unmarshal(objmap["result"], &res) diff --git a/jsonresults_test.go b/jsonresults_test.go index adbfc11b..6d30fad0 100644 --- a/jsonresults_test.go +++ b/jsonresults_test.go @@ -43,6 +43,8 @@ var resulttests = []struct { {"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":["test"]}`), false, true}, {"getmininginfo", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"getmininginfo", []byte(`{"error":null,"id":1,"result":{"generate":true}}`), false, true}, + {"listsinceblock", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"listsinceblock", []byte(`{"error":null,"id":1,"result":{"lastblock":"something"}}`), false, true}, {"validateaddress", []byte(`{"error":null,"id":1,"result":{"isvalid":false}}`), false, true}, {"validateaddress", []byte(`{"error":null,"id":1,"result":{false}}`), false, false}, {"signrawtransaction", []byte(`{"error":null,"id":1,"result":{"hex":"something","complete":false}}`), false, true}, diff --git a/test_coverage.txt b/test_coverage.txt index 4ed5f54e..7e6c1d5d 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -436,12 +436,12 @@ github.com/conformal/btcjson/jsoncmd.go VerifyMessageCmd.UnmarshalJSON 68.42 github.com/conformal/btcjson/jsoncmd.go SignRawTransactionCmd.MarshalJSON 66.67% (8/12) github.com/conformal/btcjson/jsoncmd.go NewLockUnspentCmd 66.67% (4/6) 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/jsoncmd.go GetBlockCmd.MarshalJSON 60.00% (6/10) +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/jsoncmd.go LockUnspentCmd.UnmarshalJSON 57.89% (11/19) -github.com/conformal/btcjson/jsonresults.go ReadResultCmd 57.25% (75/131) github.com/conformal/btcjson/jsonapi.go rpcRawCommand 53.33% (8/15) github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.UnmarshalJSON 50.00% (12/24) github.com/conformal/btcjson/cmdhelp.go GetHelpString 50.00% (3/6) @@ -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.51% (2338/2978) +github.com/conformal/btcjson --------------------------------------- 78.56% (2345/2985)