diff --git a/jsonapi.go b/jsonapi.go index b570a1fb..dc263328 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -67,6 +67,12 @@ type BlockResult struct { NextHash string `json:"nextblockhash"` } +// CreateMultiSigResult models the data returned from the createmultisig command. +type CreateMultiSigResult struct { + Address string `json:"address"` + RedeemScript string `json:"redeemScript"` +} + // DecodeScriptResult models the data returned from the decodescript command. type DecodeScriptResult struct { Asm string `json:"asm"` @@ -904,6 +910,12 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) { // generate put the results in the proper structure. // We handle the error condition after the switch statement. switch cmd { + case "createmultisig": + var res CreateMultiSigResult + 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/jsonapi_test.go b/jsonapi_test.go index 98ec517e..a78cbe60 100644 --- a/jsonapi_test.go +++ b/jsonapi_test.go @@ -25,6 +25,8 @@ var cmdtests = []struct { args []interface{} pass bool }{ + {"createmultisig", nil, false}, + {"createmultisig", []interface{}{1}, false}, {"getinfo", nil, true}, {"getinfo", []interface{}{1}, false}, {"listaccounts", nil, true}, @@ -333,6 +335,8 @@ var resulttests = []struct { {"anycommand", []byte(`{"result":"test","id":1}`), false, false}, {"anycommand", []byte(`{some junk}`), false, false}, {"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}, {"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 9e2da715..76280274 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -334,59 +334,59 @@ github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 96.18% (327/340) github.com/conformal/btcjson/jsoncmd.go ParseMarshaledCmd 89.77% (79/88) github.com/conformal/btcjson/jsoncmd.go NewGetNetworkHashPSCmd 88.89% (8/9) github.com/conformal/btcjson/jsoncmd.go NewVerifyChainCmd 88.89% (8/9) -github.com/conformal/btcjson/jsoncmd.go NewGetReceivedByAddressCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewAddMultisigAddressCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewGetNewAddressCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewGetAddedNodeInfoCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewGetTxOutCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewKeyPoolRefillCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewSendRawTransactionCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewHelpCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewGetNewAddressCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewGetRawChangeAddressCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewGetBlockTemplateCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewListAccountsCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewSetGenerateCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewSubmitBlockCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewGetRawTransactionCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewGetReceivedByAccountCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewGetBlockTemplateCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewGetRawMempoolCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewHelpCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewSetGenerateCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewSendRawTransactionCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewGetReceivedByAddressCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewGetRawTransactionCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewKeyPoolRefillCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewListAccountsCmd 83.33% (5/6) +github.com/conformal/btcjson/jsoncmd.go NewSubmitBlockCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewGetWorkCmd 83.33% (5/6) -github.com/conformal/btcjson/jsoncmd.go NewListUnspentCmd 80.95% (17/21) +github.com/conformal/btcjson/jsoncmd.go NewGetRawChangeAddressCmd 83.33% (5/6) github.com/conformal/btcjson/jsoncmd.go NewSendFromCmd 80.95% (17/21) github.com/conformal/btcjson/jsoncmd.go NewListTransactionsCmd 80.95% (17/21) -github.com/conformal/btcjson/jsoncmd.go NewListReceivedByAccountCmd 80.00% (12/15) +github.com/conformal/btcjson/jsoncmd.go NewListUnspentCmd 80.95% (17/21) +github.com/conformal/btcjson/jsoncmd.go NewMoveCmd 80.00% (12/15) +github.com/conformal/btcjson/jsoncmd.go NewSendToAddressCmd 80.00% (12/15) github.com/conformal/btcjson/jsoncmd.go NewSendManyCmd 80.00% (12/15) github.com/conformal/btcjson/jsoncmd.go NewGetBalanceCmd 80.00% (12/15) -github.com/conformal/btcjson/jsoncmd.go NewMoveCmd 80.00% (12/15) -github.com/conformal/btcjson/jsoncmd.go NewListSinceBlockCmd 80.00% (12/15) github.com/conformal/btcjson/jsoncmd.go NewListReceivedByAddressCmd 80.00% (12/15) -github.com/conformal/btcjson/jsoncmd.go NewSendToAddressCmd 80.00% (12/15) +github.com/conformal/btcjson/jsoncmd.go NewListReceivedByAccountCmd 80.00% (12/15) +github.com/conformal/btcjson/jsoncmd.go NewListSinceBlockCmd 80.00% (12/15) github.com/conformal/btcjson/jsoncmd.go GetBlockTemplateCmd.UnmarshalJSON 79.41% (27/34) github.com/conformal/btcjson/jsoncmd.go NewImportPrivKeyCmd 78.57% (11/14) github.com/conformal/btcjson/jsoncmd.go ListUnspentCmd.UnmarshalJSON 77.42% (24/31) github.com/conformal/btcjson/jsoncmd.go ListTransactionsCmd.UnmarshalJSON 76.92% (20/26) github.com/conformal/btcjson/jsoncmd.go SubmitBlockCmd.UnmarshalJSON 76.92% (20/26) -github.com/conformal/btcjson/jsoncmd.go ListReceivedByAddressCmd.UnmarshalJSON 76.19% (16/21) -github.com/conformal/btcjson/jsoncmd.go GetBalanceCmd.UnmarshalJSON 76.19% (16/21) -github.com/conformal/btcjson/jsoncmd.go GetNetworkHashPSCmd.UnmarshalJSON 76.19% (16/21) -github.com/conformal/btcjson/jsoncmd.go VerifyChainCmd.UnmarshalJSON 76.19% (16/21) -github.com/conformal/btcjson/jsoncmd.go ListReceivedByAccountCmd.UnmarshalJSON 76.19% (16/21) github.com/conformal/btcjson/jsoncmd.go ListSinceBlockCmd.UnmarshalJSON 76.19% (16/21) +github.com/conformal/btcjson/jsoncmd.go GetBalanceCmd.UnmarshalJSON 76.19% (16/21) +github.com/conformal/btcjson/jsoncmd.go ListReceivedByAddressCmd.UnmarshalJSON 76.19% (16/21) +github.com/conformal/btcjson/jsoncmd.go VerifyChainCmd.UnmarshalJSON 76.19% (16/21) +github.com/conformal/btcjson/jsoncmd.go GetNetworkHashPSCmd.UnmarshalJSON 76.19% (16/21) +github.com/conformal/btcjson/jsoncmd.go ListReceivedByAccountCmd.UnmarshalJSON 76.19% (16/21) github.com/conformal/btcjson/jsoncmd.go SendManyCmd.UnmarshalJSON 75.00% (27/36) github.com/conformal/btcjson/jsoncmd.go ImportPrivKeyCmd.UnmarshalJSON 75.00% (18/24) -github.com/conformal/btcjson/jsoncmd.go GetNewAddressCmd.UnmarshalJSON 75.00% (12/16) github.com/conformal/btcjson/jsoncmd.go GetWorkCmd.UnmarshalJSON 75.00% (12/16) +github.com/conformal/btcjson/jsoncmd.go HelpCmd.UnmarshalJSON 75.00% (12/16) +github.com/conformal/btcjson/jsoncmd.go GetNewAddressCmd.UnmarshalJSON 75.00% (12/16) github.com/conformal/btcjson/jsoncmd.go KeyPoolRefillCmd.UnmarshalJSON 75.00% (12/16) +github.com/conformal/btcjson/jsoncmd.go ListAccountsCmd.UnmarshalJSON 75.00% (12/16) github.com/conformal/btcjson/jsoncmd.go GetRawChangeAddressCmd.UnmarshalJSON 75.00% (12/16) github.com/conformal/btcjson/jsoncmd.go GetRawMempoolCmd.UnmarshalJSON 75.00% (12/16) -github.com/conformal/btcjson/jsoncmd.go HelpCmd.UnmarshalJSON 75.00% (12/16) -github.com/conformal/btcjson/jsoncmd.go ListAccountsCmd.UnmarshalJSON 75.00% (12/16) github.com/conformal/btcjson/jsoncmd.go GetTxOutCmd.MarshalJSON 75.00% (3/4) github.com/conformal/btcjson/jsoncmd.go LockUnspentCmd.MarshalJSON 75.00% (3/4) github.com/conformal/btcjson/jsoncmd.go SendFromCmd.UnmarshalJSON 73.68% (28/38) -github.com/conformal/btcjson/jsoncmd.go GetRawTransactionCmd.UnmarshalJSON 73.68% (14/19) -github.com/conformal/btcjson/jsoncmd.go SendRawTransactionCmd.UnmarshalJSON 73.68% (14/19) github.com/conformal/btcjson/jsoncmd.go SetGenerateCmd.UnmarshalJSON 73.68% (14/19) +github.com/conformal/btcjson/jsoncmd.go SendRawTransactionCmd.UnmarshalJSON 73.68% (14/19) +github.com/conformal/btcjson/jsoncmd.go GetRawTransactionCmd.UnmarshalJSON 73.68% (14/19) github.com/conformal/btcjson/jsoncmd.go GetReceivedByAccountCmd.UnmarshalJSON 73.68% (14/19) github.com/conformal/btcjson/jsoncmd.go GetReceivedByAddressCmd.UnmarshalJSON 73.68% (14/19) github.com/conformal/btcjson/jsoncmd.go SendToAddressCmd.UnmarshalJSON 73.33% (22/30) @@ -395,20 +395,20 @@ github.com/conformal/btcjson/jsoncmd.go MoveCmd.UnmarshalJSON 72.73% (24/33) github.com/conformal/btcjson/jsoncmd.go ConvertCreateRawTxParams 72.22% (26/36) github.com/conformal/btcjson/jsoncmd.go GetAddedNodeInfoCmd.UnmarshalJSON 72.22% (13/18) github.com/conformal/btcjson/jsoncmd.go CreateMultisigCmd.UnmarshalJSON 71.43% (15/21) -github.com/conformal/btcjson/jsoncmd.go ListAddressGroupingsCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go GetNetTotalsCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetMiningInfoCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go ListLockUnspentCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go GetBlockCountCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go PingCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetHashesPerSecCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go WalletLockCmd.UnmarshalJSON 70.00% (7/10) -github.com/conformal/btcjson/jsoncmd.go PingCmd.UnmarshalJSON 70.00% (7/10) -github.com/conformal/btcjson/jsoncmd.go GetTxOutSetInfoCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go StopCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetGenerateCmd.UnmarshalJSON 70.00% (7/10) -github.com/conformal/btcjson/jsoncmd.go GetNetTotalsCmd.UnmarshalJSON 70.00% (7/10) -github.com/conformal/btcjson/jsoncmd.go GetBlockCountCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go GetTxOutSetInfoCmd.UnmarshalJSON 70.00% (7/10) +github.com/conformal/btcjson/jsoncmd.go ListAddressGroupingsCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetDifficultyCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetPeerInfoCmd.UnmarshalJSON 70.00% (7/10) -github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetBestBlockHashCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go GetConnectionCountCmd.UnmarshalJSON 70.00% (7/10) github.com/conformal/btcjson/jsoncmd.go DecodeScriptCmd.UnmarshalJSON 69.23% (9/13) @@ -416,22 +416,22 @@ github.com/conformal/btcjson/jsoncmd.go BackupWalletCmd.UnmarshalJSON 69.23% github.com/conformal/btcjson/jsoncmd.go DebugLevelCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go DecodeRawTransactionCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go ValidateAddressCmd.UnmarshalJSON 69.23% (9/13) -github.com/conformal/btcjson/jsoncmd.go GetAccountAddressCmd.UnmarshalJSON 69.23% (9/13) +github.com/conformal/btcjson/jsoncmd.go GetAddressesByAccountCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go ImportWalletCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go DumpPrivKeyCmd.UnmarshalJSON 69.23% (9/13) +github.com/conformal/btcjson/jsoncmd.go GetAccountAddressCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go DumpWalletCmd.UnmarshalJSON 69.23% (9/13) -github.com/conformal/btcjson/jsoncmd.go GetAddressesByAccountCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go GetBlockHashCmd.UnmarshalJSON 69.23% (9/13) -github.com/conformal/btcjson/jsoncmd.go GetTransactionCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go EncryptWalletCmd.UnmarshalJSON 69.23% (9/13) +github.com/conformal/btcjson/jsoncmd.go GetTransactionCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go GetAccountCmd.UnmarshalJSON 69.23% (9/13) github.com/conformal/btcjson/jsoncmd.go CreateRawTransactionCmd.UnmarshalJSON 69.23% (9/13) -github.com/conformal/btcjson/jsoncmd.go WalletPassphraseCmd.UnmarshalJSON 68.75% (11/16) -github.com/conformal/btcjson/jsoncmd.go SetAccountCmd.UnmarshalJSON 68.75% (11/16) github.com/conformal/btcjson/jsoncmd.go WalletPassphraseChangeCmd.UnmarshalJSON 68.75% (11/16) +github.com/conformal/btcjson/jsoncmd.go WalletPassphraseCmd.UnmarshalJSON 68.75% (11/16) +github.com/conformal/btcjson/jsoncmd.go SetTxFeeCmd.UnmarshalJSON 68.75% (11/16) github.com/conformal/btcjson/jsoncmd.go SignMessageCmd.UnmarshalJSON 68.75% (11/16) github.com/conformal/btcjson/jsoncmd.go AddNodeCmd.UnmarshalJSON 68.75% (11/16) -github.com/conformal/btcjson/jsoncmd.go SetTxFeeCmd.UnmarshalJSON 68.75% (11/16) +github.com/conformal/btcjson/jsoncmd.go SetAccountCmd.UnmarshalJSON 68.75% (11/16) github.com/conformal/btcjson/jsoncmd.go VerifyMessageCmd.UnmarshalJSON 68.42% (13/19) github.com/conformal/btcjson/jsoncmd.go NewLockUnspentCmd 66.67% (4/6) github.com/conformal/btcjson/jsoncmd.go NewAddNodeCmd 66.67% (2/3) @@ -439,8 +439,8 @@ github.com/conformal/btcjson/jsonfxns.go jsonRpcSend 62.50% (10/16) github.com/conformal/btcjson/jsoncmd.go SignRawTransactionCmd.MarshalJSON 62.50% (5/8) github.com/conformal/btcjson/jsonapi.go rpcCommand 61.54% (8/13) github.com/conformal/btcjson/jsoncmd.go GetTxOutCmd.UnmarshalJSON 59.09% (13/22) +github.com/conformal/btcjson/jsonapi.go ReadResultCmd 57.38% (70/122) github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.MarshalJSON 57.14% (4/7) -github.com/conformal/btcjson/jsonapi.go ReadResultCmd 55.93% (66/118) 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) @@ -453,13 +453,13 @@ github.com/conformal/btcjson/jsonapi.go Vin.MarshalJSON 0.00% (0/5) github.com/conformal/btcjson/jsoncmd.go unparsableCmd.MarshalJSON 0.00% (0/2) github.com/conformal/btcjson/jsonapi.go TlsRpcCommand 0.00% (0/1) github.com/conformal/btcjson/jsoncmd.go newUnparsableCmd 0.00% (0/1) -github.com/conformal/btcjson/jsoncmd.go RegisterCustomCmd 0.00% (0/1) github.com/conformal/btcjson/jsoncmd.go RegisterCustomCmdGenerator 0.00% (0/1) +github.com/conformal/btcjson/jsonapi.go RpcRawCommand 0.00% (0/1) github.com/conformal/btcjson/jsonapi.go TlsRpcRawCommand 0.00% (0/1) github.com/conformal/btcjson/jsonapi.go Vin.IsCoinBase 0.00% (0/1) -github.com/conformal/btcjson/jsonapi.go RpcRawCommand 0.00% (0/1) github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Id 0.00% (0/1) -github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1) +github.com/conformal/btcjson/jsoncmd.go RegisterCustomCmd 0.00% (0/1) github.com/conformal/btcjson/jsoncmd.go unparsableCmd.SetId 0.00% (0/1) -github.com/conformal/btcjson --------------------------------------- 78.08% (2205/2824) +github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1) +github.com/conformal/btcjson --------------------------------------- 78.11% (2209/2828)