diff --git a/btcjson/chainsvrcmds.go b/btcjson/chainsvrcmds.go index 83c417eb..b90b9279 100644 --- a/btcjson/chainsvrcmds.go +++ b/btcjson/chainsvrcmds.go @@ -278,6 +278,18 @@ func NewGetBlockTemplateCmd(request *TemplateRequest) *GetBlockTemplateCmd { Request: request, } } +// GetCBFilterCmd defines the getcbfilter JSON-RPC command. +type GetCBFilterCmd struct { + Hash string +} + +// NewGetCBFilterCmd returns a new instance which can be used to issue a +// getcbfilter JSON-RPC command. +func NewGetCBFilterCmd(hash string) *GetCBFilterCmd { + return &GetCBFilterCmd{ + Hash: hash, + } +} // GetChainTipsCmd defines the getchaintips JSON-RPC command. type GetChainTipsCmd struct{} @@ -756,6 +768,7 @@ func init() { MustRegisterCmd("getblockhash", (*GetBlockHashCmd)(nil), flags) MustRegisterCmd("getblockheader", (*GetBlockHeaderCmd)(nil), flags) MustRegisterCmd("getblocktemplate", (*GetBlockTemplateCmd)(nil), flags) + MustRegisterCmd("getcbfilter", (*GetCBFilterCmd)(nil), flags) MustRegisterCmd("getchaintips", (*GetChainTipsCmd)(nil), flags) MustRegisterCmd("getconnectioncount", (*GetConnectionCountCmd)(nil), flags) MustRegisterCmd("getdifficulty", (*GetDifficultyCmd)(nil), flags) diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index d623012b..79060be6 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -317,6 +317,19 @@ func TestChainSvrCmds(t *testing.T) { }, }, }, + { + name: "getcbfilter", + newCmd: func() (interface{}, error) { + return btcjson.NewCmd("getcbfilter", "123") + }, + staticCmd: func() interface{} { + return btcjson.NewGetCBFilterCmd("123") + }, + marshalled: `{"jsonrpc":"1.0","method":"getcbfilter","params":["123"],"id":1}`, + unmarshalled: &btcjson.GetCBFilterCmd{ + Hash: "123", + }, + }, { name: "getchaintips", newCmd: func() (interface{}, error) { diff --git a/rpcserver.go b/rpcserver.go index 2408e5a3..312a6596 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -142,6 +142,7 @@ var rpcHandlersBeforeInit = map[string]commandHandler{ "getblockhash": handleGetBlockHash, "getblockheader": handleGetBlockHeader, "getblocktemplate": handleGetBlockTemplate, + "getcbfilter": handleGetCBFilter, "getconnectioncount": handleGetConnectionCount, "getcurrentnet": handleGetCurrentNet, "getdifficulty": handleGetDifficulty, @@ -258,6 +259,7 @@ var rpcLimited = map[string]struct{}{ "getblockcount": {}, "getblockhash": {}, "getblockheader": {}, + "getcbfilter": {}, "getcurrentnet": {}, "getdifficulty": {}, "getheaders": {}, @@ -2144,6 +2146,11 @@ func handleGetBlockTemplate(s *rpcServer, cmd interface{}, closeChan <-chan stru } } +// handleGetCBFilter implements the getcbfilter command. +func handleGetCBFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { + return nil, nil +} + // handleGetConnectionCount implements the getconnectioncount command. func handleGetConnectionCount(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { return s.cfg.ConnMgr.ConnectedCount(), nil diff --git a/rpcserverhelp.go b/rpcserverhelp.go index 1705ebc8..240df9bc 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -323,6 +323,11 @@ var helpDescsEnUS = map[string]string{ "getblocktemplate--condition2": "mode=proposal, accepted", "getblocktemplate--result1": "An error string which represents why the proposal was rejected or nothing if accepted", + // GetCBFilterCmd help. + "getcbfilter--synopsis": "Returns a block's committed bloom filter given its hash.", + "getcbfilter-hash": "The hash of the block", + "getcbfilter--result0": "The block's committed bloom filter", + // GetConnectionCountCmd help. "getconnectioncount--synopsis": "Returns the number of active connections to other peers.", "getconnectioncount--result0": "The number of connections", @@ -668,6 +673,7 @@ var rpcResultTypes = map[string][]interface{}{ "getblockheader": {(*string)(nil), (*btcjson.GetBlockHeaderVerboseResult)(nil)}, "getblocktemplate": {(*btcjson.GetBlockTemplateResult)(nil), (*string)(nil), nil}, "getblockchaininfo": {(*btcjson.GetBlockChainInfoResult)(nil)}, + "getcbfilter": {(*[]byte)(nil)}, "getconnectioncount": {(*int32)(nil)}, "getcurrentnet": {(*uint32)(nil)}, "getdifficulty": {(*float64)(nil)},