Implement getrawmempool rpc message

This commit is contained in:
Martin Boehm 2018-01-31 15:04:54 +01:00
parent 71d669c0b9
commit 41c6ed8b6f

View File

@ -56,6 +56,17 @@ type resGetBlockCount struct {
Result uint32 `json:"result"`
}
// getrawmempool
type cmdGetMempool struct {
Method string `json:"method"`
}
type resGetMempool struct {
Error *RPCError `json:"error"`
Result []string `json:"result"`
}
// getblockheader
type cmdGetBlockHeader struct {
@ -308,6 +319,23 @@ func (b *BitcoinRPC) GetBlockFull(hash string) (*Block, error) {
return &res.Result, nil
}
// GetMempool returns transactions in mempool.
func (b *BitcoinRPC) GetMempool() ([]string, error) {
glog.V(1).Info("rpc: getrawmempool")
res := resGetMempool{}
req := cmdGetMempool{Method: "getrawmempool"}
err := b.call(&req, &res)
if err != nil {
return nil, err
}
if res.Error != nil {
return nil, res.Error
}
return res.Result, nil
}
// GetTransaction returns a transaction by the transaction ID.
func (b *BitcoinRPC) GetTransaction(txid string) (*Tx, error) {
glog.V(1).Info("rpc: getrawtransaction ", txid)