diff --git a/btcjson/chainsvrcmds.go b/btcjson/chainsvrcmds.go index 352ea938..ad68467a 100644 --- a/btcjson/chainsvrcmds.go +++ b/btcjson/chainsvrcmds.go @@ -1,4 +1,4 @@ -// Copyright (c) 2014 The btcsuite developers +// Copyright (c) 2014-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -333,6 +333,19 @@ func NewGetInfoCmd() *GetInfoCmd { return &GetInfoCmd{} } +// GetMempoolEntryCmd defines the getmempoolentry JSON-RPC command. +type GetMempoolEntryCmd struct { + TxID string +} + +// NewGetMempoolEntryCmd returns a new instance which can be used to issue a +// getmempoolentry JSON-RPC command. +func NewGetMempoolEntryCmd(txHash string) *GetMempoolEntryCmd { + return &GetMempoolEntryCmd{ + TxID: txHash, + } +} + // GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command. type GetMempoolInfoCmd struct{} @@ -741,6 +754,7 @@ func init() { MustRegisterCmd("getgenerate", (*GetGenerateCmd)(nil), flags) MustRegisterCmd("gethashespersec", (*GetHashesPerSecCmd)(nil), flags) MustRegisterCmd("getinfo", (*GetInfoCmd)(nil), flags) + MustRegisterCmd("getmempoolentry", (*GetMempoolEntryCmd)(nil), flags) MustRegisterCmd("getmempoolinfo", (*GetMempoolInfoCmd)(nil), flags) MustRegisterCmd("getmininginfo", (*GetMiningInfoCmd)(nil), flags) MustRegisterCmd("getnetworkinfo", (*GetNetworkInfoCmd)(nil), flags) diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index fcfdc3b9..43bf84a8 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -383,6 +383,19 @@ func TestChainSvrCmds(t *testing.T) { marshalled: `{"jsonrpc":"1.0","method":"getinfo","params":[],"id":1}`, unmarshalled: &btcjson.GetInfoCmd{}, }, + { + name: "getmempoolentry", + newCmd: func() (interface{}, error) { + return btcjson.NewCmd("getmempoolentry", "txhash") + }, + staticCmd: func() interface{} { + return btcjson.NewGetMempoolEntryCmd("txhash") + }, + marshalled: `{"jsonrpc":"1.0","method":"getmempoolentry","params":["txhash"],"id":1}`, + unmarshalled: &btcjson.GetMempoolEntryCmd{ + TxID: "txhash", + }, + }, { name: "getmempoolinfo", newCmd: func() (interface{}, error) { diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index b6993303..2f368abc 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -1,4 +1,4 @@ -// Copyright (c) 2014 The btcsuite developers +// Copyright (c) 2014-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -166,6 +166,25 @@ type GetBlockTemplateResult struct { RejectReasion string `json:"reject-reason,omitempty"` } +// GetMempoolEntryResult models the data returned from the getmempoolentry +// command. +type GetMempoolEntryResult struct { + Size int32 `json:"size"` + Fee float64 `json:"fee"` + ModifiedFee float64 `json:"modifiedfee"` + Time int64 `json:"time"` + Height int64 `json:"height"` + StartingPriority float64 `json:"startingpriority"` + CurrentPriority float64 `json:"currentpriority"` + DescendantCount int64 `json:"descendantcount"` + DescendantSize int64 `json:"descendantsize"` + DescendantFees float64 `json:"descendantfees"` + AncestorCount int64 `json:"ancestorcount"` + AncestorSize int64 `json:"ancestorsize"` + AncestorFees float64 `json:"ancestorfees"` + Depends []string `json:"depends"` +} + // GetMempoolInfoResult models the data returned from the getmempoolinfo // command. type GetMempoolInfoResult struct { diff --git a/rpcserver.go b/rpcserver.go index af077268..c1406e07 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -222,6 +222,7 @@ var rpcUnimplemented = map[string]struct{}{ "estimatefee": {}, "estimatepriority": {}, "getchaintips": {}, + "getmempoolentry": {}, "getnetworkinfo": {}, "getwork": {}, "invalidateblock": {},