mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
|
)
|
|
|
|
// =====================
|
|
// ChainKitClient related RPCs.
|
|
// =====================
|
|
|
|
// GetBestBlock makes an RPC call to chain kit client's GetBestBlock and
|
|
// asserts.
|
|
func (h *HarnessRPC) GetBestBlock(
|
|
req *chainrpc.GetBestBlockRequest) *chainrpc.GetBestBlockResponse {
|
|
|
|
if req == nil {
|
|
req = &chainrpc.GetBestBlockRequest{}
|
|
}
|
|
|
|
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
|
defer cancel()
|
|
|
|
resp, err := h.ChainKit.GetBestBlock(ctxt, req)
|
|
h.NoError(err, "GetBestBlock")
|
|
|
|
return resp
|
|
}
|
|
|
|
// GetBlock makes an RPC call to chain kit client's GetBlock and asserts.
|
|
func (h *HarnessRPC) GetBlock(
|
|
req *chainrpc.GetBlockRequest) *chainrpc.GetBlockResponse {
|
|
|
|
if req == nil {
|
|
req = &chainrpc.GetBlockRequest{}
|
|
}
|
|
|
|
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
|
defer cancel()
|
|
|
|
resp, err := h.ChainKit.GetBlock(ctxt, req)
|
|
h.NoError(err, "GetBlock")
|
|
|
|
return resp
|
|
}
|
|
|
|
// GetBlockHash makes an RPC call to chain kit client's GetBlockHash and
|
|
// asserts.
|
|
func (h *HarnessRPC) GetBlockHash(
|
|
req *chainrpc.GetBlockHashRequest) *chainrpc.GetBlockHashResponse {
|
|
|
|
if req == nil {
|
|
req = &chainrpc.GetBlockHashRequest{}
|
|
}
|
|
|
|
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
|
defer cancel()
|
|
|
|
resp, err := h.ChainKit.GetBlockHash(ctxt, req)
|
|
h.NoError(err, "GetBlockHash")
|
|
|
|
return resp
|
|
}
|