Skip to content

Commit

Permalink
Merge pull request #1 from nepet/gbitcoin/add-public-request
Browse files Browse the repository at this point in the history
Add public request method and getmempoolinfo to the api
  • Loading branch information
wtogami authored Jul 13, 2022
2 parents 74f998c + 6921299 commit 49a9a8e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gbitcoin/bitcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (b *Bitcoin) StartUp(host, bitcoinDir string, port uint) error {
}
}

// Request takes a raw request and issues an RPC call to bitcoind.
func (b *Bitcoin) Request(m jrpc2.Method, resp interface{}) error {
return b.request(m, resp)
}

// Blocking!
func (b *Bitcoin) request(m jrpc2.Method, resp interface{}) error {

Expand Down Expand Up @@ -283,6 +288,29 @@ func (b *Bitcoin) GetRawBlock(blockhash string) (string, error) {
return result, err
}

type MempoolInfo struct {
Loaded bool `json:"loaded"`
Size uint32 `json:"size"`
Bytes uint64 `json:"bytes"`
Usage uint32 `json:"usage"`
MaxMempool uint32 `json:"maxmempool"`
MempoolMinFee float64 `json:"mempoolminfee"`
MinRelayTxFee float64 `json:"minrelaytxfee"`
UnbroadcastCount uint32 `json:"unbroadcastcount"`
}

type GetMempoolInfoReq struct{}

func (r *GetMempoolInfoReq) Name() string {
return "getmempoolinfo"
}

func (b *Bitcoin) GetMempoolInfo() (*MempoolInfo, error) {
var result MempoolInfo
err := b.request(&GetMempoolInfoReq{}, &result)
return &result, err
}

type GetRawTransactionReq struct {
TxId string `json:"txid"`
Blockhash string `json:"blockhash,omitempty"`
Expand Down

0 comments on commit 49a9a8e

Please sign in to comment.