Always return unparsableCmds when possible.
This change overrides the cmd return value of custom registered methods to always return an unparsableCmd if the marshaling as a JSON-RPC request succeeded, but the request was an invalid structure for the custom method.
This commit is contained in:
parent
4595c9d90d
commit
3fd5904859
2 changed files with 18 additions and 13 deletions
|
@ -324,7 +324,12 @@ func ParseMarshaledCmd(b []byte) (Cmd, error) {
|
||||||
// None of the standard Bitcoin RPC methods matched. Try
|
// None of the standard Bitcoin RPC methods matched. Try
|
||||||
// registered custom commands.
|
// registered custom commands.
|
||||||
if c, ok := customCmds[r.Method]; ok {
|
if c, ok := customCmds[r.Method]; ok {
|
||||||
return c.parser(&r)
|
cmd, err := c.parser(&r)
|
||||||
|
if err != nil {
|
||||||
|
cmd = newUnparsableCmd(r.Id, r.Method)
|
||||||
|
return cmd, err
|
||||||
|
}
|
||||||
|
return cmd, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,39 +263,39 @@ github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.Id 100.00% (1/1)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.SetId 100.00% (1/1)
|
github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.SetId 100.00% (1/1)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.Method 100.00% (1/1)
|
github.com/conformal/btcjson/jsoncmd.go GetInfoCmd.Method 100.00% (1/1)
|
||||||
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 96.18% (327/340)
|
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 96.18% (327/340)
|
||||||
github.com/conformal/btcjson/jsoncmd.go SendManyCmd.MarshalJSON 92.86% (13/14)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go SendFromCmd.MarshalJSON 92.86% (13/14)
|
github.com/conformal/btcjson/jsoncmd.go SendFromCmd.MarshalJSON 92.86% (13/14)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ParseMarshaledCmd 91.86% (79/86)
|
github.com/conformal/btcjson/jsoncmd.go SendManyCmd.MarshalJSON 92.86% (13/14)
|
||||||
github.com/conformal/btcjson/jsoncmd.go MoveCmd.MarshalJSON 91.67% (11/12)
|
github.com/conformal/btcjson/jsoncmd.go MoveCmd.MarshalJSON 91.67% (11/12)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListTransactionsCmd.MarshalJSON 90.91% (10/11)
|
github.com/conformal/btcjson/jsoncmd.go ListTransactionsCmd.MarshalJSON 90.91% (10/11)
|
||||||
github.com/conformal/btcjson/jsoncmd.go SendToAddressCmd.MarshalJSON 90.91% (10/11)
|
github.com/conformal/btcjson/jsoncmd.go SendToAddressCmd.MarshalJSON 90.91% (10/11)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListUnspentCmd.MarshalJSON 90.91% (10/11)
|
github.com/conformal/btcjson/jsoncmd.go ListUnspentCmd.MarshalJSON 90.91% (10/11)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ImportPrivKeyCmd.MarshalJSON 90.00% (9/10)
|
github.com/conformal/btcjson/jsoncmd.go ImportPrivKeyCmd.MarshalJSON 90.00% (9/10)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListReceivedByAddressCmd.MarshalJSON 88.89% (8/9)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go VerifyChainCmd.MarshalJSON 88.89% (8/9)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetBalanceCmd.MarshalJSON 88.89% (8/9)
|
github.com/conformal/btcjson/jsoncmd.go GetBalanceCmd.MarshalJSON 88.89% (8/9)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListSinceBlockCmd.MarshalJSON 88.89% (8/9)
|
github.com/conformal/btcjson/jsoncmd.go ListReceivedByAccountCmd.MarshalJSON 88.89% (8/9)
|
||||||
|
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 NewVerifyChainCmd 88.89% (8/9)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go VerifyChainCmd.MarshalJSON 88.89% (8/9)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go ListSinceBlockCmd.MarshalJSON 88.89% (8/9)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go ListReceivedByAddressCmd.MarshalJSON 88.89% (8/9)
|
||||||
github.com/conformal/btcjson/jsoncmd.go AddMultisigAddressCmd.MarshalJSON 88.89% (8/9)
|
github.com/conformal/btcjson/jsoncmd.go AddMultisigAddressCmd.MarshalJSON 88.89% (8/9)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetNetworkHashPSCmd.MarshalJSON 88.89% (8/9)
|
github.com/conformal/btcjson/jsoncmd.go GetNetworkHashPSCmd.MarshalJSON 88.89% (8/9)
|
||||||
github.com/conformal/btcjson/jsoncmd.go NewGetNetworkHashPSCmd 88.89% (8/9)
|
github.com/conformal/btcjson/jsoncmd.go ParseMarshaledCmd 87.78% (79/90)
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListReceivedByAccountCmd.MarshalJSON 88.89% (8/9)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetReceivedByAccountCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go GetReceivedByAccountCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go SubmitBlockCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go SubmitBlockCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetReceivedByAddressCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go GetReceivedByAddressCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go SetGenerateCmd.MarshalJSON 87.50% (7/8)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go GetRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go CreateRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go CreateRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go NewRawCmd 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go NewRawCmd 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go SendRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
github.com/conformal/btcjson/jsoncmd.go SendRawTransactionCmd.MarshalJSON 87.50% (7/8)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go SetGenerateCmd.MarshalJSON 87.50% (7/8)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetAddedNodeInfoCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go GetAddedNodeInfoCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetRawChangeAddressCmd.MarshalJSON 85.71% (6/7)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetNewAddressCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go GetNewAddressCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetBlockTemplateCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go GetBlockTemplateCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetRawMempoolCmd.MarshalJSON 85.71% (6/7)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go GetWorkCmd.MarshalJSON 85.71% (6/7)
|
|
||||||
github.com/conformal/btcjson/jsoncmd.go ListAccountsCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go ListAccountsCmd.MarshalJSON 85.71% (6/7)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go GetRawChangeAddressCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go KeyPoolRefillCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go KeyPoolRefillCmd.MarshalJSON 85.71% (6/7)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go GetWorkCmd.MarshalJSON 85.71% (6/7)
|
||||||
|
github.com/conformal/btcjson/jsoncmd.go GetRawMempoolCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go HelpCmd.MarshalJSON 85.71% (6/7)
|
github.com/conformal/btcjson/jsoncmd.go HelpCmd.MarshalJSON 85.71% (6/7)
|
||||||
github.com/conformal/btcjson/jsoncmd.go NewGetRawChangeAddressCmd 83.33% (5/6)
|
github.com/conformal/btcjson/jsoncmd.go NewGetRawChangeAddressCmd 83.33% (5/6)
|
||||||
github.com/conformal/btcjson/jsoncmd.go NewGetReceivedByAddressCmd 83.33% (5/6)
|
github.com/conformal/btcjson/jsoncmd.go NewGetReceivedByAddressCmd 83.33% (5/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 TlsRpcRawCommand 0.00% (0/1)
|
||||||
github.com/conformal/btcjson/jsonapi.go RpcRawCommand 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/jsonresults.go Vin.IsCoinBase 0.00% (0/1)
|
||||||
github.com/conformal/btcjson --------------------------------------- 78.37% (2348/2996)
|
github.com/conformal/btcjson --------------------------------------- 78.27% (2348/3000)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue